Search code examples
mavenkotlinkotlin-jskotlin-dokkadokka

Linking JS stdlib to generated kdoc


Developing a Kotlin/JS project, we are generating KDoc using Dokka Maven plugin. However standard JS library classes are presented as ERROR CLASS in the generated doc.

Example: having function like this:

fun HTMLElement.component(label: String, init: () -> Unit)

gives documentation:

fun <ERROR CLASS>.component(label: String, init: () -> Unit)

We are behind proxy and the Dokka plugin is configured to work offline (<offlineMode>true</offlineMode>). How can we link the stdlib documentation to the generated one?

EDIT: Seems it is related to Dokka Maven plugin, with Gradle the documentation is generated all right.


Solution

  • I've got my answer elsewhere so I'll just put it here to close it.

    Two things are needed: to add <platform>js</platform> to the plugin configuration, and to run KDoc generation after the package phase (pre-integration-test phase is recommended).

    Sample configuration:

    <plugin>
        <groupId>org.jetbrains.dokka</groupId>
        <artifactId>dokka-maven-plugin</artifactId>
        <version>...</version>
        <executions>
            <execution>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>dokka</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <offlineMode>true</offlineMode>
            <platform>js</platform>
            <apiVersion>...</apiVersion>
        </configuration>
    </plugin>