0

I have a groovy script/closure that is defined in a file named "myClosure.groovy" and the contents look like this:

# myClosure.groovy
def call(Map config) {
.....
}

I need to keep the code this way. I want to document this with groovydoc, but I'm not sure how to add a description to the class.

Using a regular class I can do this:

/**
 * My class 
 */
class myClass {

But I have no explicit class definition.

groovydoc sees it as:

class myClosure
extends groovy.lang.Script

I can add docs to the call() function but how can I write a description for the class with groovydoc too? This is not possible out of the box: https://issues.apache.org/jira/browse/GROOVY-8877

Is there some way to alter the class groovydoc template?

I'm trying to understand the custom template thing. Does it require me to override the default template and copy all of its functionality? Is there some way to just staple this on to the default class template? For example, could this be implemented as a custom tag like this?

# would put this comment at top of a groovy script file
/**
 * @override_class_description This is a class that blah
 * blah blah does xyz
 */
red888
  • 27,709
  • 55
  • 204
  • 392
  • 1
    https://stackoverflow.com/questions/33556374/is-there-a-way-to-attach-a-javadoc-doc-comment-to-a-groovy-script – daggett May 19 '22 at 06:47
  • you could create custom template and generate groovydoc using groovy-script or ant. template for class: https://github.com/apache/groovy/blob/master/subprojects/groovy-groovydoc/src/main/resources/org/codehaus/groovy/tools/groovydoc/gstringTemplates/classLevel/classDocName.html how to run it from groovy: https://github.com/apache/groovy/blob/master/subprojects/groovy-groovydoc/src/main/groovy/org/codehaus/groovy/tools/groovydoc/Main.groovy#L206 – daggett May 19 '22 at 08:46
  • @daggett See my EDIT. Is there an easy way to add functionality to the behavior of the existing templates (to add custom tags) or do you have to duplicate the whole thing? I'm going to update my title to make it specifically about this. – red888 May 19 '22 at 13:26

0 Answers0