I feel stupid. I try to write documentation on top...
# getting-started
c
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
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
Does the full package name have to be in bracket?
e
depends on if it's in scope (same package or imported) or not
c
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
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
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
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
[Pizza.eat]
, all documented: https://kotlinlang.org/docs/kotlin-doc.html
👍 1