I see much code, which uses the tag @property
to document properties:
/**
* Some Class
*
* @property p Some property
*/
class C {
val p = 42
}
But I prefer to document properties where the are defined:
/** Some Class */
class C {
/** Some property */
val p = 42
}
Are the two ways equivalent?
Have a look at Document Kotlin code:
There, they explain the purpose of the
@property
like this:Thus, your way of doing (second example in your question) is the proper way to go in KDoc. The only place where
@property
makes sense is for primary constructor properties.Note that even in constructor, we could get rid of the
@property
and write instead:This last point is more a matter of taste. I personally never use
@property
, which looks to java-esque for my taste.