0

So we have a task to produce documentation for a REST API we are building. We are using Grails and it's all nicely defined in UrlMappings but that doesn't generate a documentation the way we want.

We thought of using reflection to extract the mappings into some format that we can manipulate through code.

There's also a possibility of maybe parsing the UrlMappings as a text file and produce some data format that we can manipulate.

For the reflection bit, can we extract info from Closures - such as properties, methods, etc - in Groovy?

Any other ideas would be appreciated.

Tarcio Saraiva
  • 552
  • 5
  • 16
  • Found this question but not entirely sure yet http://stackoverflow.com/questions/4114190/retrieve-groovy-closure-method-parameters-list – Tarcio Saraiva Feb 13 '13 at 02:59
  • 1
    although I have no idea where to start, you might look into groovy's abstract syntax tree--it gives you the structure of the code as it is compiled--you might be able to get information out of that. If you load a class into GroovyConsole there is an option to bring up the AST and see if it helps, at least. – Bill K Feb 13 '13 at 03:17
  • Hi Bill K, I guess that's more or less what I'm after. At least the GroovyConsole gave me a list of ClosureExpressions which show me that is possible to get detailed information about Closures. Thank you for that! – Tarcio Saraiva Feb 13 '13 at 03:57
  • @TMan Would this plugin be of interest for you? http://grails.org/plugin/grails-runtime-docs – herom Feb 13 '13 at 12:05
  • @TMan Sorry I can't help more, I just know of it's existence, not how to use it although it looks amazingly powerful--so I don't think it's worth leaving as an answer. If anyone knows of a really good tutorial on how to really use AST trees in groovy please drop a link :) – Bill K Feb 13 '13 at 17:26
  • @herom, no luck man, that's not what I'm after. Thank you anyway. – Tarcio Saraiva Feb 13 '13 at 22:07
  • @BillK That's cool man, it does look very powerful indeed. I just wish I had a bit more knowledge of Groovy to play with AST .. but hey, that's cool. Thanks! – Tarcio Saraiva Feb 13 '13 at 22:08

0 Answers0