2

Is there a syntax to documenting default arguments with KDoc, or should I do it manually?

/**
 * A group of *members*.
 *
 * This class has no useful logic; it's just a documentation example.
 *
 * @property name the name of this group. Default -"NoName"
 * @constructor Creates an empty group.
 */
class Group(val name: String = "NoName") {
    /**
     * Adds a [member] (default - NoMember) to this group.
     * @return the new size of the group.
     */
    fun add(member: String = "NoMember"): Int { ... }
}
Feedforward
  • 4,521
  • 4
  • 22
  • 34
  • 3
    Why do you want to document something that's already visible in the method signature? There's also no syntax for documenting that a method is public or protected, for the same reason. – yole Nov 27 '18 at 17:49
  • 3
    What's wrong with adding an explanation of the default to the `@property` or `@param` documentation? – dtech Nov 27 '18 at 18:24
  • I find that there is nothing wrong with documenting defaults. However, don't overdo it. In this case, I find that it is a bit too much, but I would recommend it if you have certain defaults that are set due to a certain reason. – DevNebulae Nov 28 '18 at 15:24

0 Answers0