org.codehaus.groovy.tools.groovydoc.gstring-templates.class-level.classDocName.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of groovy-all Show documentation
Show all versions of groovy-all Show documentation
Groovy: A powerful, dynamic language for the JVM
<%
def title = classDoc.name() + (props.docTitle ? " (${props.docTitle})" : "")
def visibleFields = classDoc.fields().findAll{ !it.isPrivate() || props.privateScope }
def visibleProperties = classDoc.properties().findAll{ !it.isPrivate() || props.privateScope }
boolean hasFields = !classDoc.isAnnotationType() && visibleFields.size() > 0
boolean hasProperties = !classDoc.isAnnotationType() && visibleProperties.size() > 0
boolean hasElements = classDoc.isAnnotationType() && visibleFields.size() > 0
boolean hasConstructors = classDoc.constructors().size() > 0
boolean hasNested = classDoc.innerClasses().size() > 0
def visibleMethods = classDoc.methods().findAll{ !it.isPrivate() || props.privateScope }
boolean hasMethods = visibleMethods.size() > 0
boolean methodSummaryShown = hasMethods
boolean fieldSummaryShown = hasFields
boolean hasEnumConstants = classDoc.enumConstants().size() > 0
def dolink = { t, boolean b ->
if (!t || t instanceof String) {
return classDoc.getDocUrl(t, b)
}
if (t instanceof org.codehaus.groovy.tools.groovydoc.SimpleGroovyClassDoc) {
return "" + (b ? t.qualifiedTypeName() : t.name()) + ""
}
return classDoc.getDocUrl(t.qualifiedTypeName(), b)
}
def linkfull = { t -> dolink(t, true) }
def linkable = { t -> dolink(t, false) }
def modifiers = { t ->
(t.isPrivate()?"private ":"") +
(t.isPublic()?"public ":"") +
(t.isProtected()?"protected ":"") +
(t.isStatic()?"static ":"") +
(t.isFinal()?"final ":"") +
(t.respondsTo('isAbstract') && t.isAbstract()?"abstract ":"")
}
def modifiersBrief = { t ->
(t.isPrivate()?"private ":"") +
(t.isProtected()?"protected ":"") +
(t.isStatic()?"static ":"")
}
def annotations = { t, sepChar -> t.annotations() ? t.annotations()*.description().join(sepChar) + sepChar : '' }
def isVisible = { t -> java.lang.reflect.Modifier.isPublic(t.modifiers) || java.lang.reflect.Modifier.isProtected(t.modifiers) }
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.name() + (param.defaultValue() ? " = " + param.defaultValue():"") }.join(", ") }
def nameFromParams = { n -> n.name() + '(' + n.parameters().collect{ param -> param.isTypeAvailable()?param.type().qualifiedTypeName():param.typeName() }.join(', ') + ')' }
%>
${title}
Overview
Package
Class
Deprecated
Index
Help
<% if (props.header) { %>${props.header}<% } %>
FRAMES
NO FRAMES
SUMMARY: <%
if (classDoc.isAnnotationType()) {
def hasReq = classDoc.fields().any{ isRequired(it, "true") }
def hasOpt = classDoc.fields().any{ isRequired(it, "false") }
%><% if (hasReq) { %><% } %>REQUIRED<% if (hasReq) { %><% }
%> | <% if (hasOpt) { %><% } %>OPTIONAL<% if (hasOpt) { %><% } %><%
} else {
if (hasNested) { %><% } %>NESTED<% if (hasNested) { %><% }
if (classDoc.isEnum()) {
%> | <% if (hasEnumConstants) { %><% } %>ENUM CONSTANTS<% if (hasEnumConstants) { %><% }
}
%> | <% if (hasFields) { %><% } %>FIELD<% if (hasFields) { %><% }
if (hasProperties) { %> | PROPERTY<% }
if (classDoc.isClass()) {
%> | <% if (hasConstructors) { %><% } %>CONSTR<% if (hasConstructors) { %><% }
}
%> | <% if (hasMethods) { %><% } %>METHOD<% if (hasMethods) { %><% }
}
%>
DETAIL: <%
if (classDoc.isAnnotationType()) {
if (hasElements) { %><% } %>ELEMENT<% if (hasElements) { %><% }
} else {
if (classDoc.isEnum()) {
if (hasEnumConstants) { %><% } %>ENUM CONSTANTS<% if (hasEnumConstants) { %> | <% }
}
if (hasFields) { %><% } %>FIELD<% if (hasFields) { %><% }
if (hasProperties) { %> | PROPERTY<% }
if (classDoc.isClass()) {
%> | <% if (hasConstructors) { %><% } %>CONSTR<% if (hasConstructors) { %><% }
}
%> | <% if (hasMethods) { %><% } %>METHOD<% if (hasMethods) { %><% }
}
%>
${classDoc.containingPackage().nameWithDots()}
${classDoc.typeDescription} ${classDoc.name()}
<%
def parents = classDoc.isInterface() ? classDoc.parentInterfaces : classDoc.parentClasses
if (parents.size() >= 2) {
%><%
parents.eachWithIndex { p, i ->
%>${(i > 0 ? " " * i + " " * (i - 1) + "
" : "") + ( i == parents.size() - 1 ? p.qualifiedTypeName() : linkfull(p))}\n<%
}
%>
<%
}
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:
- ${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 (hasNested) { %>
Nested Class Summary
<% for (c in classDoc.innerClasses()) { %>
${modifiersBrief(c) + c.typeSourceDescription}
${linkable(c)}
${c.firstSentenceCommentText()}
<% } %>
<% } %>
<% if (hasEnumConstants) { %>
Enum Constant Summary
<% for (ec in classDoc.enumConstants()) { %>
${ec.name()}
${ec.firstSentenceCommentText()}
<% } %>
<% } %>
<% if (hasFields) { %>
Field Summary
<% for (field in visibleFields) { %>
${modifiersBrief(field) + linkable(field.type())}
${field.name()}
${field.firstSentenceCommentText()}
<% } %>
<% }
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.each { c ->
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{ it.isPublic() || it.isProtected() }.collect { field ->
"${field.name()}"
}
} else {
list = c.externalClass().fields.findAll{ isVisible(it) }.collect { field ->
// "${field.name()}"
field.name
}
}
if (list) {
if (!fieldSummaryShown) {
fieldSummaryShown = true
%>
Field Summary
<%
}
%>
Fields inherited from ${c.typeSourceDescription} ${linkable(c)}
${list.join(', ')}
<%
}
}
classes = nextLevel
}
%>
<% if (hasProperties) { %>
Property Summary
<% for (prop in visibleProperties) { %>
${modifiersBrief(prop) + linkable(prop.type())}
${prop.name()}
${prop.firstSentenceCommentText()}
<% } %>
<% } %>
<% if (hasElements) { %>
<% elementTypes.each { k, v -> %>
<% if (visibleFields.any{ isRequired(it, v) }) { %>
${upcase(k)} Element Summary
<% for (element in visibleFields) { %>
<% if (isRequired(element, v)) { %>
${modifiersBrief(element) + element.type().typeName()}
${element.name()}
${element.firstSentenceCommentText()}
<% } %>
<% } %>
<% } %>
<% } %>
<% } %>
<% if (hasConstructors) { %>
Constructor Summary
<% for (constructor in classDoc.constructors()) { %>
${modifiersBrief(constructor)}${constructor.name()}(${paramsOf(constructor, true)})
${constructor.firstSentenceCommentText()}
<% } %>
<% } %>
<% if (hasMethods) { %>
Method Summary
<% for (method in visibleMethods) { %>
${modifiersBrief(method)}${linkable(method.returnType())}
${method.name()}(${paramsOf(method, true)})
${method.firstSentenceCommentText()}
<% } %>
<% }
Set 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)
}
Set visited = [classDoc] as Set
while (classes) {
Set nextLevel = []
classes.each { c ->
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{ it.isPublic() || it.isProtected() }.collect { method ->
"${method.name()}"
}
} else {
list = c.externalClass().methods.findAll{ isVisible(it) }.collect { method ->
// "${method.name()}"
method.name
}
}
if (list) {
if (!methodSummaryShown) {
methodSummaryShown = true
%>
Method Summary
<%
}
%>
Methods inherited from ${c.typeSourceDescription} ${linkable(c)}
${list.join(', ')}
<%
}
}
classes = nextLevel
}
%>
Enum Constant Detail
<% for (ec in classDoc.enumConstants()) { %>
${ec.name()}
${modifiers(ec) + '' + classDoc.name() + ''} ${ec.name()}
- ${ec.commentText()}
<% } %>
<% } %>
<% if (hasFields) { %>
Field Detail
<% for (field in visibleFields) { %>
${field.name()}
${annotations(field, '\n') + modifiers(field) + linkable(field.type())} ${field.name()}
- ${field.commentText()}
<% } %>
<% } %>
<% if (hasProperties) { %>
Property Detail
<% for (prop in visibleProperties) { %>
${prop.name()}
${annotations(prop, '\n') + modifiers(prop) + linkable(prop.type())} ${prop.name()}
- ${prop.commentText()}
<% } %>
<% } %>
<% if (hasElements) { %>
Element Detail
<% for (element in visibleFields) { %>
${element.name()}
${modifiers(element) + linkable(element.type())} ${element.name()}
- ${element.commentText()}
<% } %>
<% } %>
<% if (hasConstructors) { %>
Constructor Detail
<% for (constructor in classDoc.constructors()) { %>
${constructor.name()}
${annotations(constructor, '\n') + modifiers(constructor)}${constructor.name()}(${paramsOf(constructor, false)})
- ${constructor.commentText()}
<% } %>
<% } %>
<% if (hasMethods) { %>
Method Detail
<% for (method in visibleMethods) { %>
${method.name()}
${annotations(method, '\n') + modifiers(method)}${linkable(method.returnType())} ${method.name()}(${paramsOf(method, false)})
- ${method.commentText()}
<% } %>
<% } %>
${props['footer']?:""}