2

I'm writing a class in Groovy, and I want to generate Groovydoc for it (from the command line). In my class, I've written documentation for the methods like this:

/**
 * Returns blah blah blah
*/
def getFoo(){
    ...
}

But when I run groovydoc -classpath C:\groovyStuff\ -d . *.groovy

It generates the HTML template, but no actual content.

What have I done wrong?

toniedzwiedz
  • 17,895
  • 9
  • 86
  • 131
Steve
  • 4,457
  • 12
  • 48
  • 89

3 Answers3

2

If the root of your source tree is c:\groovyStuff\ you can use something like this...

groovydoc -sourcepath c:\groovyStuff -d . com.somepackage

The -d . is a little peculiar because that is going to put the generated files in the current directory. That is what you used in your example but maybe you want something like -d output or something similar.

Does that help?

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47
  • sourcepath or classpath? I used http://marxsoftware.blogspot.com/2011/05/documenting-groovy-with-groovydoc.html as an example. The sample command is toward the middle of the page. I didn't get the impression the files needed to be part of a package either. – Steve Jul 08 '14 at 18:35
  • sourcepath and classpath are 2 different things. I meant sourcepath, which is what I typed. For example, if you have files like `c:\groovyStuff\com\somepackage\Demo.groovy` and `c:\groovyStuff\com\somepackage\Widget.groovy`, the command I show above will generate javadocs for those in the current directory (whatever directory you executed that command from). – Jeff Scott Brown Jul 08 '14 at 23:17
  • You may or may not need to specify a classpath. That depends on details of your code which are not represented in the question. – Jeff Scott Brown Jul 08 '14 at 23:19
  • Okay, it works with sourcepath. I had to specify the name of the class though, *.groovy did not work. Thank you for your help! groovydoc -sourcepath C:\groovyStuff -d . scriptName.groovy – Steve Jul 09 '14 at 13:56
1

For Eclipse users, here is a workaround:

  1. Go to Project -> Generate Javadoc...
  2. In Javadoc command, replace the 'javadoc.exe' path with the 'groovydoc.bat' path.
  3. Select the sources to be generated, the visibility and use the standard doclet (I suggest you create a new file src/main/groovydoc and delete src/main/javadoc)

enter image description here

Etienne Tonnelier
  • 2,119
  • 1
  • 15
  • 14
0

If you application consists of Java & Groovy files you can leverage next bash script which lists all java & groovy files in the source directory (even skipping undesired ones)

source_files=`find {path-to-your-dir}/ -type f \( \
    \( \
    -name "*.java" \
    -or -name "*.groovy" \
    \) \
    ! \
    \( \
     -name "UndesiredOne.java" \
     -or -name "UndesiredTwo.groovy" \
    \) \
    \)`

groovydoc -verbose --debug -public\
 -d {path-to-your-doc-dir}\
 -doctitle "Title"\
 -header "Header"\
 -footer "Footer"\
 -windowtitle "WindowTitle"\
 $source_files