Class SimpleGroovyClassDoc
java.lang.Object
org.codehaus.groovy.tools.groovydoc.SimpleGroovyDoc
org.codehaus.groovy.tools.groovydoc.SimpleGroovyProgramElementDoc
org.codehaus.groovy.tools.groovydoc.SimpleGroovyAbstractableElementDoc
org.codehaus.groovy.tools.groovydoc.SimpleGroovyClassDoc
- All Implemented Interfaces:
Comparable<GroovyDoc>,GroovyClassDoc,GroovyDoc,GroovyProgramElementDoc,GroovyType
public class SimpleGroovyClassDoc
extends SimpleGroovyAbstractableElementDoc
implements GroovyClassDoc
Default
GroovyClassDoc implementation for classes parsed from Groovy or Java source.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternPattern used to locate{@code ...}style inline tags for angle-bracket escaping.static final StringPattern used to replace{@docRoot}references.static final StringPattern used to replace{@docRoot}/references.static final PatternPattern used to split a method reference into its name and argument list.static final PatternPattern used to split a reference target from its optional label.static final PatternPattern used to split comma-separated method argument declarations.Fields inherited from class org.codehaus.groovy.tools.groovydoc.SimpleGroovyDoc
ANNOTATION_DEF, CLASS_DEF, ENUM_DEF, INTERFACE_DEF, RECORD_DEF, TRAIT_DEF -
Constructor Summary
ConstructorsConstructorDescriptionSimpleGroovyClassDoc(List<String> importedClassesAndPackages, String name) Creates a documented class with explicit imports and no aliases.SimpleGroovyClassDoc(List<String> importedClassesAndPackages, Map<String, String> aliases, String name) Creates a documented class with explicit imports and aliases.SimpleGroovyClassDoc(List<String> importedClassesAndPackages, Map<String, String> aliases, String name, List<LinkArgument> links) Creates a documented class with explicit imports, aliases, and external links. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(GroovyConstructorDoc constructor) Adds a constructor to this class.booleanadd(GroovyFieldDoc field) Adds a field to this class.booleanadd(GroovyMethodDoc method) Adds a method to this class.booleanaddEnumConstant(GroovyFieldDoc field) Adds an enum constant to this class.voidaddInterfaceName(String className) Adds the name of an implemented or extended interface for later resolution.booleanaddNested(GroovyClassDoc nestedClass) Adds a nested class or interface to this class.booleanaddProperty(GroovyFieldDoc property) Adds a property to this class.Returns the processed comment text for this element.returns a sorted array of constructorsconstructors(boolean filter) Returns the constructors declared by this type, optionally applying the active visibility filter.booleanIndicates whether this type explicitly defines serializable fields metadata.static StringencodeAngleBrackets(String text) Escapes angle brackets in plain text so they remain visible in rendered HTML.static StringencodeAngleBracketsInTagBody(String text, Pattern regex) Replaces angle brackets inside a tag.returns a sorted array of enum constantsfields()returns a sorted array of fieldsfields(boolean filter) Returns the fields declared by this type, optionally applying the active visibility filter.Resolves a referenced class name from the context of this type.Returns the first sentence of the processed comment text.Builds a documentation URL for the supplied type using the current rendering context.Builds a documentation URL for the supplied type using the current rendering context.static StringgetDocUrl(String type, boolean full, List<LinkArgument> links, String relativePath, GroovyRootDoc rootDoc, SimpleGroovyClassDoc classDoc) Builds a documentation URL for the supplied type using explicit rendering context inputs.Returns the documentation output path for this type.Returns the rendered class name including any type arguments.getOuter()Returns the enclosing class when this class is nested.Returns this class together with its resolved superclass chain.Returns this class and all interfaces reachable from its direct interfaces.Returns the relative path from this type to the documentation root.Returns the unresolved superclass name parsed from source.Returns the explicitly imported classes visible to this type.Returns the imported packages visible to this type.returns a sorted array of nested classes and interfacesinnerClasses(boolean filter) Returns the nested classes declared by this type, optionally applying the active visibility filter.Returns the interfaces directly implemented or extended by this type.Returns the interface types directly implemented or extended by this type.booleanIndicates whether this type implementsExternalizable.booleanisGroovy()Indicates whether this class originated from Groovy source.booleanIndicates whether this type is a Java primitive type.booleanIndicates whether this type implementsSerializable.methods()returns a sorted array of methodsmethods(boolean filter) Returns the methods declared by this type, optionally applying the active visibility filter.returns a sorted array of propertiesThe qualified name of this type excluding any dimension information.replaceTags(String comment) Replaces inline tags in the supplied comment using this class as the rendering context.replaceTags(String comment, GroovyMemberDoc memberDoc) GROOVY-3782 / GROOVY-6016: overload that threads the current member through toTagRendererso inline tags that need the enclosing member context (e.g.Returns the fields that participate in serialization.Returns the methods related to custom serialization.voidsetFullPathName(String fullPathName) Sets the output path used for this class in generated documentation.voidsetGroovy(boolean isgroovy) Sets whether this class originated from Groovy source.voidsetNameWithTypeArgs(String nameWithTypeArgs) Stores the rendered class name including any type arguments.voidsetOuter(GroovyClassDoc outer) Sets the enclosing class for this nested class.voidSets the resolved superclass for this class.voidsetSuperClassName(String className) Stores the unresolved superclass name parsed from source.The unqualified name of this type excluding any dimension or nesting information.booleansubclassOf(GroovyClassDoc gcd) Determines whether this type is a subclass of the supplied candidate.Returns the direct superclass of this type.Returns the direct superclass as a type reference.typeName()The unqualified name of this type excluding any dimension information.Methods inherited from class org.codehaus.groovy.tools.groovydoc.SimpleGroovyAbstractableElementDoc
isAbstract, setAbstractMethods inherited from class org.codehaus.groovy.tools.groovydoc.SimpleGroovyProgramElementDoc
addAnnotationRef, annotations, containingClass, containingPackage, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, modifiers, modifierSpecifier, qualifiedName, setContainingPackage, setFinal, setPackagePrivate, setPrivate, setProtected, setPublic, setStaticMethods inherited from class org.codehaus.groovy.tools.groovydoc.SimpleGroovyDoc
calculateFirstSentence, compareTo, getRawCommentText, getTypeDescription, getTypeSourceDescription, isAnnotationType, isAnnotationTypeElement, isClass, isConstructor, isDeprecated, isEnum, isEnumConstant, isError, isException, isField, isHidden, isIncluded, isInterface, isMarkdown, isMethod, isOrdinaryClass, isRecord, isScript, isTrait, name, setCommentText, setDeprecated, setFirstSentenceCommentText, setHidden, setMarkdown, setRawCommentText, setScript, setTokenType, tags, tokenType, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.codehaus.groovy.groovydoc.GroovyClassDoc
isAbstractMethods inherited from interface org.codehaus.groovy.groovydoc.GroovyDoc
getRawCommentText, isAnnotationType, isAnnotationTypeElement, isClass, isConstructor, isDeprecated, isEnum, isEnumConstant, isError, isException, isField, isIncluded, isInterface, isMethod, isOrdinaryClass, isRecord, name, setRawCommentTextMethods inherited from interface org.codehaus.groovy.groovydoc.GroovyProgramElementDoc
annotations, containingClass, containingPackage, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, modifiers, modifierSpecifier, qualifiedNameMethods inherited from interface org.codehaus.groovy.groovydoc.GroovyType
toString
-
Field Details
-
DOCROOT_PATTERN2
Pattern used to replace{@docRoot}/references.- See Also:
-
DOCROOT_PATTERN
Pattern used to replace{@docRoot}references.- See Also:
-
CODE_REGEX
Pattern used to locate{@code ...}style inline tags for angle-bracket escaping. -
REF_LABEL_REGEX
Pattern used to split a reference target from its optional label. -
NAME_ARGS_REGEX
Pattern used to split a method reference into its name and argument list. -
SPLIT_ARGS_REGEX
Pattern used to split comma-separated method argument declarations.
-
-
Constructor Details
-
SimpleGroovyClassDoc
public SimpleGroovyClassDoc(List<String> importedClassesAndPackages, Map<String, String> aliases, String name, List<LinkArgument> links) Creates a documented class with explicit imports, aliases, and external links.- Parameters:
importedClassesAndPackages- the imports visible to the classaliases- the import aliases visible to the classname- the simple class namelinks- the configured external documentation links
-
SimpleGroovyClassDoc
public SimpleGroovyClassDoc(List<String> importedClassesAndPackages, Map<String, String> aliases, String name) Creates a documented class with explicit imports and aliases.- Parameters:
importedClassesAndPackages- the imports visible to the classaliases- the import aliases visible to the classname- the simple class name
-
SimpleGroovyClassDoc
Creates a documented class with explicit imports and no aliases.- Parameters:
importedClassesAndPackages- the imports visible to the classname- the simple class name
-
-
Method Details
-
constructors
returns a sorted array of constructors- Specified by:
constructorsin interfaceGroovyClassDoc- Returns:
- the declared constructors
-
add
Adds a constructor to this class.- Parameters:
constructor- the constructor to add- Returns:
trueif the constructor was added
-
getOuter
Returns the enclosing class when this class is nested.- Returns:
- the enclosing class, or
nullif this class is top-level
-
setOuter
Sets the enclosing class for this nested class.- Parameters:
outer- the enclosing class
-
isGroovy
public boolean isGroovy()Indicates whether this class originated from Groovy source.- Returns:
trueif this class came from Groovy source
-
setGroovy
public void setGroovy(boolean isgroovy) Sets whether this class originated from Groovy source.- Parameters:
isgroovy-trueif this class came from Groovy source
-
innerClasses
returns a sorted array of nested classes and interfaces- Specified by:
innerClassesin interfaceGroovyClassDoc- Returns:
- the nested classes
-
addNested
Adds a nested class or interface to this class.- Parameters:
nestedClass- the nested class to add- Returns:
trueif the nested class was added
-
fields
returns a sorted array of fields- Specified by:
fieldsin interfaceGroovyClassDoc- Returns:
- the declared fields
-
add
Adds a field to this class.- Parameters:
field- the field to add- Returns:
trueif the field was added
-
properties
returns a sorted array of properties- Specified by:
propertiesin interfaceGroovyClassDoc- Returns:
- the declared properties
-
addProperty
Adds a property to this class.- Parameters:
property- the property to add- Returns:
trueif the property was added
-
enumConstants
returns a sorted array of enum constants- Specified by:
enumConstantsin interfaceGroovyClassDoc- Returns:
- the declared enum constants
-
addEnumConstant
Adds an enum constant to this class.- Parameters:
field- the enum constant to add- Returns:
trueif the enum constant was added
-
methods
returns a sorted array of methods- Specified by:
methodsin interfaceGroovyClassDoc- Returns:
- the declared methods
-
add
Adds a method to this class.- Parameters:
method- the method to add- Returns:
trueif the method was added
-
getSuperClassName
Returns the unresolved superclass name parsed from source.- Returns:
- the unresolved superclass name, or
nullif none was declared
-
setSuperClassName
Stores the unresolved superclass name parsed from source.- Parameters:
className- the unresolved superclass name
-
superclass
Returns the direct superclass of this type.- Specified by:
superclassin interfaceGroovyClassDoc- Returns:
- the direct superclass, or
nullif none exists
-
setSuperClass
Sets the resolved superclass for this class.- Parameters:
doc- the resolved superclass
-
getFullPathName
Returns the documentation output path for this type.- Specified by:
getFullPathNamein interfaceGroovyClassDoc- Returns:
- the full path used when rendering this type
-
setFullPathName
Sets the output path used for this class in generated documentation.- Parameters:
fullPathName- the documentation path for this class
-
getRelativeRootPath
Returns the relative path from this type to the documentation root.- Specified by:
getRelativeRootPathin interfaceGroovyClassDoc- Returns:
- the relative path to the documentation root
-
getParentClasses
Returns this class together with its resolved superclass chain.- Returns:
- the superclass chain ordered from the root type to this class
-
getParentInterfaces
Returns this class and all interfaces reachable from its direct interfaces.- Returns:
- the transitive interface closure for this class
-
getDocUrl
Builds a documentation URL for the supplied type using the current rendering context.- Parameters:
type- the type or reference to render- Returns:
- the rendered documentation URL or original text
-
getDocUrl
Builds a documentation URL for the supplied type using the current rendering context.- Parameters:
type- the type or reference to renderfull-trueto prefer fully qualified labels- Returns:
- the rendered documentation URL or original text
-
getDocUrl
public static String getDocUrl(String type, boolean full, List<LinkArgument> links, String relativePath, GroovyRootDoc rootDoc, SimpleGroovyClassDoc classDoc) Builds a documentation URL for the supplied type using explicit rendering context inputs.- Parameters:
type- the type or reference to renderfull-trueto prefer fully qualified labelslinks- the configured external documentation linksrelativePath- the relative path back to the documentation rootrootDoc- the root document used for in-project lookupsclassDoc- the current class context- Returns:
- the rendered documentation URL or original text
-
constructors
Returns the constructors declared by this type, optionally applying the active visibility filter.- Specified by:
constructorsin interfaceGroovyClassDoc- Parameters:
filter-trueto include only visible constructors,falseto include all constructors- Returns:
- the matching constructors
-
definesSerializableFields
public boolean definesSerializableFields()Indicates whether this type explicitly defines serializable fields metadata.- Specified by:
definesSerializableFieldsin interfaceGroovyClassDoc- Returns:
trueif serializable fields are defined explicitly
-
fields
Returns the fields declared by this type, optionally applying the active visibility filter.- Specified by:
fieldsin interfaceGroovyClassDoc- Parameters:
filter-trueto include only visible fields,falseto include all fields- Returns:
- the matching fields
-
findClass
Resolves a referenced class name from the context of this type.- Specified by:
findClassin interfaceGroovyClassDoc- Parameters:
className- the class name to resolve- Returns:
- the matching class documentation, or
nullif it cannot be resolved
-
importedClasses
Returns the explicitly imported classes visible to this type.- Specified by:
importedClassesin interfaceGroovyClassDoc- Returns:
- the imported classes
-
importedPackages
Returns the imported packages visible to this type.- Specified by:
importedPackagesin interfaceGroovyClassDoc- Returns:
- the imported packages
-
innerClasses
Returns the nested classes declared by this type, optionally applying the active visibility filter.- Specified by:
innerClassesin interfaceGroovyClassDoc- Parameters:
filter-trueto include only visible nested classes,falseto include all nested classes- Returns:
- the matching nested classes
-
interfaces
Returns the interfaces directly implemented or extended by this type.- Specified by:
interfacesin interfaceGroovyClassDoc- Returns:
- the direct interfaces
-
interfaceTypes
Returns the interface types directly implemented or extended by this type.- Specified by:
interfaceTypesin interfaceGroovyClassDoc- Returns:
- the direct interface types
-
isExternalizable
public boolean isExternalizable()Indicates whether this type implementsExternalizable.- Specified by:
isExternalizablein interfaceGroovyClassDoc- Returns:
trueif this type is externalizable
-
isSerializable
public boolean isSerializable()Indicates whether this type implementsSerializable.- Specified by:
isSerializablein interfaceGroovyClassDoc- Returns:
trueif this type is serializable
-
methods
Returns the methods declared by this type, optionally applying the active visibility filter.- Specified by:
methodsin interfaceGroovyClassDoc- Parameters:
filter-trueto include only visible methods,falseto include all methods- Returns:
- the matching methods
-
serializableFields
Returns the fields that participate in serialization.- Specified by:
serializableFieldsin interfaceGroovyClassDoc- Returns:
- the serializable fields
-
serializationMethods
Returns the methods related to custom serialization.- Specified by:
serializationMethodsin interfaceGroovyClassDoc- Returns:
- the serialization methods
-
subclassOf
Determines whether this type is a subclass of the supplied candidate.- Specified by:
subclassOfin interfaceGroovyClassDoc- Parameters:
gcd- the candidate superclass- Returns:
trueif this type is a subclass ofgcd
-
superclassType
Returns the direct superclass as a type reference.- Specified by:
superclassTypein interfaceGroovyClassDoc- Returns:
- the direct superclass type, or
nullif none exists
-
isPrimitive
public boolean isPrimitive()Indicates whether this type is a Java primitive type.- Specified by:
isPrimitivein interfaceGroovyType- Returns:
trueif this type is primitive
-
qualifiedTypeName
The qualified name of this type excluding any dimension information. For example, a two-dimensional array of String returns "java.lang.String".- Specified by:
qualifiedTypeNamein interfaceGroovyType
-
simpleTypeName
The unqualified name of this type excluding any dimension or nesting information. For example, the classOuter.Innerreturns "Inner".- Specified by:
simpleTypeNamein interfaceGroovyType
-
typeName
The unqualified name of this type excluding any dimension information. For example, a two-dimensional array of String returns "String".- Specified by:
typeNamein interfaceGroovyType
-
addInterfaceName
Adds the name of an implemented or extended interface for later resolution.- Parameters:
className- the interface name to add
-
firstSentenceCommentText
Returns the first sentence of the processed comment text.- Specified by:
firstSentenceCommentTextin interfaceGroovyDoc- Overrides:
firstSentenceCommentTextin classSimpleGroovyDoc- Returns:
- the first sentence summary
-
commentText
Returns the processed comment text for this element.- Specified by:
commentTextin interfaceGroovyDoc- Overrides:
commentTextin classSimpleGroovyDoc- Returns:
- the rendered comment text
-
replaceTags
Replaces inline tags in the supplied comment using this class as the rendering context.- Parameters:
comment- the comment to process- Returns:
- the processed comment text
-
replaceTags
GROOVY-3782 / GROOVY-6016: overload that threads the current member through toTagRendererso inline tags that need the enclosing member context (e.g.{@inheritDoc}needs the current method to find its overridden parent) can resolve.- Since:
- 6.0.0
-
encodeAngleBracketsInTagBody
Replaces angle brackets inside a tag.- Parameters:
text- GroovyDoc text to processregex- has to capture tag name in group 1 and tag body in group 2
-
encodeAngleBrackets
Escapes angle brackets in plain text so they remain visible in rendered HTML.- Parameters:
text- the text to escape- Returns:
- the escaped text
-
setNameWithTypeArgs
Stores the rendered class name including any type arguments.- Parameters:
nameWithTypeArgs- the rendered class name with type arguments
-
getNameWithTypeArgs
Returns the rendered class name including any type arguments.- Returns:
- the class name with type arguments, or
nullif none was recorded
-