13

In Java, if you want to document a package, it has to be put into the package-info.class file. Is that still the same thing with Kotlin and KDoc?

I've looked through some of the Kotlin source and can't find where their package documentation is written.

Mahozad
  • 18,032
  • 13
  • 118
  • 133
Jacob Zimmerman
  • 1,521
  • 11
  • 20
  • https://kotlinlang.org/api/latest/jvm/stdlib/index.html appears to be generated from https://github.com/JetBrains/kotlin/blob/7105c7c182cc842bf4d970f9f3860aaefc2853ad/libraries/stdlib/src/Module.md which contains markup for the module and packages documentation. – mfulton26 Feb 04 '16 at 23:36
  • I just voted to re-open this question. It is closed with motivation "question seeks recommendations for tools, etc", but that is not at all what the question is about. The question is about how to document source code properly in Kotlin. – Enselic Nov 09 '21 at 15:40

1 Answers1

7

You use the include Dokka configuration option.

See: https://github.com/Kotlin/dokka/blob/master/README.md

Example: https://github.com/JetBrains/kotlin/blob/58e93d5e1bb547c8a7e398587b6851ccf6372326/libraries/build-docs.xml

mfulton26
  • 29,956
  • 6
  • 64
  • 88
  • 8
    As lousy as package-info is, I like it better than having to manually tell the generator to include certain files. – Jacob Zimmerman Feb 05 '16 at 08:48
  • Kotlin can't use the package-info approach because the package structure in Kotlin doesn't need to match the directory structure. And with Dokka you can have one file with the descriptions of all of your packages, and not one file per package as in Java. – yole Feb 05 '16 at 11:46
  • 2
    @yole "One file per package as in Java" is sometimes a more desirable approach. In Java/Javadoc, you have more freedom, as you can create either an `overview.html` page (one for all your packages), or separate `package-info.java` (per package), or both. – Bass Sep 11 '18 at 09:50