Thursday, June 14, 2007

Displaying Javadocs in Subversion

Javadocs are an essential component of any Java project. It is a convenient way for a developer to gain an understanding of the API and the prescribed ways to use it. This is especially true when hosting open source projects on Google Code or Sourceforge. Subversion is increasingly used as a revision control system to host source code and other project related artifacts. Google Code uses Subversion exclusively while Sourceforge provides it as an option. At times, for the convenience of hosting and to centralize resources it may be required to host the Javadocs in Subversion and access them via a browser. When using Eclipse as the IDE, connecting to a Subversion server is simple through the Subclipse plugin.

On successfully committing the Javadocs to the server and viewing the exported pages through a browser, we notice that the pages display in text and are not rendered as normal HTML pages by the browser (Screenshot). The reason behind this is that the MIME type for the pages is set to text/plain and must be changed to text/html. This can be achieved through the Eclipse UI by applying the MIME type to the svn:mime-type property on the root directory of the Javadocs. The Set property recursively option must be checked to ensure that all the pages under subdirectories are also updated with the correct type.

The last change is to update the MIME type of stylesheet.css to text/css. The Javadocs in Subversion can now be viewed successfully through a browser (Screenshot).

No comments: