如何在 Ant 脚本中创建 Javadoc 自定义标记

How to create Javadoc custom tag in Ant script

目前我正在尝试通过 ant 脚本创建自定义 javadoc 标签,以在 class 级注释中声明一些属性。

我需要在方法级别创建一个类似于@param 标签的自定义标签。此标签可以在 class 级别中声明 n 次。

/**
* @argument name of the argument1: description1
* @argument name of the argument2: description2
*/
public class MainClass{
}

我希望生成的 javadoc 如下所示:

Arguments:
name of the argument1: - description1
name of the argument2: - description2

目前我正在使用以下语法创建自定义标记,并且以下语法生成 JavaDoc,由于无法拆分参数,因此将所有参数附加为一个文本。

<tag name="<Name of the Tag>" scope="all" description="<Description about the tag>"/>

Arguments:
name of the argument1: - description1, name of the argument2: - description2

实际上,Ant 中的<tag> 标记只是指定javadoc 工具的-tag 参数的一种方式。参见 here

-tag 参数在其输出方面不是很可定制。所以我不认为你可以那样实现你想要的。

但是,您可以实现自己的标记处理程序(或者,Javadoc 称之为:Taglet)并完全自定义其输出。有关详细信息,请参阅 Taglet documentation

在 Ant 中,您可以使用 <taglet> 标记在构建过程中使用它。

感谢斯特凡的回复。我也尝试过这个选项,但我没有成功。

         <taglet name="<packagename>.<Classname">
                        <path>
                            <pathelement location="bin"/>
                          </path>
                     </taglet>
                </javadoc>```

Taglet is registering properly but i get below warning and the tag information is not present in the generated html page.

     [javadoc] Registered Taglet packagename.ArgumentsTaglet ...
  [javadoc] Standard Doclet version 1.8.0_121
  [javadoc] Building tree for all the packages and classes...
  [javadoc] Building index for all the packages and classes...
  [javadoc] Building index for all classes...
  [javadoc] Generating C:\temp\Projects\TagletCreation\docs\help-doc.html...
  [javadoc] Note: Custom tags that were not seen:  @arguments
  [javadoc] 100 warnings

Note: I am using Java 1.8 version.