Hello! I am making a Dokka plugin to render docs a...
# dokka
m
Hello! I am making a Dokka plugin to render docs as Json and I am getting a bit lost on how to correctly approach this, my idea was to have a package object that has classes/interfaces objects inside, then inside those would go the members, etc. I was able to get decently far into this crazy idea, however I am unsure how to correctly proceed, for example I am trying to get the parameters of a function and its comments, and annotations, etc. If I use the
documentables
as DFunction I can get the parameters but they lack the comments and generic types are erased, ex:
test: Provider<String>
would turn into just
Provider
. Could I get some advice on how to correctly approach this? I feel like I am not doing this the correct way.
j
Hello @Mateus Moreira I'm working in a plugin with the same functionality. I didn't post anything yet as it is still a bit green. However, if you want to collaborate to reach that goal, we can share efforts. This is what I've done so far: https://github.com/hexagonkt/hexagon_extra/tree/develop/dokka_json
🙌 1
m
Hey! I am doing this with a friend but if I can figure something out I can definitely help you out too! I have currently figured that the parameters and their types are inside the member node's DRI, which contains the type parameters too, but sadly the parameter name is not in there, it's in the documentables. Only thing I need to figure now (other than comments, I am leaving that for last) is the return type of a function.
👍 1
v
If I use the
documentables
as DFunction I can get the parameters but they lack the comments and generic types are erased, ex:
test: Provider<String>
would turn into just
Provider
.
Dokka keeps generic types. E.g.,
DParameter.type
will have
GenericTypeConstructor
type. You can have a look at our unit tests: https://github.com/Kotlin/dokka/blob/4451b8e546584da389da60f73b56ce25d6ac2eaa/plugins/base/src/test/kotlin/model/FunctionsTest.kt#L217 and how we generate function signatures: https://github.com/Kotlin/dokka/blob/c0aece910e9b012a45ef577136a3f986c52df23e/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt#L301
m
Thank you so much for the links! They were amazing help!
One more question, is there a way to get the link of what the HTML renderer would give to a page? For classes is it always
-
plus the class name lower kebab cased? Basically I need the json to link to the original html docs when possible
v
I suppose you need this and DokkaLocationProvider.
m
Awesome, ty!