【发布时间】:2020-09-22 19:21:57
【问题描述】:
我已经开始为我的项目实现 JSDoc,并且根据文档,函数头是这样的:
/**
* @name randomlyGenerateMixedCaseLetterOrSpecialCharacter1
* @description Randomly generates an alphabetic letter from A-Z, a-z or a random special character from the input list of special characters.
* @param {string} inputData - The list of allowable special characters that should be used to randomly select from.
* @param {string} inputMetaData - Not used for this business rule.
* @return {string} Randomly returns a random mixed case letter of the alphabet, or a random special character from the list of allowable special characters.
* @NOTE: OLD implementation.
* @author Seth Hollingsead
* @date 2020/03/05
*/
应该生成一个小表:
-----------------------------------------------------
| Name | Type | Description |
-----------------------------------------------------
| inputData | String | The list of allowable... |
| inputMetaData | String | Not used for this... |
-----------------------------------------------------
但是当我针对这个函数运行 JSDoc 时,它会输出更像这样的东西:
randomlyGenerateMixedCaseLetterOrSpecialCharacter1 Randomly generates an alphabetic letter from A-Z, a-z or a random special character from the input list of special characters. Author: Seth Hollingsead Source: Framework/BusinessRules/Rules/characterGeneration.js, line 18
完全没有@param & @return 标签。
这是完整的功能,减去身体。也许是我声明函数的方式?
/**
* @name randomlyGenerateMixedCaseLetterOrSpecialCharacter1
* @description Randomly generates an alphabetic letter from A-Z, a-z or a random special character from the input list of special characters.
* @param {string} inputData - The list of allowable special characters that should be used to randomly select from.
* @param {string} inputMetaData - Not used for this business rule.
* @return {string} Randomly returns a random mixed case letter of the alphabet, or a random special character from the list of allowable special characters.
* @NOTE: OLD implementation.
* @author Seth Hollingsead
* @date 2020/03/05
*/
export const randomlyGenerateMixedCaseLetterOrSpecialCharacter1 = function(inputData, inputMetaData) {
// ...Function Body...
};
这是我的 jsdoc.json 文件:
{
"source": {
"include": ["src"],
"includePattern": ".js$",
"excludePattern": "{node_modules/|Documentation}"
},
"plugins": ["plugins/markdown"],
"templates": {
"cleverLinks": true,
"monospaceLinks": true
},
"opts": {
"recurse": true,
"destination": "./src/Application/NodeJS-App/Resources/Documentation",
"template": "./jsDocTemplate"
}
}
回顾错误日志,我在这一行没有看到该文件的任何错误。 当然,我确实在其他函数上看到了错误,但这只是因为我没有正确更改标题的格式。例如:(我知道这是不正确的,但这是我知道我仍然需要做的一个例子:)
/**
* @name randomlyGenerateUpperCaseLetterOrSpecialCharacter1
* @description Randomly generates an alphabetic letter from A-Z or a random special character from the input list of special characters.
* @param {[String]} inputData The list of allowable special characters that should be used to randomly select from.
* @param {[String]} inputMetaData Not used for this business rule.
* @return {[String]} Randomly returns a random upper case letter of the alphabet, or a random special character from the list of allowable special characters.
* @NOTE: OLD implementation.
* @author Seth Hollingsead
* @date 2020/03/05
*/
export const randomlyGenerateUpperCaseLetterOrSpecialCharacter1 = function(inputData, inputMetaData) {
// ... function body
};
在上面的标题中,@param {[String]} 应该更改为@param {string},我还有更多的功能要做,我只是想确保在我彻底清除所有功能之前我得到它我的文件。
我得到的错误是这样的:(虽然实际的错误有点冗长)
\src\Framework\BusinessRules\Rules\characterGeneration.js in line 70 with tag title "param" and text "{[String]} inputData The list of allowable special characters that should be used \src\Framework\BusinessRules\Rules\characterGeneration.js in line 70 with tag title "param" and text "{[String]} inputMetaData Not used for this business rule.": Invalid type expression "[ \src\Framework\BusinessRules\Rules\characterGeneration.js in line 70 with tag title "return" and text "{[String]} Randomly returns a random upper case letter of the alphabet, or a random special character
但正如我所说,即使在更正之后,我仍然没有从标签中获得 @param 和 @returns 元信息表。
编辑:版本号:
- npm 版本:6.9.0
- 节点版本:10.16.3
- “jsdoc”:“^3.6.4”,
有什么想法吗?
提前谢谢你!! 干杯并保持安全!
更新:我能够让它适用于我的一个功能,所以我想我现在的问题是为什么它适用于一个功能而不适用于其他功能?
这是我能够使其工作的函数的标题:
/**
* Converts a time interval into a different kind of format.
* @param {integer} deltaTime - A time interval measured in microseconds.
* @param {string} format - The formatting template that should be used to format the time interval.
* @return {string} A time interval formatted according to the input format template string.
* @author Seth Hollingsead
* @date 2020/05/21
*/
function reformatDeltaTime(deltaTime, format) {
// ... function body...
}
另外,当相同的函数头看起来像这样时:
/**
* @name reformatDeltaTime
* @description Converts a time interval into a different kind of format.
* @param {integer} deltaTime - A time interval measured in microseconds.
* @param {string} format - The formatting template that should be used to format the time interval.
* @return {string} A time interval formatted according to the input format template string.
* @author Seth Hollingsead
* @date 2020/05/21
*/
function reformatDeltaTime(deltaTime, format) {
// ...function body
}
它不起作用,但据说JSDocs应该支持@name和@description标签?那么给了什么?我再次重复......为什么一种标题格式而不是另一种?我可以进行任何配置更改以支持带有@name 和@description 标签的标头吗?
【问题讨论】:
标签: javascript node.js ecmascript-6 jsdoc