All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.groovy.tools.groovydoc.gstringTemplates.classLevel.classDocName.html Maven / Gradle / Ivy

There is a newer version: 3.0.21
Show newest version






<%
    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) }
    def visibleFields = classDoc.fields().findAll(isVisible)
    def visibleProperties = classDoc.properties() // props visible be defn
    def visibleMethods = classDoc.methods().findAll(isVisible)
    def visibleConstructors = classDoc.constructors().findAll(isVisible)
    def visibleNested = classDoc.innerClasses().findAll(isVisible)
    boolean hasFields = !classDoc.isAnnotationType() && visibleFields
    boolean hasProperties = !classDoc.isAnnotationType() && visibleProperties
    boolean hasElements = classDoc.isAnnotationType() && visibleFields
    boolean methodSummaryShown = visibleMethods
    boolean fieldSummaryShown = hasFields
    boolean hasEnumConstants = classDoc.enumConstants()
    def dolink = { t, boolean b ->
        boolean isArray = false
        if (!t || t instanceof String) {
            return classDoc.getDocUrl(t, b)
        }
        if (t instanceof org.codehaus.groovy.tools.groovydoc.ArrayClassDocWrapper) {
            t = t.delegate
            isArray = true
        }
        if (t instanceof org.codehaus.groovy.tools.groovydoc.SimpleGroovyClassDoc) {
            if (t.fullPathName == 'def') return classDoc.getDocUrl("java.lang.Object def", b)
            if (!t.qualifiedTypeName().contains("<") && t.name().size() > 1)
                return "" + (b ? t.qualifiedTypeName() : t.name()) + "" + (isArray ? "[]" : "")
        }
        return classDoc.getDocUrl(t.qualifiedTypeName(), b) + (isArray ? "[]" : "")
    }
    def linkfull = { t -> dolink(t, true) }
    def linkable = { t -> dolink(t, false) }
    def modifiersWithIgnore = { t, boolean ignorePublic ->
        (t.isPrivate()?"private ":"") +
        (t.isPublic() && !ignorePublic?"public ":"") +
        (t.isProtected()?"protected ":"") +
        (t.isStatic()?"static ":"") +
        (t.isFinal()?"final ":"") +
        (t.respondsTo('isAbstract') && t.isAbstract()?"abstract ":"")
    }
    def modifiers = { t -> modifiersWithIgnore(t, classDoc.isGroovy()) }
    def modifiersBrief = { t ->
        (t.isPrivate()?"private ":"") +
        (t.isProtected()?"protected ":"") +
        (t.isStatic()?"static ":"")
    }
    def annotations = { t, sepChar ->
        t.annotations() ? t.annotations().collect{it.isTypeAvailable()?'@'+linkable(it.type().name())+(it.description()-('@'+it.type().name())):it.description()}.join(sepChar) + sepChar : ''
    }
    def elementTypes = [
        "required":"true",
        "optional":"false"
    ]
    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(', ') + ')' }
    def nameFromJavaParams = { n -> n.name + '(' + n.parameterTypes.collect{ param -> param.name }.join(', ') + ')' }
%>


    
    ${title}
    <% if (props.timestamp != 'false') { %><% } %>
    
    
    
    











<% def pkg = classDoc.containingPackage().nameWithDots() String classDesc = "${classDoc.isGroovy() ? "[Groovy]" : "[Java]"} ${classDoc.typeDescription} ${org.codehaus.groovy.tools.groovydoc.SimpleGroovyClassDoc.encodeAngleBrackets(classDoc.getNameWithTypeArgs())}" if (pkg != "DefaultPackage") { %>
Package: ${pkg}
<%}%>

${classDesc}

    <% def parents = classDoc.isInterface() ? classDoc.parentInterfaces : classDoc.parentClasses if (parents.size() >= 2) { parents.eachWithIndex { p, i -> %>
  • <% if ( i == parents.size() - 1) { out << p.qualifiedTypeName() } else { %>
      <% linkfull(p) %>
  • <% } } } %>
  • <% if (classDoc.isInterface()) { Set interfaces = classDoc.parentInterfaces interfaces -= classDoc if (interfaces) { %>
    All Superinterfaces:
    ${interfaces.collect{ linkable(it) }.join(', ')}
    <% } } else { // TODO follow up the tree collecting interfaces seen? def interfaces = classDoc.interfaces() if (interfaces) { %>
    All Implemented Interfaces and Traits:
    ${interfaces.collect{ linkable(it) }.join(', ')}


    ${annotations(classDoc, '\n') + modifiers(classDoc) + classDoc.typeSourceDescription + ' ' + classDoc.name()}
    <% if (classDoc.isInterface() && classDoc.interfaces()) {
    %>extends ${classDoc.interfaces().collect{ linkable(it) }.join(', ')}
    <% } else if (classDoc.superclass()) {
    %>extends ${linkable(classDoc.superclass())}
    <% } %>
    
    <% } %> <% } %> <% if (classDoc.commentText()) { %>

    ${classDoc.commentText()}

    <% } %>
  • <% if (visibleNested) { %>
    • Nested Class Summary

        <% visibleNested.eachWithIndex { c, i -> %> <% } %>
        Nested classes 
        Modifiers Name Description
        ${modifiersBrief(c) + c.typeSourceDescription}  ${linkable(c)} ${c.firstSentenceCommentText()}
    <% } %> <% if (hasEnumConstants) { %>
    • Enum Constants Summary

        <% classDoc.enumConstants().eachWithIndex { ec, i -> %> <% } %>
        Enum constants classes 
        Enum constant Description
        ${ec.name()} ${ec.firstSentenceCommentText()}
    <% } %> <% def buffer = new StringBuilder() classes = [] if (classDoc.isInterface()) { classes.addAll(classDoc.interfaces().toList()) } else { if (classDoc.superclass()) classes += classDoc.superclass() else classes += new org.codehaus.groovy.tools.groovydoc.ExternalGroovyClassDoc(Object.class) } visited = [classDoc] as Set while (classes) { Set nextLevel = [] classes.eachWithIndex { c,i -> if (c.isInterface()) nextLevel.addAll(c.interfaces().toList()) else if (c.superclass() && c.qualifiedTypeName() != 'java.lang.Object') nextLevel += c.superclass() nextLevel -= visited visited += nextLevel def list = [] if (c instanceof org.codehaus.groovy.tools.groovydoc.SimpleGroovyClassDoc) { list = c.fields().findAll(isVisible).collect { field -> "${field.name()}" } } else { list = c.externalClass().fields.findAll{ isVisibleExt(it) }.collect { field -> // "${field.name()}" field.name } } if (list) { buffer << """ ${c.typeSourceDescription} ${linkable(c)} ${list.join(', ')} """ } } classes = nextLevel } if (hasFields || buffer.length()>0) { %>
      <% if (hasFields) { %>
    • Field Summary

        <% visibleFields.eachWithIndex { field, i -> %> <% } %>
        Fields 
        Modifiers Name Description
        ${modifiersBrief(field) + linkable(field.type())}  ${field.name()} ${field.firstSentenceCommentText()}
    • <% } // if (hasFields) if ((buffer.length())>0) { %>
      • ${buffer}
        Inherited fields 
        Fields inherited from class Fields
    • <% } // if buffer %>
    <% } // if hasFields or buffer %> <% if (hasProperties) { %>
    • Properties Summary

        <% visibleProperties.eachWithIndex { prop, i -> %> <% } %>
        Properties 
        Type Name and description
        ${modifiersBrief(prop) + linkable(prop.type())}  ${prop.name()}
        ${prop.firstSentenceCommentText()}
    <% } %> <% if (hasElements) { %>
    • Element Summary

      <% elementTypes.each { k, v -> %><% if (visibleFields.any{ isRequired(it, v) }) { %>
        <% visibleFields.findAll {isRequired(it, v)}.eachWithIndex { element, i -> %> <% } %>
        ${upcase(k)} Element Summary 
        Type Name and Description
        ${modifiersBrief(element) + linkable(element.type())}  ${element.name()}
        ${element.firstSentenceCommentText()}
      <% } } //elementTypes.each %>
    <% } %> <% if (visibleConstructors) { %>
    • Constructor Summary

        <% visibleConstructors.eachWithIndex { constructor, i -> %> <% } %>
        Constructors 
        Constructor and description
        ${modifiersBrief(constructor)}${constructor.name()} (${paramsOf(constructor, true)})
        ${constructor.firstSentenceCommentText()}
    <% } %> <% buffer = new StringBuilder() Set classes = [] if (classDoc.isInterface()) { classes.addAll(classDoc.interfaces().toList()) } else { if (classDoc.superclass()) classes += classDoc.superclass() else if (!classDoc.isTrait()) classes += new org.codehaus.groovy.tools.groovydoc.ExternalGroovyClassDoc(Object.class) } Set visited = [classDoc] as Set while (classes) { Set nextLevel = [] classes.eachWithIndex { c,i -> if (c.isInterface()) nextLevel.addAll(c.interfaces().toList()) else if (c.superclass() && c.qualifiedTypeName() != 'java.lang.Object') nextLevel += c.superclass() nextLevel -= visited visited += nextLevel def list = [] if (c instanceof org.codehaus.groovy.tools.groovydoc.SimpleGroovyClassDoc) { list = c.methods().findAll(isVisible).collect { method -> "${method.name()}" } } else { list = c.externalClass().methods.findAll{ isVisibleExt(it) }.collect { method -> linkable(c.externalClass().name + "#" + nameFromJavaParams(method) + " " + method.name) } } if (list) { buffer << """ ${c.typeSourceDescription} ${linkable(c)} ${list.join(', ')} """ } } classes = nextLevel } if (visibleMethods || buffer.length()>0) { %>
      <% if (visibleMethods) { %>
    • Methods Summary

        <% visibleMethods.eachWithIndex { method, i -> %> <% } %>
        Methods 
        Type Name and description
        ${modifiersBrief(method)}${linkable(method.returnType())} ${method.name()}(${paramsOf(method, true)})
        ${method.firstSentenceCommentText()}
    • <% } // if (visibleMethods) if (buffer.length()>0) { %>
    • Inherited Methods Summary

        ${buffer}
        Inherited Methods 
        Methods inherited from class Name
    • <% } // if buffer.length%>
    <% } %>
  • <% if (hasEnumConstants) { %>
    • Enum Constant Detail

      <% for (ec in classDoc.enumConstants()) { %> <% } %>
    <% } %> <% if (hasFields) { %>
    • Field Detail

      <% visibleFields.each { field -> %>
      • ${annotations(field, '\n') + modifiersWithIgnore(field, false) + linkable(field.type())} ${field.name()}

        ${field.commentText()}

      <% } %>
    <% } %> <% if (hasProperties) { %>
    • Property Detail

      <% visibleProperties.each { prop -> %>
      • ${annotations(prop, '\n') + modifiers(prop) + linkable(prop.type())} ${prop.name()}

        ${prop.commentText()}

      <% } %>
    <% } %> <% if (hasElements) { %>
    • Element Detail

      <% visibleFields.each { element -> %>
      • ${modifiers(element) + linkable(element.type())} ${element.name()}

        ${element.commentText()}

      <% } %>
    <% } %> <% if (visibleConstructors) { %>
    • Constructor Detail

      <% visibleConstructors.each { constructor -> %>
      • ${annotations(constructor, '\n') + modifiers(constructor)}${constructor.name()}(${paramsOf(constructor, false)})

        ${constructor.commentText()}

      <% } %>
    <% } %> <% if (visibleMethods) { %>
    • Method Detail

      <% visibleMethods.each { method -> %>
      • ${annotations(method, '\n') + modifiers(method)}${linkable(method.returnType())} ${method.name()}(${paramsOf(method, false)})

        ${method.commentText()}

      <% } %>
    <% } %>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy