groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "杨波" <>
Subject 回复:How to extract comments (especially the fields comments) from groovy or java (compiled in groovy) code?
Date Thu, 23 Jul 2020 05:38:45 GMT
Hi Paul,

Thanks for your reply. I found SimpleGroovyClassDocAssembler is enlightening.

The basic idea is to locate Field Node postion (line,column) and then extract code snippet
include comments between target field and previous Node.

I will try this method, and Grails compatible with Groovy3 will be great, so we can use a
lot of Groovy3 new features.


发件人:Paul King <>
发送时间:2020年7月23日(星期四) 12:25
收件人:users <>; 杨波 <>
主 题:Re: How to extract comments (especially the fields comments) from groovy or java
(compiled in groovy) code?

Groovy has a groovydoc command. You could just run that and extract those comments from the
resulting output or look at the sourcecode for groovydoc for inspiration.
From Groovy 3, you can extract such comments from the AST. Versions of Grails compatible with
Groovy 3 are not too far away.

Cheers, Paul.
On Thu, Jul 23, 2020 at 1:29 PM 杨波 <> wrote:

    I am writing a grails swagger plugin that needs to extract comments of class fields, such
as below code:

class UserCommand {
     * The name of user in comments
    String username

    String password

    String avatarUrl

    Then I need to extract the comment content "The name of user in comments" from the code.
I searched the Groovy2.5 AST, but can not find comments related nodes in the node tree.

How can I do this in Groovy 2.5 ? Because grails needs groovy v2.5.


Best Regards,

Bob Yang

View raw message