Questions tagged [kdoc]

KDoc is a documentation generation system which reads specially formatted comments in Kotlin source code and generates compiled documentation. It is typically used to produce API documentation in the form of HTML web pages.

Resources

Documenting Kotlin code

70 questions
160
votes
9 answers

How to use @link and @code in kotlin kDoc

I'm trying to document a method and trying to use @link and @code as in JavaDoc. I know in kotlin there is a kDoc but I can't find them or at least something similar.
humazed
  • 74,687
  • 32
  • 99
  • 138
52
votes
1 answer

KDoc: Insert code snippet

How do I insert a code snippet in KDoc, Kotlin's default documentation tool? In Java, I can use the following: /** * Example usage: * *
 * @JavaAnnotation
 * public void foo() {
 *     // Code
 * }
 * 
 * 
F. George
  • 4,970
  • 4
  • 20
  • 38
32
votes
1 answer

How do I inherit KDoc documentation?

In Java's Javadoc, there is a way to inherit a method's documentation in a subclass using {@inheritDoc} tag. Is there a way to do the same in Kotlin's KDoc? Basically, what I'd like to do is the following: abstract class Base { /** * Some…
hotkey
  • 140,743
  • 39
  • 371
  • 326
31
votes
3 answers

Line break, new line in KDoc

Assuming we have such documented string /** retrieve a state of the service *
HTTP code 200 - normal state *
HTTP code 403 - some recoverable state: const val SERVICE_STATE = "servicestate" */ There are several
here, which i used…
Beloo
  • 9,723
  • 7
  • 40
  • 71
27
votes
1 answer

How to represent hyperlink in KDoc

In Javadoc I can represent a hyperlink as @see http://google.com. How can I do this in Kotlin?
salyela
  • 1,325
  • 3
  • 14
  • 26
25
votes
1 answer

How to document attributes in Kotlin data class?

Where shall I put Javadoc analogy for attributes in KDoc in Kotlin data class? In other words, how to write in Kotlin KDoc the following Java code Javadoc: /** * Represents a person. */ public class Person { /** * First name. -- where to…
Honza Zidek
  • 9,204
  • 4
  • 72
  • 118
21
votes
1 answer

How to add formatting such as bold, italic, underscore, etc. to Kotlin documenation (KDoc)

I found the page Documenting Kotlin Code in the official Kotlin Reference. Yet, I could not find out how to highlight certain parts of the documentation, e.g., marking it as italic or bold. I am new to Kotlin, coming from Java, and have previously…
Markus Weninger
  • 11,931
  • 7
  • 64
  • 137
17
votes
1 answer

In Kotlin documentation (KDoc), is it possible to link to a specific overloaded method?

Consider the class comment of this Kotlin class: /** * This class has two methods, one that takes one parameters ([foo]), * and another one that takes two parameters ([foo]). **/ class Clazz { /* Foo with one. */ fun foo(a: Int) { } …
treesAreEverywhere
  • 3,722
  • 4
  • 28
  • 51
16
votes
1 answer

Can I reference a specific function overload?

Given the following code fun example() {} fun example(name: String) {} How can I reference a specific function? I.e. example() or example(String)? Using [example] I can't specify which exactly function I want.
Mibac
  • 8,990
  • 5
  • 33
  • 57
14
votes
0 answers

How do I reference a secondary constructor in KDoc?

I have a Kotlin class with a secondary constructor, that is supposed to be used in a certain scenario. Now this should be properly documented from the first constructor so you can see it right away. /** * This is my class. * * @constructor This is…
Jan Gillich
  • 313
  • 2
  • 10
13
votes
1 answer

Where/How do You Add Documentation for Kotlin Packages?

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…
Jacob Zimmerman
  • 1,521
  • 11
  • 20
12
votes
1 answer

How to add top level KDoc for a file?

Is there a way to add a piece of top level KDoc for a Kotlin file? Since Kotlin supports multiple variables, functions, classes, etc. in a single file, it makes sense to document the file as a whole. However, Documenting Kotlin Code - Kotlin…
Shreck Ye
  • 1,591
  • 2
  • 16
  • 32
11
votes
1 answer

Kotlin documentation doesn't support tags like '

' well

I'm writing doc comments to describe a method. /** *

necessary *

setType is to set the PendingIntend's request code

*/ But it won't show the paragraphs. If I don't use the

, all the documentation is in a line without…

Allen Vork
  • 1,536
  • 3
  • 16
  • 29
10
votes
1 answer

How do you publish KDoc for a Kotlin library using maven on Jitpack?

Background After a lot of researching and trying out, and also asking for help, I've succeeded publishing a private Github repository using maven on Jitpack (written here). So, currently the files that I put on the repository for Jitpack are just…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
10
votes
2 answers

Dokka: include code samples into package documentation

How do I include (tested, non-stale) code samples into Dokka package documentation? More specifically, assuming that I have this configuration in my build.gradle.kts: withType { outputFormat = "html" outputDirectory =…
Andrey Tyukin
  • 43,673
  • 4
  • 57
  • 93
1
2 3 4 5