基本上,我不太在乎我的同事如何格式化他的JSDoc,我只是不希望非标准的实践将来会引起问题(如果将来存在此类问题,我会希望能够向他解释这一点,而不仅仅是说我不喜欢您格式化JSDoc的方式".解决方案没有行业标准" jsdoc格式.有 jsdoc 3 以某种方式起作用,还有 jsdoc 2 ,其工作方式相似但又不同.有一个 jsdoc 1 但我不知道人们在生产中静止使用它的案例.然后,有一些工具或多或少成功地尝试了jsdoc的标记.行首的星号是可选的,通常是正确的,但并非在所有情况下都是正确的.例如,如果将jsdoc 3与 Markdown插件一起使用,则:此外,请确保在文档注释中使用前导星号!.如果您省略前导星号,则JSDoc的代码解析器可能会删除用于Markdown格式化的其他星号.因此,各种版本的jsdoc都不需要前导星号,但是在某些用例场景中,绝对需要前导星号.(我没有在jsdoc 3的文档中找到直接指出星号是可选的位置.但是,上面的引用暗示它们是可选的.)不过,在这里提出的问题中,两个代码段均以/* 开头.从jsdoc 1到jsdoc 3的所有版本的jsdoc都要求注释被处理为标记为像这样的/** 开头带有两个或多个星号.I've always seen JSDoc (and JavaDoc before it) in the following format: /** * This is some JSDoc ... * ... and some more */ function foo() {However, a co-worker of mine would prefer not to have the initial asterisks, ie.: /** This is some JSDoc ... ... and some more */ function foo() {When I try this in Eclipse it still recognizes the code as JSDoc (it colors it differently from non-JSDoc comments). However, when I look at the JSDoc website, all the examples include the asterisks ... but then again, I can't find anything that says they're required either (the JSDoc website seems kind of terrible to be honest).So, given that I can't even find a proper specification of what JSDoc is/is not, I figured I'd ask Stack Overflow. Can anyone here point me to either:A) some kind of canonical reference (eg. something from the JSDoc site) saying that the initial asterisks are/are not requiredB) examples of where not having the initial asterisks would be problematic (eg. "you can't use cool JSDoc library X unless you have initial asterisks")*EDIT*Just to clarify, we don't currently use the JSDoc documentation generator. This question comes more from a desire to format our comments in an industry-standard way, and a desire to (someday in the future) be able to use tools that rely on the JSDoc standard (such as the JSDOc documentaiton generator).Basically I don't really care how my co-worker formats his JSDoc, I just don't want a non-standard practice to cause a problem in the future (and if there is such a problem in our future, I'd like to be able to explain it to him and not just say "I don't like the way you format your JSDoc"). 解决方案 There is no such thing as an "industry-standard" jsdoc format. There's jsdoc 3 which works in a certain way, and there's jsdoc 2 which works in a similar but different way. There's a jsdoc 1 but I don't know any case of people still using it in production. Then there are tools that try to work jsdoc's markup, more or less successfully.That the asterisks at the beginning of lines have been optional is generally true but is not true in all cases. For instance, if using jsdoc 3 with a Markdown plugin, then: Also, be sure to use leading asterisks in your doc comments! If you omit the leading asterisks, JSDoc's code parser may remove other asterisks that are used for Markdown formatting.So the various versions of jsdoc have not required the leading asterisks but there are some use-case scenarios where the leading asterisks are absolutely required. (I've not found a location in jsdoc 3's documentation that straightforwardly states that the asterisks are optional. The quote above, however, implies that they are.)One thing though, in the question asked here both code snippets begin with /*. All versions of jsdoc, form jsdoc 1 to jsdoc 3 require comments meant to be processed as jsdoc comments to be marked with two or more asterisks at the start like this /**. 这篇关于星号是否对“有效"有效?JSDoc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
05-29 07:24