groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject groovy git commit: GROOVY-7340: GroovyDoc doesn't understand method type parameters
Date Thu, 01 Sep 2016 06:05:20 GMT
Repository: groovy
Updated Branches:
  refs/heads/master 86f345d72 -> d96568429


GROOVY-7340: GroovyDoc doesn't understand method type parameters


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/d9656842
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d9656842
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d9656842

Branch: refs/heads/master
Commit: d9656842908acb403599cf574f509aea2737be47
Parents: 86f345d
Author: paulk <paulk@asert.com.au>
Authored: Thu Sep 1 16:04:14 2016 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Thu Sep 1 16:04:14 2016 +1000

----------------------------------------------------------------------
 .../groovydoc/SimpleGroovyClassDocAssembler.java   | 14 +++++++++++++-
 .../tools/groovydoc/SimpleGroovyMethodDoc.java     |  9 +++++++++
 .../gstringTemplates/classLevel/classDocName.html  | 17 ++++++++++-------
 3 files changed, 32 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/d9656842/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
index 810e694..a178a92 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
@@ -250,6 +250,9 @@ public class SimpleGroovyClassDocAssembler extends VisitorAdapter implements
Gro
                 }
             }
             SimpleGroovyMethodDoc currentMethodDoc = createMethod(t, currentClassDoc);
+            StringBuilder params = new StringBuilder();
+            getTypeParameters(t.childOfType(TYPE_PARAMETERS), params, "def");
+            currentMethodDoc.setTypeParameters(params.toString());
             currentClassDoc.add(currentMethodDoc);
         }
     }
@@ -795,7 +798,16 @@ public class SimpleGroovyClassDocAssembler extends VisitorAdapter implements
Gro
             if (next.getType() == TYPE_UPPER_BOUNDS) return "? extends " + boundType;
             if (next.getType() == TYPE_LOWER_BOUNDS) return "? super " + boundType;
         } else if (typeNode.getType() == IDENT) {
-            return getAsTextCurrent(typeNode, defaultText);
+            String ident = getAsTextCurrent(typeNode, defaultText);
+            AST next = typeNode.getNextSibling();
+            if (next == null && typeNode.getFirstChild() != null) {
+                // Java2Groovy produces a slightly different tree structure (TODO fix converter
or java.g instead?)
+                next = typeNode.getFirstChild();
+            }
+            if (next == null) return ident;
+            String boundType = getTypeNodeAsText((GroovySourceAST) next.getFirstChild(),
defaultText);
+            if (next.getType() == TYPE_UPPER_BOUNDS) return ident + " extends " + boundType;
+            if (next.getType() == TYPE_LOWER_BOUNDS) return ident + " super " + boundType;
         }
         return defaultText;
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/d9656842/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyMethodDoc.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyMethodDoc.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyMethodDoc.java
index 85e424a..60cbbc5 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyMethodDoc.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyMethodDoc.java
@@ -22,6 +22,7 @@ import org.codehaus.groovy.groovydoc.*;
 
 public class SimpleGroovyMethodDoc extends SimpleGroovyExecutableMemberDoc implements GroovyMethodDoc
{
     private GroovyType returnType;
+    private String typeParameters;
 
     public SimpleGroovyMethodDoc(String name, GroovyClassDoc belongsToClass) {
         super(name, belongsToClass);
@@ -56,4 +57,12 @@ public class SimpleGroovyMethodDoc extends SimpleGroovyExecutableMemberDoc
imple
     public boolean overrides(GroovyMethodDoc arg0) {/*todo*/
         return false;
     }
+
+    public String typeParameters() {
+        return typeParameters;
+    }
+
+    public void setTypeParameters(String typeParameters) {
+        this.typeParameters = typeParameters;
+    }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/d9656842/subprojects/groovy-groovydoc/src/main/resources/org/codehaus/groovy/tools/groovydoc/gstringTemplates/classLevel/classDocName.html
----------------------------------------------------------------------
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 a4812c3..d1ab15a 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
@@ -263,7 +263,7 @@ if (classDoc.isInterface()) {
                         <tr class="${i%2==0?'altColor':'rowColor'}">
                             <td class="colFirst"><code><strong>${modifiersBrief(c)
+ c.typeSourceDescription}</strong></code>&nbsp;</td>
                             <td class="colLast"><code>${linkable(c)}</code></td>
-                            <td class="colLast">${c.firstSentenceCommentText()}</code></td>
+                            <td class="colLast">${c.firstSentenceCommentText()}</td>
                         </tr>
                         <% } %>
                     </table>
@@ -353,7 +353,7 @@ if (classDoc.isInterface()) {
                         <tr class="${i%2==0?'altColor':'rowColor'}">
                             <td class="colFirst"><code><strong>${modifiersBrief(field)
+ linkable(field.type())}</strong></code>&nbsp;</td>
                             <td class="colLast"><code><a href="#${field.name()}">${field.name()}</a></code></td>
-                            <td class="colLast">${field.firstSentenceCommentText()}</code></td>
+                            <td class="colLast">${field.firstSentenceCommentText()}</td>
                         </tr>
                         <% } %>
                     </table>
@@ -444,7 +444,7 @@ if (classDoc.isInterface()) {
                         <% visibleConstructors.eachWithIndex { constructor, i -> %>
                         <tr class="${i%2==0?'altColor':'rowColor'}">
                             <td class="colFirst">
-                                <code>${modifiersBrief(constructor)}<a href="#${nameFromParams(constructor)}">${constructor.name()}</a></strong>
+                                <code>${modifiersBrief(constructor)}<a href="#${nameFromParams(constructor)}">${constructor.name()}</a>
                                 (${paramsOf(constructor, true)})</code><br>${constructor.firstSentenceCommentText()}</td>
                         </tr>
                         <% } %>
@@ -484,7 +484,7 @@ if (classDoc.isInterface()) {
                 if (list) {
                     buffer << """
                         <tr class="${i%2==0?'altColor':'rowColor'}">
-                            <td class="colFirst"><code>${c.typeSourceDescription}
${linkable(c)}</strong></code></td>
+                            <td class="colFirst"><code>${c.typeSourceDescription}
${linkable(c)}</code></td>
                             <td class="colLast"><code>${list.join(', ')}</code></td>
                         </tr>"""
                 }
@@ -502,12 +502,14 @@ if (classDoc.isInterface()) {
                     <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0"
summary="Methods Summary table">
                         <caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
                         <tr>
-                            <th class="colFirst" scope="col">Type</th>
+                            <th class="colFirst" scope="col">Type Params</th>
+                            <th class="colLast" scope="col">Return Type</th>
                             <th class="colLast" scope="col">Name and description</th>
                         </tr>
                         <% visibleMethods.eachWithIndex { method, i -> %>
                         <tr class="${i%2==0?'altColor':'rowColor'}">
-                            <td class="colFirst"><code>${modifiersBrief(method)}${linkable(method.returnType())}</strong></code></td>
+                            <td class="colFirst"><code>${org.codehaus.groovy.tools.groovydoc.SimpleGroovyClassDoc
.encodeAngleBrackets(method.typeParameters())}</code></td>
+                            <td class="colLast"><code>${modifiersBrief(method)}${linkable(method.returnType())}</code></td>
                             <td class="colLast"><code><strong><a href="#${nameFromParams(method)}">${method.name()}</a></strong>(${paramsOf(method,
true)})</code><br>${method.firstSentenceCommentText()}</td>
                         </tr>
                         <% } %>
@@ -653,7 +655,8 @@ if (classDoc.isInterface()) {
                         <a name="${nameFromParams(method)}"><!-- --></a>
                         <ul class="blockListLast">
                             <li class="blockList">
-                                <h4>${annotations(method, '\n') + modifiers(method)}${linkable(method.returnType())}
<strong>${method.name()}</strong>(${paramsOf(method, false)})</h4>
+                                <h4>${method.typeParameters() ?
+                                    org.codehaus.groovy.tools.groovydoc.SimpleGroovyClassDoc.encodeAngleBrackets(method.typeParameters())
+ ' ' : ''}${annotations(method, '\n') + modifiers(method)}${linkable(method.returnType())}
<strong>${method.name()}</strong>(${paramsOf(method, false)})</h4>
                                 <p>${method.commentText()}</p>
                             </li>
                         </ul>


Mime
View raw message