Ok, I got it working now (didn't look at the source code the first
time - how silly can you be?) This works from the Rhino shell with
current CVS HEAD:

importPackage(org.mozilla.javascript);
var ce = new CompilerEnvirons();
ce.setRecordingComments(true);
ce.setRecordingLocalJsDocComments(true)
ce.initFromContext(Context.getCurrentContext());
var p = new Parser(ce, null);
var ast = p.parse("/** FOO */\nfunction foo() {}", 'sourcename', 0);
ast.debugPrint();
ast.firstChild.debugPrint()
ast.firstChild.getJsDoc()

ast.firstChild is function foo, and ast.firstChild.getJsDoc() delivers
the JSDoc comment associated with it. Great - I think creating jsdoc
based documentation just got a lot easier.

Hannes

On May 18, 12:09 am, gozala <[email protected]> wrote:
> Hi,
>
> I'm trying to parse js source using rhino and then I would like to get
> a jsdoc comments which I suppose cane be collected from AstRoot via
> visitComments function. Unfortunately I can't get any comment node
> while I can get rest of the astNode's even visit and visitAll returns
> exactly the same ammount of AstNode's. Of course source I'm parsing
> has a comments.
>
> Do I need to do something else to get comment nodes or might I'm doing
> something wrong ?
> Thanks

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to