开发者

Adding dynamic links to JavaDoc within Maven Site generated html

开发者 https://www.devze.com 2022-12-08 10:14 出处:网络
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.

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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消