Search in sources :

Example 1 with GroovyDocTool

use of org.codehaus.groovy.tools.groovydoc.GroovyDocTool in project groovy by apache.

the class Groovydoc method execute.

public void execute() throws BuildException {
    List<String> packagesToDoc = new ArrayList<String>();
    Path sourceDirs = new Path(getProject());
    Properties properties = new Properties();
    properties.setProperty("windowTitle", windowTitle);
    properties.setProperty("docTitle", docTitle);
    properties.setProperty("footer", footer);
    properties.setProperty("header", header);
    checkScopeProperties(properties);
    properties.setProperty("publicScope", publicScope.toString());
    properties.setProperty("protectedScope", protectedScope.toString());
    properties.setProperty("packageScope", packageScope.toString());
    properties.setProperty("privateScope", privateScope.toString());
    properties.setProperty("author", author.toString());
    properties.setProperty("processScripts", processScripts.toString());
    properties.setProperty("includeMainForScripts", includeMainForScripts.toString());
    properties.setProperty("overviewFile", overviewFile != null ? overviewFile.getAbsolutePath() : "");
    properties.setProperty("charset", charset != null ? charset : "");
    properties.setProperty("fileEncoding", fileEncoding != null ? fileEncoding : "");
    properties.setProperty("timestamp", Boolean.valueOf(!noTimestamp).toString());
    properties.setProperty("versionStamp", Boolean.valueOf(!noVersionStamp).toString());
    if (sourcePath != null) {
        sourceDirs.addExisting(sourcePath);
    }
    parsePackages(packagesToDoc, sourceDirs);
    GroovyDocTool htmlTool = new GroovyDocTool(// we're gonna get the default templates out of the dist jar file
    new ClasspathResourceManager(), sourcePath.list(), getDocTemplates(), getPackageTemplates(), getClassTemplates(), links, properties);
    try {
        htmlTool.add(sourceFilesToDoc);
        FileOutputTool output = new FileOutputTool();
        // TODO push destDir through APIs?
        htmlTool.renderToOutput(output, destDir.getCanonicalPath());
    } catch (Exception e) {
        e.printStackTrace();
    }
    // try to override the default stylesheet with custom specified one if needed
    if (styleSheetFile != null) {
        try {
            String css = ResourceGroovyMethods.getText(styleSheetFile);
            File outfile = new File(destDir, "stylesheet.css");
            ResourceGroovyMethods.setText(outfile, css);
        } catch (IOException e) {
            System.out.println("Warning: Unable to copy specified stylesheet '" + styleSheetFile.getAbsolutePath() + "'. Using default stylesheet instead. Due to: " + e.getMessage());
        }
    }
}
Also used : Path(org.apache.tools.ant.types.Path) FileOutputTool(org.codehaus.groovy.tools.groovydoc.FileOutputTool) ClasspathResourceManager(org.codehaus.groovy.tools.groovydoc.ClasspathResourceManager) GroovyDocTool(org.codehaus.groovy.tools.groovydoc.GroovyDocTool) IOException(java.io.IOException) File(java.io.File) BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException)

Example 2 with GroovyDocTool

use of org.codehaus.groovy.tools.groovydoc.GroovyDocTool in project groovy-core by groovy.

the class Groovydoc method execute.

public void execute() throws BuildException {
    List<String> packagesToDoc = new ArrayList<String>();
    Path sourceDirs = new Path(getProject());
    Properties properties = new Properties();
    properties.setProperty("windowTitle", windowTitle);
    properties.setProperty("docTitle", docTitle);
    properties.setProperty("footer", footer);
    properties.setProperty("header", header);
    checkScopeProperties(properties);
    properties.setProperty("publicScope", publicScope.toString());
    properties.setProperty("protectedScope", protectedScope.toString());
    properties.setProperty("packageScope", packageScope.toString());
    properties.setProperty("privateScope", privateScope.toString());
    properties.setProperty("author", author.toString());
    properties.setProperty("processScripts", processScripts.toString());
    properties.setProperty("includeMainForScripts", includeMainForScripts.toString());
    properties.setProperty("overviewFile", overviewFile != null ? overviewFile.getAbsolutePath() : "");
    properties.setProperty("charset", charset != null ? charset : "");
    properties.setProperty("fileEncoding", fileEncoding != null ? fileEncoding : "");
    if (sourcePath != null) {
        sourceDirs.addExisting(sourcePath);
    }
    parsePackages(packagesToDoc, sourceDirs);
    GroovyDocTool htmlTool = new GroovyDocTool(// we're gonna get the default templates out of the dist jar file
    new ClasspathResourceManager(), sourcePath.list(), getDocTemplates(), getPackageTemplates(), getClassTemplates(), links, properties);
    try {
        htmlTool.add(sourceFilesToDoc);
        FileOutputTool output = new FileOutputTool();
        // TODO push destDir through APIs?
        htmlTool.renderToOutput(output, destDir.getCanonicalPath());
    } catch (Exception e) {
        e.printStackTrace();
    }
    // try to override the default stylesheet with custom specified one if needed
    if (styleSheetFile != null) {
        try {
            String css = ResourceGroovyMethods.getText(styleSheetFile);
            File outfile = new File(destDir, "stylesheet.css");
            ResourceGroovyMethods.setText(outfile, css);
        } catch (IOException e) {
            System.out.println("Warning: Unable to copy specified stylesheet '" + styleSheetFile.getAbsolutePath() + "'. Using default stylesheet instead. Due to: " + e.getMessage());
        }
    }
}
Also used : Path(org.apache.tools.ant.types.Path) FileOutputTool(org.codehaus.groovy.tools.groovydoc.FileOutputTool) ClasspathResourceManager(org.codehaus.groovy.tools.groovydoc.ClasspathResourceManager) GroovyDocTool(org.codehaus.groovy.tools.groovydoc.GroovyDocTool) IOException(java.io.IOException) File(java.io.File) BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 BuildException (org.apache.tools.ant.BuildException)2 Path (org.apache.tools.ant.types.Path)2 ClasspathResourceManager (org.codehaus.groovy.tools.groovydoc.ClasspathResourceManager)2 FileOutputTool (org.codehaus.groovy.tools.groovydoc.FileOutputTool)2 GroovyDocTool (org.codehaus.groovy.tools.groovydoc.GroovyDocTool)2