且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

长JSDoc行的正确/规范格式是什么?

更新时间:2023-11-14 09:20:52

在JSDoc中有两种处理换行符的正确方法.第一种,显然是由Google使用的,是在第一种之后缩进行:

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.
 */

这来自《 Google Javascript样式指南》: http://google.github.io/styleguide/javascriptguide.xml?showone=Comments#Comments

This is from the Google Javascript Style Guide: http://google.github.io/styleguide/javascriptguide.xml?showone=Comments#Comments

第二个基于JSDoc源自JavaDoc的事实,这与您的第二个示例类似.有关JavaDoc示例的信息,请参见以下链接: http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html#styleguide

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.