在 Maven 站点生成的 html 中添加到 JavaDoc 的动态链接

发布于 2024-08-08 19:05:34 字数 558 浏览 3 评论 0原文

我想知道是否有一种方法可以通过 maven 站点插件自动创建指向它生成的 html 中的某些 JavaDoc 结构(如类)的链接。

作为我的意思的一个例子,Doxygen 提供了一种通过使用 doxy 协议来做到这一点的方法。您可以像这样创建一个锚点:

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

然后,当您运行 Doxygen 时,它将用对包含 ExampleClass 文档的相应 html 文件的引用来替换 doxy:// 引用。这样,如果此类或其文档的位置发生更改,我不需要记住返回并修复链接,因为 Doxygen 会在下一次构建时自动更改它。

Maven Site 在导航栏中生成并提供了一个指向 JavaDoc 索引的链接,并且 JavaDoc 中存在链接到实际源代码的链接,但我希望将对文档中的类所做的任何引用都转换为指向该类的链接class' JavaDoc,而不必担心如果情况发生变化,在未来版本中保持最新状态。

这可能吗?或者我被硬编码的链接困住了?

提前致谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待我真够勒 2024-08-15 19:05:34

据我所知, Doxia 使用的内容生成框架本身并不支持这一点Maven 和任何 Doxia 模块。所以我想你必须“硬编码”你的链接。

如果您使用 APT,请注意 Doxia-1.1(Maven >= 2.1.x 使用)对原始 APT 格式进行了一些增强。关于链接

在 Doxia-1.1 中,“本地”的概念
除了以下内容之外还引入了链接
内部链接和外部链接。 [...]

  • 本地链接是指向同一站点内另一个文档的链接。
    本地链接必须开头
    ./../ 来区分
    他们来自内部链接。例如

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

虽如此,解决方案可能是使用包含在中的 宏机制多克西娅。但您必须为此功能编写自己的宏。不过,这应该不会太难,请检查 源存储库中的现有代码

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文