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
Ignat Beresnev
02/24/2022, 7:00 PM
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
rnett
02/24/2022, 7:37 PM
Don't know if that's the case here, but fake constructors (i.e.
fun <ClassName>(...)
are a fairly common pattern.
☝️ 1
u
uli
02/24/2022, 8:09 PM
Exactly @rnett
uli
02/24/2022, 8:10 PM
And @Ignat Beresnev AS resolves type and method correctly
d
David Hamilton
03/04/2022, 5:10 PM
Re: fake constructors. Isn't it more normal to do that via an