Another question… working on a plugin. I’d like to...
# dokka
r
Another question… working on a plugin. I’d like to generate a new table of contents page that enumerates and links to classes that implement a particular type. I’m sleuthing through the code right now and struggling to come up with the right things to implement to do something like this. Any pointers?
Actually, better yet, it’d be nice if I could add another content node (?) to a module’s root
index.html
as another section (e.g. another heading similar to
Packages
).
m
Data about all implemented interfaces can be taken from the
sources
field in Documentables. From there you can get the descriptor/PSI (depending on the language) and see their supertypes. I'd suggest creating a new extra for keeping the data. As for the actual table of content, i think it should be a PageTransformer plugged either in
CoreExtensions.pageTransformer
or (if it is only relevant for 1 output format) in preprocessors.
r
Another followup: I have this plugin in
buildSrc
, but I’m struggling to figure out how to connect it in the dependencies. Seems like adding a
dokkaHtmlPlugin
in
dependencies
is the right thing to do, but I don’t know how to reference
buildSrc
from there. Do I have to create this plugin as a totally separate repository and artifact?
Derp. Just moved it to a module instead of
buildSrc
.
Hmm… didn’t seem to help it any, but I do see making it a module is the way to go.
m
I think you are thinking about a gradle plugin rather than a dokka plugin. They are not the same. You need to create a dokka plugin. You may also want to check out if your plugin's project structure is correct: • https://kotlin.github.io/dokka/1.4.10/developer_guide/introduction/ • And an example on how a plugin should look like: https://github.com/Kotlin/dokka/tree/master/plugins/mathjax Creating an artifact is not required since you can reference project in dependencies
Also please remember about including a file in META-INF like here: https://github.com/Kotlin/dokka/blob/master/plugins/mathjax/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin Directory structure and name should be the same, all you need to change is the name of the plugin inside
org.jetbrains.dokka.plugability.DokkaPlugin
file