【发布时间】:2021-12-02 02:21:01
【问题描述】:
我正在尝试获取 jsdoc(版本 3.6.7,使用节点 16)将我记录的 js 代码转换为实际文档,但无论我做什么,它只会生成一个带有索引的 out 目录。 html 主要是空行,而不是文档。我已经在the issue tracker 上询问过这个问题(在我搜索了文档和网络以获取有关让 jsdoc 生成空文件可能做错了什么的信息之后,但我一生都找不到任何有用的东西解决了这个问题)但是由于已经有几天了,所以在这里问也很有用,这样任何一个地方的答案都可以交叉发布。
运行jsdoc 命令不会标记任何输入错误,并以正常的零退出代码完成,但不会产生任何有用的信息,因此希望这里有人遇到过他的问题,并且可以解释除了以下内容之外还需要什么实际获取 jsdoc 生成文档的代码。
根据 jsdoc 没有错误但也没有生成任何文档的代码示例:
import { Errors } from "../errors.js";
import { Models } from "./models.js";
/**
* Several paragraphs of text that explain this class
*
* @class
* @namespace model
*/
export class Model {
/**
* @ignore
*/
static ALLOW_INCOMPLETE = Symbol();
/**
* Also several paragraphs explaining the use of this function.
*
* @static
* @param {*} data
* @param {*} allowIncomplete (must be Model.ALLOW_INCOMPLETE to do anything)
* @returns {*} a model instance
* @throws {*} one of several errors
*/
static create = function (data = undefined, allowIncomplete) {
return Models.create(
this,
data,
allowIncomplete === Model.ALLOW_INCOMPLETE
);
};
/**
* code comment that explains that if you're reading
* this source, you should not be using the constructor,
* but should use the .create factory function instead.
*
* @ignore
*/
constructor(caller, when) {
if (!caller || typeof when !== "number") {
const { name } = this.__proto__.constructor;
throw Errors.DO_NOT_USE_MODEL_CONSTRUCTOR(name);
}
}
}
使用jsdoc test.js 运行此程序会产生一个带有index.html 和test.js.html 文件的out 目录,第一个包含大约30 行“这里没有文档”和样板包装HTML 代码的换行符,第二个包含原始文件源代码也没什么用处。
还需要做什么才能让 jsdoc 在此处实际生成文档?
【问题讨论】:
标签: jsdoc