https://kotlinlang.org logo
#getting-started
Title
# getting-started
c

Colton Idle

04/17/2021, 1:52 AM
I feel stupid. I try to write documentation on top of my class like so
Copy code
/**
* This class does this or that
*
but I always want to link to other classes or methods to help my team easily navigate to places that I reference, but I can never get it to work correctly. I also tried to search online for how to write common documentation like this, but I still can't get it to work. Apparently I just put a class name in brackets [] but when I pull up the documentation I can't click on it to navigate to that class. Does anyone know of like a nice crash course in documenting in kotlin code? Thank you!
u

ushort

04/17/2021, 2:08 AM
Assuming you're using IntelliJ, you can control click after putting them inside square brackets like you would normal code
Copy code
/**
 * [SomeClass]
 */
Quick read if you want https://kotlinlang.org/docs/coding-conventions.html#documentation-comments
👍 1
c

Colton Idle

04/17/2021, 2:34 AM
Does the full package name have to be in bracket?
e

ephemient

04/17/2021, 2:36 AM
depends on if it's in scope (same package or imported) or not
c

Colton Idle

04/17/2021, 2:38 AM
Interesting. I guess I'll have to try again. I don't know how I couldn't get it to work
When I click on it... should it take me to the class itself, or will it take me to the class' documentation.
u

ushort

04/17/2021, 2:43 AM
It'll take you to the class itself. It's the same as control clicking any code, takes you to declaration of thing you clicked. Where are you putting class' documentation if not in the class?
e

ephemient

04/17/2021, 2:47 AM
if you click on the link from within the documentation, it should take you to the other class's documentation
if you ctrl-click the name in the kdoc comment in the source file, it should take you to the other class's source
c

Colton Idle

04/17/2021, 2:56 AM
Okay. I think I got it working for a class. How do I link to a partifular method in a class? Like
Pizza.eat()
?
e

ephemient

04/17/2021, 3:08 AM
[Pizza.eat]
, all documented: https://kotlinlang.org/docs/kotlin-doc.html
👍 1