How can I use inline markup to document parameters...
# dokka
s
How can I use inline markup to document parameters of a primary constructor? If I use the usual
[param]
syntax, IntelliJ show the references as unresolved.
c
What did you write exactly?
s
E.g. this:
Copy code
* A [Closeable] class which temporarily moves away [directories] to inside a [stashDir] and moves them back on close.
 * Any conflicting directory created at the location of an original directory is deleted before the original state is
 * restored. If a specified directory did not exist on initialization, it will also not exist on close.
 */
private class DirectoryStash(directories: Set<File>, stashDir: File) : Closeable {
directories
and
stashDir
are unresolved.
c
This is expected, this comment documents the class, not the constructor
s
.... seems natural to document the primary constructor as part of the class, though, or?
What would be the correct syntax then?
c
Not really, you wouldn't expect ArrayList's class documentation to explain what its primary constructor takes as arguments (it's probably private anyway)
What would be the correct syntax then?
If the constructor parameters are properties, you can resolve them in the class documentation:
Copy code
/**
 * Some example: [a]
 */
class Foo(val a: Int)
If they are not properties, you can use
@param
:
Copy code
class Foo
/**
 * The primary constructor.
 *
 * @param a test
 */
constructor(a: Int) {

    init {
        println(a)
    }
}
However, I expected this to work and it didn't, which seems worth reporting as a bug:
Copy code
class Foo
/**
 * The primary constructor [a].
 */
constructor(a: Int) {

    init {
        println(a)
    }
}
s
So, there's no inline markup syntax to document an inline primary constructor?
c
Oh, I forgot but you can do this too:
Copy code
/**
 * test
 * 
 * @constructor Hello world, [a]
 */
class Foo(a: Int)
I doesn't seem to resolve
a
as well, I think this one is a bug.
s
Heh, so we're running into two bugs here 👀
c
I think it's likely they're the same, but yeah 😅 if you report them, please link them here
👍🏻 1
👍 1
v
I doesn't seem to resolve
a
as well, I think this one is a bug.
Unfortunately, we do not support inlined docs inside the
@constructor
tag. See https://github.com/Kotlin/dokka/issues/1953
c
Interesting, IDEA does accept it and properly shows the documentation popup, too 🤔