All of the official JSDoc examples have naively simple documentation strings, like the following:
/** * @param {string} author - The author of the book. */
The problem is, in real-life documentation you often have longer documentation strings:
/** * @param {string} author - The author of the book, presumably some person who writes well */
But since most companies (for legitimate readability reasons) have line length limits, the above often isn't acceptable. However, what I can't figure out is what the "right" way of breaking up those lines should be.
I could do:
/** * @param {string} author - The author of the book, presumably some * person who writes well */
But that is difficult to read. I could instead do:
/** * @param {string} author - The author of the book, presumably some * person who writes well */
That looks better, but it can result in a ton of lines, especially if the parameter has a long name:
/** * @param {string} personWhoIsTheAuthorOfTheBook - The author of the * book, presumably * some person who * writes well */
So my question is, what is the proper/official/canonical way of formatting long @param
lines (in the code, not in the generated JSDoc) ... or really any long annotation lines for that matter.
The {@link} inline tag creates a link to the namepath or URL that you specify. When you use the {@link} tag, you can also provide link text, using one of several different formats. If you don't provide any link text, JSDoc uses the namepath or URL as the link text.
JSDoc comments are used for documentation lookup with Ctrl+Q in JavaScript and TypeScript, see JavaScript documentation look-up and TypeScript documentation look-up, as well as for type annotations and method return type hints in chained methods.
JSDoc is a markup language used to annotate JavaScript source code files. Using comments containing JSDoc, programmers can add documentation describing the application programming interface of the code they're creating.
There are two proper ways of dealing with line breaks in JSDoc. The first, apparently used by Google, is to indent the lines after the first:
/** * @param {string} author - The author of the book, presumably some * person who writes well and does so for a living. This is * especially important for obvious reasons. */
This is from the Google Javascript Style Guide: http://google.github.io/styleguide/javascriptguide.xml?showone=Comments#Comments
The second is based on the fact that JSDoc is derived from JavaDoc, which is similar to your second example. See the following link for JavaDoc examples: http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html#styleguide
I would recommend using the indentation method - I think it is a good cross between readability and not having extremely short lines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With