Search code examples
anttagsjavadoc

How to create Javadoc custom tag in Ant script


Currently i am trying to create custom javadoc tags through ant script to declare some attributes in the class level comment.

I need to create one custom tag which is similar to @param tag in the method level. This tag can be declared n number of time in the class level.

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

And i am expecting the javadoc to be generated as below:

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

Currently I am using below syntax to create custom tag and the below syntax generates JavaDoc, appending all argument as one text due to this unable to split the argument.

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

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

Solution

  • Actually, the <tag> tag in Ant is just a way to specify the -tag parameter of the javadoc tool. See here.

    The -tag parameter is not very customizable with respect to its output. So I don‘t think you can achieve what you want that way.

    However, you can implement your own tag handler (or, as Javadoc calls it: Taglet) and fully customize its output. See the Taglet documentation for more information.

    In Ant, you can then use the <taglet> tag to use it in the build process.