从Taglet访问Java注释

时间:2022-09-25 12:14:54

I'm working on a project where we have some custom Taglet classes that are used to modify the Javadocs (such as linking to source code in SVN, adding citations) and so on.One of the things we'd like to do is to be able to get the annotations that are used in the source and manipulate the information from them.

我正在开发一个项目,我们有一些用于修改Javadoc的自定义Taglet类(例如链接到SVN中的源代码,添加引用)等等。我们要做的一件事就是能够获取源中使用的注释并操纵它们的信息。

It seems that the Taglet interface does not provide an easy way to access annotations in the Java source code. Does anybody know if this is at all possible?

似乎Taglet接口不提供访问Java源代码中的注释的简单方法。有人知道这是否可能吗?

I'm using JDK 1.5

我正在使用JDK 1.5

1 个解决方案

#1


3  

If your taglet is called from the standard doclet, you can access its internal state:

如果从标准doclet调用taglet,则可以访问其内部状态:

import com.sun.tools.doclets.standard.Standard;

ClassDoc currentcd = Standard.htmlDoclet.configuration.currentcd;

I have written a Taglet that uses this technique, but it sure ain't pretty ;-)

我写了一个使用这种技术的Taglet,但肯定不漂亮;-)

#1


3  

If your taglet is called from the standard doclet, you can access its internal state:

如果从标准doclet调用taglet,则可以访问其内部状态:

import com.sun.tools.doclets.standard.Standard;

ClassDoc currentcd = Standard.htmlDoclet.configuration.currentcd;

I have written a Taglet that uses this technique, but it sure ain't pretty ;-)

我写了一个使用这种技术的Taglet,但肯定不漂亮;-)