Search code examples
javaantjavadocfavicon

Creating Javadoc HTML pages that use a favicon


I want to include an element in the <head> of my generated Javadoc HTML:

<link rel="shortcut icon" href="my-project-icon.ico" />

Note that I'm using an Ant task to generate the Javadoc.

I tried using the <header> element of the Ant task, but any markup placed there ends up within an <h1> tag, which is invalid and therefore ignored by the browser.


Solution

  • I would definitely modify the output files as an easy brute force solution. But a sophisticated way would be to have a custom doclet. This doclet would be a copy of standard doclet (Where can you download the source for the standard JavaDoc doclet for current releases (1.5 or 1.6)).

    In HtmlDocletWriter.java there are many lines head.addContent. You would add one more such a line, perhaps based on HtmlTree.LINK.