-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Support for kdoc #17
Comments
Hi @mediavrog, all comment are part of the raw ast, but they are currently not attached to a class. I added an example here: As you can see in the raw ast, the KDoc comment is attached to the package header: I already added a class named But nested (in the ast) comments are not yet visible. |
I am interested in this feature as well; I want to parse just individual kdoc comments and verify their contents as part of my workflow. @drieks Can you recommend me which classes within this ast library I should look at for making such a feature possible? |
Hey there, At the moment I have been able to locate comments using the "attachments" field on AstWithAttachments. Without side-tracking the conversation and intent of this particular question too much I am wondering: what is the purpose of an AstWithAttachments? What are attachments and what makes them different from an Ast node's children? Thank you kindly, |
Hi Kevin @kevinvandenbreemen, you can find many examples in the unittest folder: https://github.com/kotlinx/ast/blob/master/grammar-kotlin-parser-test/src/commonMain/resources/testdata/ The Files are still there, just renamed:
The Attachments are used as a generic way to store additional data in the ast tree, for example line numbers or comments. The main problem with comments is that they do not have a syntax relationship to the commented code, so you have to look at different places. This is "only" a ast parsing library, but assignment of comments to commented objects or assigning types to packages (by looking into import statements) is a task that should better be done by a compiler or documentation parser tool (that can use the ast from here, or can even be an extension of this library)
|
So in the examples and the test cases, it seemed that single line comments are stripped from the AST output.
Now I could not find a reference or test case for class or function documentation (kdoc). Will this library parse them into some nodes or will comments be ignored in the output?
The text was updated successfully, but these errors were encountered: