Search code examples
htmljavadoc

Link which jumps to specific method in deployed javadoc


I want to generate a URL which, when opened, jumps to a specific method in the Javadoc.

I would assume that the standard Javadoc generator also adds the id attribute to some element containing the method. That way it would have been easy. A URL could look like http://example.com/javadoc/some/package/MyClass#specialMethod. Sadly I can't see the id attribute set anywhere in the generated Javadoc files.

Is it possible to pass arguments to the javadoc generator which would also add ids to the methods? Or do I have to edit the source of the javadoc generator?

Another solution I thought of, was adding html to every method I'm interested in. Something like <p id="specialMethod" style="visibility:hidden;"></p>, but I wouldn't like to do this for obvious reasons.


Solution

  • I found, that there is a <a> tag surrounding the title of the method with the name attribute set. <a name="specialMethod--"></a>.

    So I just had to add the two dashes at the end of the url:

    http://example.com/javadoc/some/package/MyClass#specialMethod--

    This may not work in the future as per HTML5 the nameattribute is obsolete on the a tag.