GroovyDocTool htmlTool = new GroovyDocTool( new ClasspathResourceManager(), // we're gonna get the default templates out of the dist jar file sourcePath.list(), htmlTool.add(sourceFilesToDoc); FileOutputTool output = new FileOutputTool(); htmlTool.renderToOutput(output, destDir.getCanonicalPath()); // TODO push destDir through APIs? } catch (Exception e) { e.printStackTrace();
public void testDefaultPackage() throws Exception { List<String> srcList = new ArrayList<String>(); srcList.add("DefaultPackageClassSupport.java"); xmlToolForTests.add(srcList); MockOutputTool output = new MockOutputTool(); xmlToolForTests.renderToOutput(output, MOCK_DIR); String doc = output.getText(MOCK_DIR + "/DefaultPackage/DefaultPackageClassSupport.html"); assertTrue(doc.indexOf("<extends>GroovyTestCase</extends>") > 0); }
private void processFile(String filename, File srcFile, boolean isAbsolute) throws IOException { String src = ResourceGroovyMethods.getText(srcFile); String relPackage = tool.getPath(filename).replace('\\', FS); String packagePath = isAbsolute ? "DefaultPackage" : relPackage; String file = tool.getFile(filename); SimpleGroovyPackageDoc packageDoc = null; if (!isAbsolute) {
GroovyDocTool htmlTool = new GroovyDocTool( new ClasspathResourceManager(), // we're gonna get the default templates out of the dist jar file htmlTool.add(sourceFilesToDoc); FileOutputTool output = new FileOutputTool(); htmlTool.renderToOutput(output, destDir.getCanonicalPath()); // TODO push destDir through APIs? } catch (Exception e) { e.printStackTrace();
public void writePackageToOutput(GroovyPackageDoc packageDoc, String destdir) throws Exception { Iterator<String> templates = templateEngine.packageTemplatesIterator(); while (templates.hasNext()) { String template = templates.next(); String renderedSrc = templateEngine.applyPackageTemplate(template, packageDoc); String destFileName = destdir + FS + packageDoc.name() + FS + tool.getFile(template); log.debug("Generating " + destFileName); output.writeToOutput(destFileName, renderedSrc, properties.getProperty("fileEncoding")); } }
public void testFileEncodingCharsetFallbackToDefaultCharset() throws Exception { String expectedCharset = Charset.defaultCharset().name(); GroovyDocTool tool = new GroovyDocTool( new FileSystemResourceManager("src"), new String[0], new String[0], new String[0], new String[0], new ArrayList<LinkArgument>(), new Properties()); assertEquals("'charset' falls back to the default charset", expectedCharset, tool.properties.getProperty("charset")); assertEquals("'fileEncoding' falls back to the default charset", expectedCharset, tool.properties.getProperty("fileEncoding")); }
public void testPlainGroovyDocTool() throws Exception { List<String> srcList = new ArrayList<String>(); srcList.add("org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java"); plainTool.add(srcList); GroovyRootDoc root = plainTool.getRootDoc(); // loop through classes in tree GroovyClassDoc[] classDocs = root.classes(); for (int i = 0; i < classDocs.length; i++) { GroovyClassDoc clazz = root.classes()[i]; assertEquals("GroovyDocToolTest", clazz.name()); // loop through methods in class boolean seenThisMethod = false; GroovyMethodDoc[] methodDocs = clazz.methods(); for (int j = 0; j < methodDocs.length; j++) { GroovyMethodDoc method = clazz.methods()[j]; if ("testPlainGroovyDocTool".equals(method.name())) { seenThisMethod = true; break; } } assertTrue(seenThisMethod); } }
GroovyDocTool htmlTool = new GroovyDocTool( new ClasspathResourceManager(), // we're gonna get the default templates out of the dist jar file sourcePath.list(), htmlTool.add(sourceFilesToDoc); FileOutputTool output = new FileOutputTool(); htmlTool.renderToOutput(output, destDir.getCanonicalPath()); // TODO push destDir through APIs? } catch (Exception e) { e.printStackTrace();
public void writeRootDocToOutput(GroovyRootDoc rootDoc, String destdir) throws Exception { Iterator<String> templates = templateEngine.docTemplatesIterator(); while (templates.hasNext()) { String template = templates.next(); String destFileName = destdir + FS + tool.getFile(template); log.debug("Generating " + destFileName); if (hasBinaryExtension(template)) { templateEngine.copyBinaryResource(template, destFileName); } else { String renderedSrc = templateEngine.applyRootDocTemplate(template, rootDoc); output.writeToOutput(destFileName, renderedSrc, properties.getProperty("fileEncoding")); } } }
public void testCharsetFallbackToFileEncoding() throws Exception { String expectedCharset = "ISO-88591"; Properties props = new Properties(); props.setProperty("fileEncoding", expectedCharset); GroovyDocTool tool = new GroovyDocTool( new FileSystemResourceManager("src"), new String[0], new String[0], new String[0], new String[0], new ArrayList<LinkArgument>(), props); assertEquals("'charset' falls back to 'fileEncoding' if not provided", expectedCharset, tool.properties.getProperty("charset")); }
public void testWrongPackageNameInClassHierarchyWithPlainTool() throws Exception { List<String> srcList = new ArrayList<String>(); String fullPathBaseA = "org/codehaus/groovy/tools/groovydoc/testfiles/a/Base"; srcList.add(fullPathBaseA + ".groovy"); String fullPathBaseB = "org/codehaus/groovy/tools/groovydoc/testfiles/b/Base"; srcList.add(fullPathBaseB + ".groovy"); String fullPathBaseC = "org/codehaus/groovy/tools/groovydoc/testfiles/c/Base"; srcList.add("org/codehaus/groovy/tools/groovydoc/testfiles/a/DescendantA.groovy"); srcList.add("org/codehaus/groovy/tools/groovydoc/testfiles/b/DescendantB.groovy"); srcList.add("org/codehaus/groovy/tools/groovydoc/testfiles/a/DescendantC.groovy"); srcList.add("org/codehaus/groovy/tools/groovydoc/testfiles/a/DescendantD.groovy"); srcList.add("org/codehaus/groovy/tools/groovydoc/testfiles/c/DescendantE.groovy"); srcList.add("org/codehaus/groovy/tools/groovydoc/testfiles/c/DescendantF.groovy"); plainTool.add(srcList); GroovyRootDoc root = plainTool.getRootDoc(); // loop through classes in tree GroovyClassDoc classDocDescendantA = getGroovyClassDocByName(root, "DescendantA"); assertTrue(fullPathBaseA.equals(root.classNamed(classDocDescendantA, "Base").getFullPathName())); GroovyClassDoc classDocDescendantB = getGroovyClassDocByName(root, "DescendantB"); assertTrue(fullPathBaseB.equals(root.classNamed(classDocDescendantB, "Base").getFullPathName())); GroovyClassDoc classDocDescendantC = getGroovyClassDocByName(root, "DescendantC"); assertTrue(fullPathBaseA.equals(root.classNamed(classDocDescendantC, "Base").getFullPathName())); GroovyClassDoc classDocDescendantD = getGroovyClassDocByName(root, "DescendantD"); assertTrue(fullPathBaseA.equals(root.classNamed(classDocDescendantD, "Base").getFullPathName())); GroovyClassDoc classDocDescendantE = getGroovyClassDocByName(root, "DescendantE"); assertTrue(fullPathBaseC.equals(root.classNamed(classDocDescendantE, "Base").getFullPathName())); GroovyClassDoc classDocDescendantF = getGroovyClassDocByName(root, "DescendantF"); assertTrue(fullPathBaseC.equals(root.classNamed(classDocDescendantF, "Base").getFullPathName())); }
public void testMultipleConstructorErrorBug() throws Exception { List<String> srcList = new ArrayList<String>(); srcList.add("org/codehaus/groovy/tools/groovydoc/testfiles/MultipleConstructorErrorBug.java"); xmlTool.add(srcList); MockOutputTool output = new MockOutputTool(); xmlTool.renderToOutput(output, MOCK_DIR); String sqlDoc = output.getText(MOCK_DIR + "/org/codehaus/groovy/tools/groovydoc/testfiles/MultipleConstructorErrorBug.html"); System.out.println(sqlDoc); // VARBINARY() and other methods were assumed to be Constructors, make sure they aren't anymore... assertTrue(sqlDoc.indexOf("<method modifiers=\"public static \" returns=\"java.lang.String\" name=\"VARBINARY\">") > 0); }
GroovyDocTool htmlTool = new GroovyDocTool( new ClasspathResourceManager(), // we're gonna get the default templates out of the dist jar file htmlTool.add(sourceFilesToDoc); FileOutputTool output = new FileOutputTool(); htmlTool.renderToOutput(output, destDir.getCanonicalPath()); // TODO push destDir through APIs? } catch (Exception e) { e.printStackTrace();
public void writeRootDocToOutput(GroovyRootDoc rootDoc, String destdir) throws Exception { Iterator templates = templateEngine.docTemplatesIterator(); while (templates.hasNext()) { String template = (String) templates.next(); String renderedSrc = templateEngine.applyRootDocTemplate(template, rootDoc); // todo String destFileName = destdir + FS + tool.getFile(template); System.out.println("Generating " + destFileName); output.writeToOutput(destFileName, renderedSrc); } }
public void testFileEncodingFallbackToCharset() throws Exception { String expectedCharset = "ISO-88591"; Properties props = new Properties(); props.setProperty("charset", expectedCharset); GroovyDocTool tool = new GroovyDocTool( new FileSystemResourceManager("src"), new String[0], new String[0], new String[0], new String[0], new ArrayList<LinkArgument>(), props); assertEquals("'fileEncoding' falls back to 'charset' if not provided", expectedCharset, tool.properties.getProperty("fileEncoding")); }
public void testReturnTypeResolution() throws Exception { List<String> srcList = new ArrayList<String>(); 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); }
GroovyDocTool htmlTool = new GroovyDocTool( new ClasspathResourceManager(), // we're gonna get the default templates out of the dist jar file htmlTool.add(sourceFilesToDoc); FileOutputTool output = new FileOutputTool(); htmlTool.renderToOutput(output, destDir.getCanonicalPath()); // TODO push destDir through APIs? } catch (Exception e) { e.printStackTrace();
private void processFile(String filename, File srcFile) throws IOException { String src = DefaultGroovyMethods.getText(srcFile); String packagePath = tool.getPath(filename).replace('\\', FS); String file = tool.getFile(filename); SimpleGroovyPackageDoc packageDoc = (SimpleGroovyPackageDoc) rootDoc.packageNamed(packagePath); if (packageDoc == null) { packageDoc = new SimpleGroovyPackageDoc(packagePath); } if (filename.endsWith("package.html") || filename.endsWith("package-info.java") || filename.endsWith("package-info.groovy")) { processPackageInfo(src, filename, packageDoc); rootDoc.put(packagePath, packageDoc); return; } try { Map<String, GroovyClassDoc> classDocs = getClassDocsFromSingleSource(packagePath, file, src); rootDoc.putAllClasses(classDocs); packageDoc.putAll(classDocs); rootDoc.put(packagePath, packageDoc); } catch (RecognitionException e) { System.err.println("ignored due to RecognitionException: " + filename + " [" + e.getMessage() + "]"); } catch (TokenStreamException e) { System.err.println("ignored due to TokenStreamException: " + filename + " [" + e.getMessage() + "]"); } }
public void writePackageToOutput(GroovyPackageDoc packageDoc, String destdir) throws Exception { Iterator templates = templateEngine.packageTemplatesIterator(); while (templates.hasNext()) { String template = (String) templates.next(); String renderedSrc = templateEngine.applyPackageTemplate(template, packageDoc); // todo String destFileName = destdir + FS + packageDoc.name() + FS + tool.getFile(template); System.out.println("Generating " + destFileName); output.writeToOutput(destFileName, renderedSrc); } }