diff --git a/gradle/docs.gradle b/gradle/docs.gradle index 5bf8b26844e..c359f836d6e 100644 --- a/gradle/docs.gradle +++ b/gradle/docs.gradle @@ -18,7 +18,7 @@ */ task doc(dependsOn: ['javadocAll', 'groovydocAll', 'docGDK', 'asciidocAll']) { - ext.footer = 'Copyright © 2003-2021 The Apache Software Foundation. All rights reserved.' + ext.footer = 'Copyright © 2003-2024 The Apache Software Foundation. All rights reserved.' ext.title = "Groovy ${groovyVersion}" } diff --git a/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java b/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java index 02adcdb3b5d..2b4aa64700d 100644 --- a/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java +++ b/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java @@ -132,7 +132,7 @@ public void visitClass(ClassNode node) { } currentClassDoc.setRawCommentText(getDocContent(node.getGroovydoc())); currentClassDoc.setNameWithTypeArgs(name + genericTypesAsString(node.getGenericsTypes())); - if (!node.isInterface() && node.getSuperClass() != null) { + if (!node.isInterface() && !node.isEnum() && node.getSuperClass() != null) { String superName = makeType(node.getSuperClass()); currentClassDoc.setSuperClassName(superName); String superSimpleName = node.getSuperClass().getNameWithoutPackage(); @@ -314,8 +314,7 @@ private String makeType(ClassNode node) { final ClassNode cn = node.isArray() ? node.getComponentType() : node; return cn.getName().replace('.', '/').replace('$', '.') + genericTypesAsString(cn.getGenericsTypes()) - + (node.isArray() ? "[]" : "") - ; + + (node.isArray() ? "[]" : ""); } @Override @@ -368,7 +367,11 @@ public void visitField(FieldNode node) { processModifiers(fieldDoc, node, node.getModifiers()); processAnnotations(fieldDoc, node); fieldDoc.setRawCommentText(getDocContent(node.getGroovydoc())); - currentClassDoc.add(fieldDoc); + if (node.isEnum()) { + currentClassDoc.addEnumConstant(fieldDoc); + } else { + currentClassDoc.add(fieldDoc); + } super.visitField(node); } diff --git a/subprojects/groovy-groovydoc/src/main/resources/org/codehaus/groovy/tools/groovydoc/gstringTemplates/classLevel/classDocName.html b/subprojects/groovy-groovydoc/src/main/resources/org/codehaus/groovy/tools/groovydoc/gstringTemplates/classLevel/classDocName.html index 011ba5225ec..cafa0f2a7eb 100644 --- a/subprojects/groovy-groovydoc/src/main/resources/org/codehaus/groovy/tools/groovydoc/gstringTemplates/classLevel/classDocName.html +++ b/subprojects/groovy-groovydoc/src/main/resources/org/codehaus/groovy/tools/groovydoc/gstringTemplates/classLevel/classDocName.html @@ -56,12 +56,12 @@ } def linkfull = { t -> dolink(t, true) } def linkable = { t -> dolink(t, false) } - def modifiersWithOptions = { t, boolean ignorePublic, boolean ignoreAbstract -> + def modifiersWithOptions = { t, boolean ignorePublic, boolean ignoreAbstract, boolean ignoreFinal=false, boolean ignoreStatic=false -> (t.isPrivate()?"private ":"") + (t.isPublic() && !ignorePublic?"public ":"") + (t.isProtected()?"protected ":"") + - (t.isStatic()?"static ":"") + - (t.isFinal()?"final ":"") + + (t.isStatic() && !ignoreStatic ?"static ":"") + + (t.isFinal() && !ignoreFinal?"final ":"") + (!ignoreAbstract && t.respondsTo('isAbstract') && t.isAbstract()?"abstract ":"") } def modifiers = { t -> modifiersWithOptions(t, classDoc.isGroovy(), false) } @@ -157,14 +157,14 @@ if (hasElements) { %>
  • <% } %>Element<% if (hasElements) { %>
  • <% } %>   <% } else { if (classDoc.isEnum()) { - if (hasEnumConstants) { %>
  • <% } %>Enum constants<% if (hasEnumConstants) { %>
  • <% } %>   <% + if (hasEnumConstants) { %>
  • <% } %>Enum constants<% if (hasEnumConstants) { %>
  • <% } %>   <% } - if (hasFields) { %>
  • <% } %>Field<% if (hasFields) { %>
  • <% } %>   <% - if (hasProperties) { %>
  • Property
  • <% } %>   <% + if (hasFields) { %>
  • <% } %>Field<% if (hasFields) { %>
  • <% } %>   <% + if (hasProperties) { %>
  • Property
  • <% } %>   <% if (classDoc.isClass()) { - if (visibleConstructors) { %>
  • <% } %>Constructor<% if (visibleConstructors) { %>
  • <% } %>   <% + if (visibleConstructors) { %>
  • <% } %>Constructor<% if (visibleConstructors) { %>
  • <% } %>   <% } - if (visibleMethods) { %>
  • <% } %>Method<% if (visibleMethods) { %>
  • <% } %>   <% + if (visibleMethods) { %>
  • <% } %>Method<% if (visibleMethods) { %>
  • <% } %>   <% } %> @@ -233,7 +233,7 @@

    ${classDesc}


    <% def declaration = annotations(classDoc, '\n') + - modifiersWithOptions(classDoc, classDoc.isGroovy(), classDoc.isInterface() || classDoc.isAnnotationType()) + + modifiersWithOptions(classDoc, classDoc.isGroovy(), classDoc.isInterface() || classDoc.isAnnotationType(), classDoc.isEnum(), false) + classDoc.typeSourceDescription + ' ' + nameEncoded @@ -568,7 +568,7 @@

    Enum Constant Detail

    @@ -713,19 +713,19 @@

    ${method.typeParameters() ? 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) { %>
  • <% } %>   <% + if (hasReq) { %>
  • <% } %>Required<% if (hasReq) { %>
  • <% } %>   <% + if (hasOpt) { %>
  • <% } %>Optional<% if (hasOpt) { %>
  • <% } %>   <% } else { - if (visibleNested) { %>
  • <% } %>Nested<% if (visibleNested) { %>
  • <% } %>   <% + if (visibleNested) { %>
  • <% } %>Nested<% if (visibleNested) { %>
  • <% } %>   <% if (classDoc.isEnum()) { - if (hasEnumConstants) { %>
  • <% } %>Enum constants<% if (hasEnumConstants) { %>
  • <% } %>   <% + if (hasEnumConstants) { %>
  • <% } %>Enum constants<% if (hasEnumConstants) { %>
  • <% } %>   <% } - if (hasFields) { %>
  • <% } %>Field<% if (hasFields) { %>
  • <% } %>   <% - if (hasProperties) { %>
  • Property
  • <% } %>   <% + if (hasFields) { %>
  • <% } %>Field<% if (hasFields) { %>
  • <% } %>   <% + if (hasProperties) { %>
  • Property
  • <% } %>   <% if (classDoc.isClass()) { - if (visibleConstructors) { %>
  • <% } %>Constructor<% if (visibleConstructors) { %>
  • <% } %>   <% + if (visibleConstructors) { %>
  • <% } %>Constructor<% if (visibleConstructors) { %>
  • <% } %>   <% } - if (visibleMethods) { %>
  • <% } %>Method<% if (visibleMethods) { %>
  • <% } %>   <% + if (visibleMethods) { %>
  • <% } %>Method<% if (visibleMethods) { %>
  • <% } %>   <% } %> @@ -733,17 +733,17 @@

    ${method.typeParameters() ?
  •  | Detail: 
  • <% if (classDoc.isAnnotationType()) { - if (hasElements) { %>
  • <% } %>Element<% if (hasElements) { %>
  • <% } %>   <% + if (hasElements) { %>
  • <% } %>Element<% if (hasElements) { %>
  • <% } %>   <% } else { if (classDoc.isEnum()) { - if (hasEnumConstants) { %>
  • <% } %>Enum constants<% if (hasEnumConstants) { %>
  • <% } %>   <% + if (hasEnumConstants) { %>
  • <% } %>Enum constants<% if (hasEnumConstants) { %>
  • <% } %>   <% } - if (hasFields) { %>
  • <% } %>Field<% if (hasFields) { %>
  • <% } %>   <% - if (hasProperties) { %>
  • Property
  • <% } %>   <% + if (hasFields) { %>
  • <% } %>Field<% if (hasFields) { %>
  • <% } %>   <% + if (hasProperties) { %>
  • Property
  • <% } %>   <% if (classDoc.isClass()) { - if (visibleConstructors) { %>
  • <% } %>Constructor<% if (visibleConstructors) { %>
  • <% } %>   <% + if (visibleConstructors) { %>
  • <% } %>Constructor<% if (visibleConstructors) { %>
  • <% } %>   <% } - if (visibleMethods) { %>
  • <% } %>Method<% if (visibleMethods) { %>
  • <% } %>   <% + if (visibleMethods) { %>
  • <% } %>Method<% if (visibleMethods) { %>
  • <% } %>   <% } %> diff --git a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java index ec38f374432..2ab1e5f0b69 100644 --- a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java +++ b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java @@ -685,7 +685,7 @@ public void testInnerEnumReference() throws Exception { assertEquals("There has to be a reference to class Enum", "Enum", m.group(3)); } - public void testEnumInitNotDocumented() throws Exception { + public void testEnumConstantsDocumentedAndInitNotDocumented() throws Exception { final String base = "org/codehaus/groovy/tools/groovydoc/testfiles"; final String klass = "EnumWithDeprecatedConstants"; htmlTool.add(Arrays.asList( @@ -696,6 +696,7 @@ public void testEnumInitNotDocumented() throws Exception { htmlTool.renderToOutput(output, MOCK_DIR); final String groovydoc = output.getText(MOCK_DIR + "/" + base + "/"+ klass +".html"); + assertTrue(groovydoc.matches("(?s).*bar<.*<\\/table>.*")); final Matcher ctor = Pattern.compile(Pattern.quote("$INIT")).matcher(groovydoc);