You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "paulk-asert (via GitHub)" <gi...@apache.org> on 2026/04/21 03:44:39 UTC

[PR] Enhanced groovydoc spike [groovy]

paulk-asert opened a new pull request, #2479:
URL: https://github.com/apache/groovy/pull/2479

     GROOVY-3782   {@inheritDoc} + stray-brace rendering bug                                                                                                                                                                                       
     GROOVY-4634   Honor @Documented on annotation refs
     GROOVY-5986   doc-files / snippet-files resource copy                                                                                                                                                                                         
     GROOVY-6016   {@value} inline tag (same-class, cross-class, and bare)                                                                                                                                                                         
     GROOVY-8025   NPE on closures in annotations                                                                                                                                                                                                  
     GROOVY-8877   Document top-level scripts; cross-link embedded classes                                                                                                                                                                         
     GROOVY-9057   Non-zero exit code on groovydoc errors                                                                                                                                                                                          
     GROOVY-9572   Hide @Internal members; mark Verifier-generated __$stMC
     GROOVY-10162  Spurious Foo.1.html for abstract-method enum                                                                                                                                                                                    
     GROOVY-11542  JEP 467 Markdown doc comments (///)         
     GROOVY-11682  module attribute on Ant <link>                                                                                                                                                                                                  
     GROOVY-11938  {@snippet} (inline / external file / markup comments / syntax highlighting / Markdown interop / region scoping)
     GROOVY-11939  Consolidate inline-tag processing in SimpleGroovyClassDoc                                                                                                                                                                       
     GROOVY-11941  --add-stylesheet (additive, multiple stylesheets)
     GROOVY-11942  Class hierarchy tree pages (overview-tree, package-tree)                                                                                                                                                                        
     GROOVY-11943  -noindex / -nodeprecatedlist / -nohelp disable flags
     GROOVY-11945  Recognise @apiNote, @implSpec, @implNote block tags                                                                                                                                                                             
     GROOVY-11946  Auto dark mode via prefers-color-scheme + CSS variable refactor                                                                                                                                                                 
     GROOVY-11947  -theme=auto|light|dark generator flag  


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Enhanced groovydoc spike [groovy]

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert merged PR #2479:
URL: https://github.com/apache/groovy/pull/2479


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Enhanced groovydoc spike [groovy]

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #2479:
URL: https://github.com/apache/groovy/pull/2479#discussion_r3114917831


##########
subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java:
##########
@@ -190,23 +235,281 @@
         return result;
     }
 
+    /**
+     * GROOVY-8877: extract the first Javadoc-style comment block
+     * ({@code /** ... *}{@code /}) from the top of the source file, skipping
+     * line comments, plain block comments, whitespace, {@code package}
+     * declarations, and {@code import} declarations.
+     *
+     * <p>Lifting policy, by what follows the candidate comment:
+     * <ul>
+     *   <li><b>package / import / another comment / end of file</b> — lift.
+     *       These are unambiguous; the comment cannot belong to a following
+     *       member because there isn't one.</li>
+     *   <li><b>an annotation ({@code &#64;Xxx})</b> — lift only if no member
+     *       of the script class already owns the same comment content. This
+     *       covers the {@code @BaseScript} / {@code @Grab} pattern where the
+     *       annotated declaration is consumed by an AST transform and no
+     *       member survives to carry the doc, while still avoiding duplication
+     *       for cases like {@code @Override void foo()} where the parser
+     *       attached the comment to a real method.</li>
+     *   <li><b>anything else</b> (e.g. {@code def x = 42} which could be a
+     *       local variable or a field/property, or a bare declaration) —
+     *       don't lift. Groovy's script form makes it unreliable to tell
+     *       these apart without full parsing, so we err toward preserving
+     *       what the parser decided.</li>
+     * </ul>
+     *
+     * <p>Script authors who want a script-level doc should follow the
+     * convention of separating it with a package/import/comment or putting
+     * another Javadoc comment before the next member.
+     */
+    private String extractLeadingScriptDocContent(ClassNode scriptNode) {
+        String src;
+        try (Reader r = unit.getSource().getReader()) {
+            StringBuilder sb = new StringBuilder();
+            char[] buf = new char[8192];
+            int n;
+            while ((n = r.read(buf)) > 0) sb.append(buf, 0, n);
+            src = sb.toString();
+        } catch (IOException e) {
+            return "";
+        }
+        int i = 0, n = src.length();
+        while (i < n) {
+            char c = src.charAt(i);
+            if (Character.isWhitespace(c)) { i++; continue; }
+            if (c == '/' && i + 1 < n) {
+                char next = src.charAt(i + 1);
+                if (next == '/') {
+                    int eol = src.indexOf('\n', i);
+                    i = eol < 0 ? n : eol + 1;
+                    continue;
+                }
+                if (next == '*') {
+                    boolean isJavadoc = i + 2 < n && src.charAt(i + 2) == '*'
+                            && (i + 3 >= n || src.charAt(i + 3) != '/');
+                    int close = src.indexOf("*/", i + 2);
+                    if (close < 0) return "";
+                    if (isJavadoc) {
+                        String full = src.substring(i, close + 2);
+                        Matcher m = JAVADOC_COMMENT_PATTERN.matcher(full);

Review Comment:
   ## CodeQL / Polynomial regular expression used on uncontrolled data
   
   This [regular expression](1) that depends on a [user-provided value](2) may run slow on strings starting with '/**' and with many repetitions of '/**a'.
   
   [Show more details](https://github.com/apache/groovy/security/code-scanning/233)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org