Let's say there's a class which primary constructor has the parameter param
that I'd like to be resolved (linked to the actual parameter) within the doc block of the class.
/** Class A does something using [param].
@constructor constructs A with [param].
*/
class A (param: Int)
However, the inscription param
is highlighted by the IDE saying that it cannot resolve symbol param
.
The language used to document Kotlin code (the equivalent of Java's Javadoc) is called KDoc. In its essence, KDoc combines Javadoc's syntax for block tags (extended to support Kotlin's specific constructs) and Markdown for inline markup.
The primary constructor is initialized in the class header, goes after the class name, using the constructor keyword. The parameters are optional in the primary constructor. The constructor keyword can be omitted if there is no annotations or access modifiers specified.
Define an interface with the same factory function and two objects for the scopes. Define a function that takes the scope and the initializer block. Now you can use the useScope -Function and within the block the right factory function is invoked. Save this answer.
Actually, dokka correctly finds the parameter if you reference it with [param]
in the @constructor
paragraph, you can check that by inspecting the URL that appears in the assembled docs, which looks like:
file:///.../some.package/-a/-init-.html#some.package.A$<init>(kotlin.Int)/param
Seemingly, the warning about an unresolved reference is an issue with the IDE support for KDoc. Please report it at kotl.in/issue.
Another option is to use @param
in the class KDoc:
/**
* Class A does something using [param].
* @param param means something special.
*/
class A (param: Int)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With