# dokka


07/29/2022, 10:58 AM
Hi, I would like to extract comments from Kotlin code using Dokka and produce a JSON or something similar. My goal is to use those comments together with other information to generate domain specific documentation. Is this something possible? Any pointer to share?

Ignat Beresnev

07/29/2022, 2:20 PM
Hi! I believe this is possible by writing a lightweight custom Dokka plugin. Traversing the Documentables tree should be enough, so you can disable creation of pages and rendering (and possibly some transformers if you want to keep the information and comments close to source without changes) Or, actually, you can write a
to produce JSON output instead of html/md. Depends on your use case There's a similar plugin already written for knit: pathsaver-plugin. It traverses the documentables tree and dumps links to members to a json file We've also recently updates Developer Guides, there you can find all of the info on Dokka's architecture and on how to write a plugin for it (with a tutorial)
Before you begin though - have you considered KSP or something similarly low-level? I don't know if they have access to KDocs, but if you want to be in more control over what information you get from source code and you only have Kotlin sources - it could be a good fit Don't know much about your use case, and Dokka would do the job, but I'm not sure you need a full blown api reference engine for that