12

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.

Markus Marvell
  • 1,916
  • 1
  • 21
  • 26
  • Interesting. This works fine, except for the IDE warning. If I add a `val` or `var` before `param` it goes away (and of course becomes a property) - and I don't get the warning if I document a method param in this way. – Adam S Sep 19 '17 at 12:21
  • @AdamS That's how it's meant to work for properties and method params. I could add a `constructor` identifier before the primary constructor and treat it as a method. But I'd like to avoid clutter. – Markus Marvell Sep 19 '17 at 12:49

1 Answers1

10

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)
hotkey
  • 140,743
  • 39
  • 371
  • 326