如何获取 com.sun.javadoc.Taglet 中 {@docroot} 的值?

发布于 2024-09-30 11:03:59 字数 253 浏览 0 评论 0原文

我正在编写一个自定义 taglet,用于将 mathML 文件包含在 javadoc html 文件中。我想将所有 *.mml 文件存储在同一个文件夹中,可能在该

{@docroot}/doc-files

文件夹中。我的问题是:我如何知道 Taglet 对象中的 @docRoot 字符串的值(更具体地说,在 toString(com.sun.javadoc.Tag tag) 方法中? 非常感谢!

I'm writing a custom taglet for inclusion of a mathML file in a javadoc html file. I would like to store all my *.mml files in the same folder, possibly in the

{@docroot}/doc-files

folder. My question is : how can I know the value of the @docRoot string within a Taglet object (more specifically, within the toString(com.sun.javadoc.Tag tag) method ?
Many thanks!

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

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

发布评论

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

评论(2

过期情话 2024-10-07 11:03:59

我还需要在 javadoc 中显示 MathML。我在这里写了一篇关于如何解决它的博客文章: http://chadretz.wordpress.com/2010/12/19/mathml-inside-javadoc-using-mathjax-and-a-custom-taglet/

更具体地说,您的但问题是,如果你查看我发布在那里的 Taglet 源代码(默认情况下折叠),你可以看到我在哪里获取 Tag.holder() 的顶级 ClassDoc 来获取我所在的目录深度,以便我可以向上遍历。如果您需要相对 HTML 根目录,这会有所帮助。如果您需要在 Taglet 运行时知道 MML 的位置,我建议您将它们放在类路径中并作为资源访问它们。

I also needed to display MathML in my javadoc. I wrote a blog post about how I solved it here: http://chadretz.wordpress.com/2010/12/19/mathml-inside-javadoc-using-mathjax-and-a-custom-taglet/

More specifically to your problem though, if you look at the Taglet source code I posted there (collapsed by default), you can see where I get the top level ClassDoc of the Tag.holder() to obtain the directory depth I am at so I can traverse up. This helps if you need the relative HTML root. If you need to know the location of your MML's while the Taglet is running, I suggest you put them on the classpath and access them as resources.

风情万种。 2024-10-07 11:03:59

@ChadRetz 的博客,我创建了一个实用程序类,其中包含一个可以执行您想要的操作的函数:给定一个 com.sun.javadoc.Tag ,它返回从其封闭文件(包含该标记的文件)到 JavaDoc 根目录的相对 url ——这相当于 {@docRoot}

该类名为 < code>ComSunJavaDocUtil,函数名称为 getRelativeUrlToDocRoot

taglet 的 toString() 函数示例:

public String toString(Tag tag) {
   return  "Relative url to DOC ROOT for this tag's enclosing file is \"" + 
      ComSunJavaDocUtil.getRelativeUrlToDocRoot(tag) + "\"";
}

该实用程序类是 Codelet 的一部分。安装说明位于此处。如果您要使用的只是这个实用程序类,那么您的类路径中所需的唯一 jar 就是 codeletxbnjava...当然,还有 com.sun.javadoc

Starting with the getPackageDoc function from @ChadRetz's blog, I've created a utility class that contains a function that does what you wish: Given a com.sun.javadoc.Tag, it returns the relative url from its enclosing file (the file containing that tag), to the JavaDoc root directory--this is the equivalent of {@docRoot}.

The class is called ComSunJavaDocUtil, and the function name is getRelativeUrlToDocRoot.

An example taglet's toString() function:

public String toString(Tag tag) {
   return  "Relative url to DOC ROOT for this tag's enclosing file is \"" + 
      ComSunJavaDocUtil.getRelativeUrlToDocRoot(tag) + "\"";
}

This utility class is part of Codelet. Installation instructions are here. If this utility class is all you're going to use, then the only jars you need on your classpath are codelet and xbnjava...and, of course, com.sun.javadoc.

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