CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-apache-groovy--groovy-groovydoc

A documentation generation tool for Groovy code, part of the Apache Groovy programming language suite

Pending
Overview
Eval results
Files

doc-model.mddocs/

Documentation Model

The documentation model provides a hierarchical object representation of the parsed Groovy and Java source code documentation. This model allows programmatic access to all documented elements including packages, classes, methods, fields, and their relationships.

Model Hierarchy

The documentation model follows this hierarchy:

  • GroovyRootDoc - Root of all documentation
    • GroovyPackageDoc - Package-level documentation
      • GroovyClassDoc - Class/interface documentation
        • GroovyMethodDoc - Method documentation
        • GroovyFieldDoc - Field/property documentation
        • GroovyConstructorDoc - Constructor documentation

Core Interfaces

GroovyDoc

Base interface for all documentation elements.

public interface GroovyDoc {
    String commentText()                    // Get processed comment text
    String getRawCommentText()             // Get raw comment text
    String name()                          // Get element name
    String firstSentenceCommentText()      // Get first sentence for summaries
    
    // Type checking methods
    boolean isClass()
    boolean isInterface() 
    boolean isMethod()
    boolean isField()
    boolean isConstructor()
    boolean isPackage()
}

GroovyRootDoc

Root of the documentation tree, representing the entire documentation set.

public interface GroovyRootDoc extends GroovyDoc {
    GroovyClassDoc[] classes()                                              // Get all classes
    GroovyPackageDoc[] specifiedPackages()                                  // Get specified packages
    GroovyClassDoc classNamed(GroovyClassDoc groovyClassDoc, String name)   // Find class by name
    Map<String, GroovyClassDoc> getVisibleClasses(List importedClassesAndPackages) // Get visible classes
}

GroovyPackageDoc

Represents package-level documentation.

public interface GroovyPackageDoc extends GroovyDoc {
    GroovyClassDoc[] allClasses()                      // Get all classes in package
    GroovyClassDoc[] allClasses(boolean filter)       // Get classes with filtering
    GroovyClassDoc[] interfaces()                      // Get interfaces
    GroovyClassDoc[] ordinaryClasses()                 // Get regular classes
    GroovyClassDoc[] enums()                           // Get enums
    GroovyClassDoc[] errors()                          // Get errors
    GroovyClassDoc[] exceptions()                      // Get exceptions
    GroovyClassDoc findClass(String className)         // Find class by name
    String summary()                                   // Get package summary
    String description()                               // Get package description
}

GroovyClassDoc

Represents class and interface documentation.

public interface GroovyClassDoc extends GroovyProgramElementDoc {
    GroovyMethodDoc[] methods()                    // Get all methods
    GroovyMethodDoc[] methods(boolean filter)     // Get methods with filtering
    GroovyFieldDoc[] fields()                     // Get all fields
    GroovyFieldDoc[] fields(boolean filter)      // Get fields with filtering
    GroovyFieldDoc[] properties()                 // Get Groovy properties
    GroovyConstructorDoc[] constructors()         // Get constructors
    GroovyConstructorDoc[] constructors(boolean filter) // Get constructors with filtering
    GroovyClassDoc[] innerClasses()               // Get inner classes
    GroovyClassDoc[] innerClasses(boolean filter) // Get inner classes with filtering
    GroovyClassDoc superclass()                   // Get superclass
    GroovyClassDoc[] interfaces()                 // Get implemented interfaces
    
    // Class characteristics
    boolean isAbstract()
    boolean isSerializable()
    boolean isEnum()
    boolean isException()
    boolean isError()
    boolean isOrdinaryClass()
}

Program Element Base Interfaces

GroovyProgramElementDoc

Base interface for documented program elements (classes, methods, fields).

public interface GroovyProgramElementDoc extends GroovyDoc {
    GroovyAnnotationRef[] annotations()        // Get annotations
    GroovyClassDoc containingClass()           // Get containing class
    GroovyPackageDoc containingPackage()       // Get containing package
    String qualifiedName()                     // Get fully qualified name
    String modifiers()                         // Get modifier string
    
    // Visibility and modifier checks
    boolean isPublic()
    boolean isPrivate()
    boolean isProtected()
    boolean isPackagePrivate()
    boolean isStatic()
    boolean isFinal()
}

GroovyMemberDoc

Base interface for class members.

public interface GroovyMemberDoc extends GroovyProgramElementDoc {
    boolean isSynthetic()    // Check if compiler-generated
}

GroovyExecutableMemberDoc

Base interface for executable members (methods and constructors).

public interface GroovyExecutableMemberDoc extends GroovyMemberDoc {
    GroovyParameter[] parameters()       // Get parameters
    String signature()                   // Get method signature
    String flatSignature()              // Get flattened signature
    GroovyClassDoc[] thrownExceptions()  // Get thrown exceptions
    
    // Method characteristics
    boolean isNative()
    boolean isSynchronized()
    boolean isVarArgs()
}

Member Documentation Interfaces

GroovyMethodDoc

Represents method documentation.

public interface GroovyMethodDoc extends GroovyExecutableMemberDoc {
    GroovyType returnType()                      // Get return type
    boolean isAbstract()                         // Check if abstract
    GroovyClassDoc overriddenClass()             // Get overridden class
    GroovyMethodDoc overriddenMethod()           // Get overridden method
    GroovyType overriddenType()                  // Get overridden type
    boolean overrides(GroovyMethodDoc method)    // Check if overrides another method
}

GroovyConstructorDoc

Represents constructor documentation.

public interface GroovyConstructorDoc extends GroovyExecutableMemberDoc {
    // Inherits all methods from GroovyExecutableMemberDoc
    // No additional methods specific to constructors
}

GroovyFieldDoc

Represents field and property documentation.

public interface GroovyFieldDoc extends GroovyMemberDoc {
    GroovyType type()                      // Get field type
    Object constantValue()                 // Get constant value if applicable
    String constantValueExpression()       // Get constant value expression
    
    // Field characteristics
    boolean isTransient()
    boolean isVolatile() 
}

Supporting Type Interfaces

GroovyType

Represents type information for parameters, return values, and fields.

public interface GroovyType {
    String qualifiedTypeName()    // Get fully qualified type name
    String simpleTypeName()       // Get simple type name
    String typeName()             // Get type name
    boolean isPrimitive()         // Check if primitive type
}

GroovyParameter

Represents method and constructor parameters.

public interface GroovyParameter {
    String name()                         // Get parameter name
    GroovyType type()                     // Get parameter type
    String typeName()                     // Get type name
    String defaultValue()                 // Get default value if applicable
    GroovyAnnotationRef[] annotations()   // Get parameter annotations
}

GroovyAnnotationRef

Represents annotation usage on program elements.

public interface GroovyAnnotationRef {
    GroovyClassDoc type()       // Get annotation type
    String name()               // Get annotation name
    String description()        // Get annotation description
}

GroovyTag

Represents documentation tags like @param, @return, @see, etc.

public interface GroovyTag {
    String name()        // Get tag name (e.g., "param", "return")
    String param()       // Get tag parameter (for @param tags)
    String text()        // Get tag text content
}

Usage Examples

Navigating the Documentation Model

import org.codehaus.groovy.groovydoc.*;

// Get the root documentation
GroovyRootDoc rootDoc = tool.getRootDoc();

// Iterate through all packages
GroovyPackageDoc[] packages = rootDoc.specifiedPackages();
for (GroovyPackageDoc pkg : packages) {
    System.out.println("Package: " + pkg.name());
    
    // Get all classes in the package
    GroovyClassDoc[] classes = pkg.allClasses();
    for (GroovyClassDoc clazz : classes) {
        System.out.println("  Class: " + clazz.qualifiedName());
        
        // Check class characteristics
        if (clazz.isInterface()) {
            System.out.println("    Type: Interface");
        } else if (clazz.isEnum()) {
            System.out.println("    Type: Enum");
        } else {
            System.out.println("    Type: Class");
        }
        
        // Get superclass and interfaces
        GroovyClassDoc superclass = clazz.superclass();
        if (superclass != null) {
            System.out.println("    Extends: " + superclass.qualifiedName());
        }
        
        GroovyClassDoc[] interfaces = clazz.interfaces();
        for (GroovyClassDoc iface : interfaces) {
            System.out.println("    Implements: " + iface.qualifiedName());
        }
    }
}

Examining Methods and Parameters

// Get a specific class
GroovyClassDoc classDoc = rootDoc.classNamed(null, "com.example.MyClass");

// Examine all methods
GroovyMethodDoc[] methods = classDoc.methods();
for (GroovyMethodDoc method : methods) {
    System.out.println("Method: " + method.name());
    System.out.println("  Signature: " + method.signature());
    System.out.println("  Return type: " + method.returnType().typeName());
    
    // Check modifiers
    if (method.isPublic()) System.out.println("  Visibility: public");
    if (method.isStatic()) System.out.println("  Static: yes");
    if (method.isAbstract()) System.out.println("  Abstract: yes");
    
    // Examine parameters
    GroovyParameter[] params = method.parameters();
    for (GroovyParameter param : params) {
        System.out.println("  Parameter: " + param.name() + 
                         " : " + param.type().typeName());
        
        // Check for default value
        String defaultValue = param.defaultValue();
        if (defaultValue != null) {
            System.out.println("    Default: " + defaultValue);
        }
    }
    
    // Check for thrown exceptions
    GroovyClassDoc[] exceptions = method.thrownExceptions();
    for (GroovyClassDoc exception : exceptions) {
        System.out.println("  Throws: " + exception.qualifiedName());
    }
}

Working with Fields and Properties

// Examine fields
GroovyFieldDoc[] fields = classDoc.fields();
for (GroovyFieldDoc field : fields) {
    System.out.println("Field: " + field.name());
    System.out.println("  Type: " + field.type().typeName());
    System.out.println("  Modifiers: " + field.modifiers());
    
    // Check if it's a constant
    Object constantValue = field.constantValue();
    if (constantValue != null) {
        System.out.println("  Constant value: " + constantValue);
    }
}

// Examine Groovy properties (separate from fields)
GroovyFieldDoc[] properties = classDoc.properties();
for (GroovyFieldDoc property : properties) {
    System.out.println("Property: " + property.name());
    System.out.println("  Type: " + property.type().typeName());
}

Accessing Documentation Comments

// Get comment text from any documentation element
System.out.println("Class comment: " + classDoc.commentText());
System.out.println("First sentence: " + classDoc.firstSentenceCommentText());
System.out.println("Raw comment: " + classDoc.getRawCommentText());

// Method comments
for (GroovyMethodDoc method : classDoc.methods()) {
    System.out.println("Method " + method.name() + " comment: " + 
                      method.commentText());
}

Install with Tessl CLI

npx tessl i tessl/maven-org-apache-groovy--groovy-groovydoc

docs

doc-generation.md

doc-model.md

index.md

output-management.md

template-engine.md

tile.json