Class IncludeTaglet
- java.lang.Object
-
- com.norconex.commons.lang.javadoc.IncludeTaglet
-
- All Implemented Interfaces:
Taglet
public class IncludeTaglet extends Object implements Taglet
{@nx.include} Include text from other JavaDoc documentation found in source files.
Making comments eligible for inclusion
The text to be included is taken from the declared type JavaDoc comment of the referenced class source file. The given text needs to be wrapped by a block tag such as
BlockTaglet,HTMLTaglet,JSONTaglet,XMLTaglet, etc.If you have multiple blocks of text to include from a JavaDoc comment, you can add a reference anchor to it (a recommended practice). In the following example, the JavaDoc comment has two HTML blocks ready to be included by any other JavaDoc comments.
package com.somepackage; /** * <h1>How to create a list</h1> * <p>Two examples:</p> * * {@nx.html #ordered * <ol> * <li>An item.</li> * <li>Another item.</li> * </ol> * } * * {@nx.html #unordered * <ul> * <li>An item.</li> * <li>Another item.</li> * </ul> * } */ public class MyClassWithReusableComments { //... }Including comments
The
{@nx.include ...}directive is used to reference other classes along with which comment block to include. The complete syntax is:{@nx.include [class][@tagName][#reference]}Where each elements in square brackets are:
class The fully qualified class name containing the comment to include. Required. @tagName The name of the block tag wrapping the comment. If there are multiple block tags with the same name in the class comment, the first one will be picked. Use #referencefor more precision. At least one of@tagNameand#referenceneed to be specified.#reference Matches the reference anchor defined in the included class comment. Those should be unique within a class comment so should be favored over @tagNamewhen present. At least one of@tagNameand#referenceneed to be specified.The following example will insert the two blocks defined in the previous example along with additional HTML.
/** * <p> * Here are two types of HTML lists: * </p> * {@nx.html * * <h1>Ordered List</h1> * {@nx.include com.somepackage.MyClassWithReusableComments#ordered} * * <h1>Unordered List</h1> * {@nx.include com.somepackage.MyClassWithReusableComments#unordered} * } */ public class MyClassIncludingComments { //... }One thing to keep in mind is the included text is taken as is. If you want to format it, you would need to wrap it yourself like above. Includes can be nested in any other
@nx.*taglets.- Since:
- 2.0.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jdk.javadoc.doclet.Taglet
Taglet.Location
-
-
Constructor Summary
Constructors Constructor Description IncludeTaglet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<Taglet.Location>getAllowedLocations()StringgetName()voidinit(DocletEnvironment env, Doclet doclet)booleanisInlineTag()StringtoString(List<? extends DocTree> tags, Element element)
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init(DocletEnvironment env, Doclet doclet)
-
getAllowedLocations
public Set<Taglet.Location> getAllowedLocations()
- Specified by:
getAllowedLocationsin interfaceTaglet
-
isInlineTag
public boolean isInlineTag()
- Specified by:
isInlineTagin interfaceTaglet
-
-