views:

382

answers:

1

I am wondering if there is a way through the maven site plugin to have it automatically create a link to some JavaDoc structure (like a class) within the html it generates.

As an example of what I mean, Doxygen provides a way to do this through using the doxy protocol. You can create an anchor like such:

<a href="doxy://class/ExampleClass">ExampleClass</a>

Then, when you run Doxygen, it will replace the doxy:// reference with a reference to the appropriate html file containing the documentation of ExampleClass. This way, if the location of this class or its documentation ever changed, I wouldn't need to remember to go back and fix the link, as Doxygen will change it automatically on next build.

Maven Site generates and provides a link to the JavaDoc index in the navigation bar, and there are links in the JavaDoc that link to the actual source code, but I was hoping to turn any references I make to classes within the documentation into links to that class' JavaDoc without having to worry about keeping it up to date in future releases if things change.

Is this possible? Or am I stuck with hard coded links?

Thanks in advance!

+2  A: 

To my knowledge, this is not natively supported by Doxia, the content generation framework used by Maven, and any of the Doxia Modules. So I guess you'll have to "hard code" your links.

If you use APT, note that Doxia-1.1 (used by Maven >= 2.1.x) incorporates some enhancements to the original APT format. Regarding links:

In Doxia-1.1 the notion of 'local' link was introduced in addition to internal links and external links. [...]

  • A local link is a link to another document within the same site. Local links have to start with either ./ or ../ to distinguish them from internal links. E.g.

    {{{./apidocs/com/company/example/ExampleClass.html}ExampleClass}}
    

Having that said, a solution might be to use the macro mechanisms included in Doxia. But you'll have to write your own macro for this feature. It shouldn't be too hard though, check existing code in the source repository.

Pascal Thivent
Thanks! I created a macro like you suggested above that takes a class and turns it into a link to its JavaDoc. I, however, see now that due to having to include the full package info on a class, like you mentioned above, means that if the class location ever changes, I still have to change every reference to the class in the macro since its package will have changed. Therefore I believe that unless I can find an unchanging unique identifier for java, the only benefit to having a macro generate a dynamic link, is if the overall format of every link changed, then I could just change the macro.
FModa3
Yes, hence my initial question. The advantage I can see with a macro is that you write the fully qualified name of a class only once (in the macro). But indeed, you'll still have to update it if it changes.
Pascal Thivent