Index: main/org/codehaus/groovy/ant/Groovydoc.java =================================================================== --- main/org/codehaus/groovy/ant/Groovydoc.java (revision 13946) +++ main/org/codehaus/groovy/ant/Groovydoc.java (working copy) @@ -255,7 +255,7 @@ GroovyDocTool htmlTool = new GroovyDocTool( new ClasspathResourceManager(), // we're gonna get the default templates out of the dist jar file - sourcePath.toString(), // sourcepath - TODO multiple paths need to be handled here + sourcePath, // sourcepath - TODO multiple paths need to be handled here Should Work Now new String[] { // top level templates "org/codehaus/groovy/tools/groovydoc/gstring-templates/top-level/index.html", "org/codehaus/groovy/tools/groovydoc/gstring-templates/top-level/overview-frame.html", // needs all package names @@ -274,11 +274,7 @@ ); try { - Iterator itr = sourceFilesToDoc.iterator(); - while (itr.hasNext()) { - htmlTool.add((String) itr.next()); - } - + htmlTool.add(sourceFilesToDoc); FileOutputTool output = new FileOutputTool(); htmlTool.renderToOutput(output, destDir.getCanonicalPath()); // TODO push destDir through APIs? } catch (Exception e) { Index: main/org/codehaus/groovy/tools/groovydoc/GroovyDocTool.java =================================================================== --- main/org/codehaus/groovy/tools/groovydoc/GroovyDocTool.java (revision 13946) +++ main/org/codehaus/groovy/tools/groovydoc/GroovyDocTool.java (working copy) @@ -15,6 +15,7 @@ */ package org.codehaus.groovy.tools.groovydoc; +import org.apache.tools.ant.types.Path; import antlr.RecognitionException; import antlr.TokenStreamException; import org.codehaus.groovy.groovydoc.GroovyRootDoc; @@ -30,15 +31,15 @@ * Constructor for use by people who only want to interact with the Groovy Doclet Tree (rootDoc) * @param sourcepath where the sources to be added can be found */ - public GroovyDocTool(String sourcepath) { + public GroovyDocTool(Path sourcepath) { this(null,sourcepath,null); } - public GroovyDocTool(ResourceManager resourceManager, String sourcepath, String classTemplate) { + public GroovyDocTool(ResourceManager resourceManager, Path sourcepath, String classTemplate) { this(resourceManager, sourcepath, new String[]{}, new String[]{}, new String[] {classTemplate}, new ArrayList()); } - public GroovyDocTool(ResourceManager resourceManager, String sourcepath, String[] docTemplates, String[] packageTemplates, String[] classTemplates, List links) { + public GroovyDocTool(ResourceManager resourceManager, Path sourcepath, String[] docTemplates, String[] packageTemplates, String[] classTemplates, List links) { rootDocBuilder = new GroovyRootDocBuilder(this, sourcepath, links); if (resourceManager == null) { templateEngine = null; @@ -47,12 +48,12 @@ } } - public void add(String filename) throws RecognitionException, TokenStreamException, IOException { + public void add(List filenames) throws RecognitionException, TokenStreamException, IOException { if (templateEngine != null) { // only print out if we are being used for template generation - System.out.println("Loading source files for " + filename); + System.out.println("Loading source files for " + filenames); } - rootDocBuilder.buildTree(filename); + rootDocBuilder.buildTree(filenames); } public GroovyRootDoc getRootDoc() { Index: main/org/codehaus/groovy/tools/groovydoc/GroovyRootDocBuilder.java =================================================================== --- main/org/codehaus/groovy/tools/groovydoc/GroovyRootDocBuilder.java (revision 13946) +++ main/org/codehaus/groovy/tools/groovydoc/GroovyRootDocBuilder.java (working copy) @@ -20,7 +20,10 @@ import java.io.StringReader; import java.util.Map; import java.util.List; +import java.util.Iterator; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.resources.FileResource; import org.codehaus.groovy.antlr.AntlrASTProcessor; import org.codehaus.groovy.antlr.SourceBuffer; import org.codehaus.groovy.antlr.UnicodeEscapingReader; @@ -51,12 +54,12 @@ */ public class GroovyRootDocBuilder { private final GroovyDocTool tool; - private final String sourcepath; + private final Path sourcepath; private final SimpleGroovyRootDoc rootDoc; private static final char FS = '/'; private List links; - public GroovyRootDocBuilder(GroovyDocTool tool, String sourcepath, List links) { + public GroovyRootDocBuilder(GroovyDocTool tool, Path sourcepath, List links) { this.tool = tool; this.sourcepath = sourcepath; this.links = links; @@ -143,28 +146,39 @@ return parser; } - public void buildTree(String filename) throws IOException, RecognitionException, TokenStreamException { - String srcFileName = sourcepath + FS + filename; - String src = DefaultGroovyMethods.getText(new File(srcFileName)); - - String packagePath = tool.getPath(filename); - packagePath = packagePath.replace('\\', FS); - String file = tool.getFile(filename); - try { - Map classDocs = getClassDocsFromSingleSource(packagePath, file, src); - - rootDoc.putAllClasses(classDocs); - - SimpleGroovyPackageDoc packageDoc = (SimpleGroovyPackageDoc) rootDoc.packageNamed(packagePath); - if (packageDoc == null) { - packageDoc = new SimpleGroovyPackageDoc(packagePath); + public void buildTree(List filenames) throws IOException, RecognitionException, TokenStreamException { + Iterator fileItr = filenames.iterator(); + while (fileItr.hasNext()) { + String filename = (String) fileItr.next(); + Iterator pathItr = sourcepath.iterator(); + while (pathItr.hasNext()){ + FileResource fileRes = (FileResource) pathItr.next(); + String path = fileRes.getFile().getAbsolutePath(); + if(new File(path + FS + filename).exists()){ + String srcFileName = path + FS + filename; + String src = DefaultGroovyMethods.getText(new File(srcFileName)); + + String packagePath = tool.getPath(filename); + packagePath = packagePath.replace('\\', FS); + String file = tool.getFile(filename); + try { + Map classDocs = getClassDocsFromSingleSource(packagePath, file, src); + + rootDoc.putAllClasses(classDocs); + + SimpleGroovyPackageDoc packageDoc = (SimpleGroovyPackageDoc) rootDoc.packageNamed(packagePath); + if (packageDoc == null) { + packageDoc = new SimpleGroovyPackageDoc(packagePath); + } + packageDoc.putAll(classDocs); + rootDoc.put(packagePath, packageDoc); + } catch (RecognitionException e) { + System.out.println("ignored due to RecognitionException: " + filename); + } catch (TokenStreamException e) { + System.out.println("ignored due to TokenStreamException: " + filename); + } + } } - packageDoc.putAll(classDocs); - rootDoc.put(packagePath, packageDoc); - } catch (RecognitionException e) { - System.out.println("ignored due to RecognitionException: " + filename); - } catch (TokenStreamException e) { - System.out.println("ignored due to TokenStreamException: " + filename); } } Index: test/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java =================================================================== --- test/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java (revision 13946) +++ test/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java (working copy) @@ -18,9 +18,12 @@ package org.codehaus.groovy.tools.groovydoc; import groovy.util.GroovyTestCase; +import java.util.List; import org.codehaus.groovy.groovydoc.GroovyClassDoc; import org.codehaus.groovy.groovydoc.GroovyMethodDoc; import org.codehaus.groovy.groovydoc.GroovyRootDoc; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.Project; import java.util.ArrayList; @@ -32,11 +35,11 @@ private static final String TEMPLATES_DIR = "main/org/codehaus/groovy/tools/groovydoc/gstring-templates"; public void setUp() { - plainTool = new GroovyDocTool("src/test"); + plainTool = new GroovyDocTool(new Path(new Project(), "src/test")); xmlTool = new GroovyDocTool( new FileSystemResourceManager("src"), // template storage - "src/main", // source file dirs + new Path(new Project(), "src/main"), // source file dirs new String[]{TEMPLATES_DIR + "/top-level/rootDocStructuredData.xml"}, new String[]{TEMPLATES_DIR + "/package-level/packageDocStructuredData.xml"}, new String[]{TEMPLATES_DIR + "/class-level/classDocStructuredData.xml"}, @@ -45,7 +48,7 @@ xmlToolForTests = new GroovyDocTool( new FileSystemResourceManager("src"), // template storage - "src/test", // source file dirs + new Path(new Project(), "src/main"), // source file dirs new String[]{TEMPLATES_DIR + "/top-level/rootDocStructuredData.xml"}, new String[]{TEMPLATES_DIR + "/package-level/packageDocStructuredData.xml"}, new String[]{TEMPLATES_DIR + "/class-level/classDocStructuredData.xml"}, @@ -54,7 +57,9 @@ } public void testPlainGroovyDocTool() throws Exception { - plainTool.add("org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java"); + List srcList = new ArrayList(); + srcList.add("org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java"); + plainTool.add(srcList); GroovyRootDoc root = plainTool.getRootDoc(); // loop through classes in tree @@ -80,12 +85,14 @@ } public void testGroovyDocTheCategoryMethodClass() throws Exception { - xmlTool.add("groovy/util/CliBuilder.groovy"); - xmlTool.add("groovy/lang/GroovyLogTestCase.groovy"); - xmlTool.add("groovy/mock/interceptor/StrictExpectation.groovy"); - xmlTool.add("groovy/ui/Console.groovy"); - xmlTool.add("org/codehaus/groovy/runtime/GroovyCategorySupport.java"); - xmlTool.add("org/codehaus/groovy/runtime/ConvertedMap.java"); + List srcList = new ArrayList(); + srcList.add("groovy/util/CliBuilder.groovy"); + srcList.add("groovy/lang/GroovyLogTestCase.groovy"); + srcList.add("groovy/mock/interceptor/StrictExpectation.groovy"); + srcList.add("groovy/ui/Console.groovy"); + srcList.add("org/codehaus/groovy/runtime/GroovyCategorySupport.java"); + srcList.add("org/codehaus/groovy/runtime/ConvertedMap.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); @@ -102,7 +109,9 @@ } public void testConstructors() throws Exception { - xmlTool.add("groovy/ui/Console.groovy"); + List srcList = new ArrayList(); + srcList.add("groovy/ui/Console.groovy"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); @@ -112,7 +121,9 @@ } public void testClassComment() throws Exception { - xmlTool.add("groovy/xml/DOMBuilder.java"); + List srcList = new ArrayList(); + srcList.add("groovy/xml/DOMBuilder.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); @@ -121,7 +132,9 @@ } public void testMethodComment() throws Exception { - xmlTool.add("groovy/model/DefaultTableColumn.java"); + List srcList = new ArrayList(); + srcList.add("groovy/model/DefaultTableColumn.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); @@ -130,7 +143,9 @@ assertTrue(defTabColDoc.indexOf("Evaluates the value of a cell") > 0); } public void testPackageName() throws Exception { - xmlTool.add("groovy/xml/DOMBuilder.java"); + List srcList = new ArrayList(); + srcList.add("groovy/xml/DOMBuilder.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); @@ -139,7 +154,9 @@ } public void testExtendsClauseWithoutSuperClassInTree() throws Exception { - xmlTool.add("groovy/xml/DOMBuilder.java"); + List srcList = new ArrayList(); + srcList.add("groovy/xml/DOMBuilder.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); @@ -148,8 +165,10 @@ } public void testExtendsClauseWithSuperClassInTree() throws Exception { - xmlTool.add("groovy/xml/DOMBuilder.java"); - xmlTool.add("groovy/util/BuilderSupport.java"); + List srcList = new ArrayList(); + srcList.add("groovy/xml/DOMBuilder.java"); + srcList.add("groovy/util/BuilderSupport.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); @@ -158,7 +177,9 @@ } public void testDefaultPackage() throws Exception { - xmlToolForTests.add("UberTestCaseBugs.java"); + List srcList = new ArrayList(); + srcList.add("UberTestCaseBugs.java"); + xmlToolForTests.add(srcList); MockOutputTool output = new MockOutputTool(); xmlToolForTests.renderToOutput(output, MOCK_DIR); String domBuilderDoc = output.getText(MOCK_DIR + "/DefaultPackage/UberTestCaseBugs.html"); @@ -166,21 +187,27 @@ } public void testStaticModifier() throws Exception { - xmlTool.add("groovy/swing/binding/AbstractButtonProperties.java"); + List srcList = new ArrayList(); + srcList.add("groovy/swing/binding/AbstractButtonProperties.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); String abstractButtonPropertiesDoc = output.getText(MOCK_DIR + "/groovy/swing/binding/AbstractButtonProperties.html"); assertTrue(abstractButtonPropertiesDoc.indexOf("static") > 0); } public void testAnonymousInnerClassMethodsNotIncluded() throws Exception { - xmlTool.add("groovy/swing/binding/AbstractButtonProperties.java"); + List srcList = new ArrayList(); + srcList.add("groovy/swing/binding/AbstractButtonProperties.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); String abstractButtonPropertiesDoc = output.getText(MOCK_DIR + "/groovy/swing/binding/AbstractButtonProperties.html"); assertTrue(abstractButtonPropertiesDoc.indexOf("createBinding") < 0); } public void testMultipleConstructorError() throws Exception { - xmlTool.add("groovy/sql/Sql.java"); + List srcList = new ArrayList(); + srcList.add("groovy/sql/Sql.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); String sqlDoc = output.getText(MOCK_DIR + "/groovy/sql/Sql.html"); @@ -188,16 +215,20 @@ } public void testReturnTypeResolution() throws Exception { - xmlTool.add("org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java"); - xmlTool.add("org/codehaus/groovy/groovydoc/GroovyClassDoc.java"); + List srcList = new ArrayList(); + srcList.add("org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java"); + srcList.add("org/codehaus/groovy/groovydoc/GroovyClassDoc.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); String text = output.getText(MOCK_DIR + "/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.html"); assertTrue(text.indexOf("org.codehaus.groovy.groovydoc.GroovyClassDoc") > 0); } public void testParameterTypeResolution() throws Exception { - xmlTool.add("org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java"); - xmlTool.add("org/codehaus/groovy/groovydoc/GroovyPackageDoc.java"); + List srcList = new ArrayList(); + srcList.add("org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java"); + srcList.add("org/codehaus/groovy/groovydoc/GroovyPackageDoc.java"); + xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); String text = output.getText(MOCK_DIR + "/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.html");