Mercurial > public > gradleplugins
changeset 15:e3c55e83c9a4
USASR-1307: start custom class/property displays
author | Dave Smith <smith@nwoca.org> |
---|---|
date | Fri, 17 Jan 2014 18:16:29 +0000 |
parents | 9de72de14ab3 |
children | 8400a7db1330 |
files | src/main/groovy/org/ssdt_ohio/gradle/doc/tools/UserClassDocProxy.groovy src/main/groovy/org/ssdt_ohio/gradle/plugins/UserDocPlugin.groovy src/main/groovy/org/ssdt_ohio/gradle/tasks/UserDoc.groovy src/main/resources/org/ssdt_ohio/gradle/userdoc/templates/classDocName.html |
diffstat | 4 files changed, 51 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/groovy/org/ssdt_ohio/gradle/doc/tools/UserClassDocProxy.groovy Fri Jan 17 18:16:29 2014 +0000 @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2013. Ohio Department of Education. - All Rights Reserved. + * Unauthorized copying of this file, in any medium, is strictly prohibited. + * Written by State Software Development Team (http://ssdt.oecn.k12.oh.us/) + */ + +package org.ssdt_ohio.gradle.doc.tools + +import org.codehaus.groovy.groovydoc.GroovyFieldDoc + +class UserClassDocProxy extends groovy.util.Proxy { + + GroovyFieldDoc[] properties() { + println "getting properties for $adaptee" + getAdaptee().properties().findAll { GroovyFieldDoc p -> + !p.isTransient() + } + + } + +}
--- a/src/main/groovy/org/ssdt_ohio/gradle/plugins/UserDocPlugin.groovy Tue Dec 10 23:24:56 2013 +0000 +++ b/src/main/groovy/org/ssdt_ohio/gradle/plugins/UserDocPlugin.groovy Fri Jan 17 18:16:29 2014 +0000 @@ -27,8 +27,10 @@ private void configureUserdoc(final Project project) { UserDoc userDoc = project.getTasks().create(USERDOC_TASK_NAME, UserDoc.class); - userDoc.setDescription("Generates UserDoc API documentation for the main source code."); + userDoc.setDescription("Generates UserDoc API documentation"); userDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); + userDoc.windowTitle = project.name + userDoc.docTitle = project.name JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
--- a/src/main/groovy/org/ssdt_ohio/gradle/tasks/UserDoc.groovy Tue Dec 10 23:24:56 2013 +0000 +++ b/src/main/groovy/org/ssdt_ohio/gradle/tasks/UserDoc.groovy Fri Jan 17 18:16:29 2014 +0000 @@ -3,7 +3,6 @@ import org.codehaus.groovy.tools.groovydoc.ClasspathResourceManager import org.codehaus.groovy.tools.groovydoc.FileOutputTool import org.codehaus.groovy.tools.groovydoc.GroovyDocTool -import org.codehaus.groovy.tools.groovydoc.OutputTool import org.codehaus.groovy.tools.groovydoc.gstringTemplates.GroovyDocTemplateInfo import org.gradle.api.InvalidUserDataException import org.gradle.api.file.FileCollection @@ -30,6 +29,15 @@ classPathRegistry = getServices().get(ClassPathRegistry.class); } + String windowTitle + + String docTitle + + Boolean publicScope = true + Boolean protectedScope = false + Boolean packageScope = false + Boolean privateScope = false + @TaskAction protected void generate() { checkGroovyClasspathNonEmpty(getGroovyClasspath().getFiles()); @@ -48,15 +56,15 @@ args.destdir = destinationDir Properties properties = new Properties(); -// properties.setProperty("windowTitle", windowTitle); -// properties.setProperty("docTitle", docTitle); + 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("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()); @@ -65,7 +73,7 @@ // properties.setProperty("fileEncoding", fileEncoding != null ? fileEncoding : ""); // - def tool = new GroovyDocTool(new ClasspathResourceManager(), + def tool = new GroovyDocTool(new ClasspathResourceManager(this.getClass().getClassLoader()), [tmpDir.getPath()] as String[], getDocTemplates(), getPackageTemplates(),
--- a/src/main/resources/org/ssdt_ohio/gradle/userdoc/templates/classDocName.html Tue Dec 10 23:24:56 2013 +0000 +++ b/src/main/resources/org/ssdt_ohio/gradle/userdoc/templates/classDocName.html Fri Jan 17 18:16:29 2014 +0000 @@ -5,6 +5,10 @@ <!-- * i.e. only iterate & print data where possible. Thanks, Jez. * --> <!-- **************************************************************** --> <% + + + classDoc = new org.ssdt_ohio.gradle.doc.tools.UserClassDocProxy().wrap(classDoc) + def title = classDoc.name() + (props.docTitle ? " (${props.docTitle})" : "") def isVisible = { it.isPublic() || (it.isProtected() && props.protectedScope == 'true') || (!it.isProtected() && !it.isPrivate() && props.packageScope == 'true') || props.privateScope == 'true' } def isVisibleExt = { t -> java.lang.reflect.Modifier.isPublic(t.modifiers) || java.lang.reflect.Modifier.isProtected(t.modifiers) } @@ -22,7 +26,7 @@ def dolink = { t, boolean b -> boolean isArray = false if (!t || t instanceof String) { - return classDoc.getDocUrl(t, b) + return (classDoc.getDocUrl(t, b) -'java.util.' - 'java.lang.') } if (t instanceof org.codehaus.groovy.tools.groovydoc.ArrayClassDocWrapper) { t = t.delegate @@ -30,9 +34,9 @@ } if (t instanceof org.codehaus.groovy.tools.groovydoc.SimpleGroovyClassDoc) { if (t.fullPathName == 'def') return classDoc.getDocUrl("java.lang.Object def", b) - return "<a href='" + classDoc.relativeRootPath + t.fullPathName + ".html'>" + (b ? t.qualifiedTypeName() : t.name()) + "</a>" + (isArray ? "[]" : "") + return "<a href='" + classDoc.relativeRootPath + t.fullPathName + ".html'>" + ( (b ? t.qualifiedTypeName() : t.name() ) - "java.lang." - "java.util." ) + "</a>" + (isArray ? "[]" : "") } - return classDoc.getDocUrl(t.qualifiedTypeName(), b) + (isArray ? "[]" : "") + return ( classDoc.getDocUrl(t.qualifiedTypeName(), b) - 'java.util.' - 'java.lang.' ) + (isArray ? "[]" : "") } def linkfull = { t -> dolink(t, true) } def linkable = { t -> dolink(t, false) } @@ -52,7 +56,7 @@ } def annotations = { t, sepChar -> t.annotations() ? t.annotations().collect { - // it.isTypeAvailable() ? '@'+linkable(it.type().name())+(it.description()-('@'+it.type().name())): it.description() +// it.isTypeAvailable() ? '@'+linkable(it.type().name())+(it.description()-('@'+it.type().name())): it.description() it.description() }.join(sepChar) + sepChar : '' } @@ -60,7 +64,9 @@ "required":"true", "optional":"false" ] - def isRequired = { f, v -> def req = f.constantValueExpression() == null; req.toString() == v } + def isRequired = { f, v -> + def req = f.constantValueExpression() == null; req.toString() == v + } def upcase = { n -> n[0].toUpperCase() + n[1..-1] } def paramsOf = { n, boolean brief -> n.parameters().collect{ param -> (brief?'':annotations(param, ' ')) + linkable(param.isTypeAvailable()?param.type():param.typeName()) + (param.vararg()?'... ':' ') + param.name() + (param.defaultValue() ? " = " + param.defaultValue():"") }.join(", ") } def nameFromParams = { n -> n.name() + '(' + n.parameters().collect{ param -> param.isTypeAvailable()?param.type().qualifiedTypeName():param.typeName() }.join(', ') + ')' }