Hi, could some one help out with a simple question...
# dokka
u
Hi, could some one help out with a simple question? If I want to document
interface MySDK {
and I have a global factory method
fun MySdk()
how do I refernce the method from the interface KDoc? The obvious approach is ambigouos and dokka chooses to resolves to the interface, not the method.
Copy code
/**
 * An implementation of this interface can be instantiated by calling the factory method [MySdk]()
 */
🤔 1
i
Hi! Is there any particular reason why your global factory method starts with an upper-case letter? from coding conventintions:
Names of functions, properties and local variables start with a lowercase letter and use camel case and no underscores:
There should be no problem then Even IDEA will navigate you to the interface declaration instead of the method if you use
Go to declaration
, not just dokka If you have
interface MySdk
and
fun MySdk()
in different packages, then using full path to the function should help, such as
[com.company.foo.bar.MySdk]
. If they're in the same package, not sure what to do..
r
Don't know if that's the case here, but fake constructors (i.e.
fun <ClassName>(...)
are a fairly common pattern.
☝️ 1
u
Exactly @rnett
And @Ignat Beresnev AS resolves type and method correctly
d
Re: fake constructors. Isn't it more normal to do that via an
invoke()
function definition in the companion object?