JSDoc 无法在带有 Rollup 的 .MJS 文件中工作
JSDoc not working in .MJS file with Rollup
我有以下...
/**
* Represents a base element
* @extends HTMLElement
* @constructor
*/
export class Base extends HTMLElement {
...
}
当我运行...
jsdoc src/jrg-base-element.mjs
然后我得到...
There are no input files to process.
我尝试了 --debug
并且得到了...
{"env":{"conf":{"plugins":[],"recurseDepth":10,"source":{"includePattern":".+\.js(doc|x)?$","excludePattern":"(^|\/|\)"},"sourceType":"module","tags":{"allowUnknownTags":true,"dictionaries":["jsdoc","closure"]},"templates":{"monospaceLinks":false,"cleverLinks":false,"default":{"outputSourceFiles":true}}},"opts":{"":["src/jrg-base-element.mjs"],"debug":true,"destination":"./out/","encoding":"utf8"}}}
这似乎接近于(The error message "There are no input files to process" from jsdoc),但我不知道该怎么做。
有什么想法吗?
我自己试了一下:
安装 JSDoc:
npm install -g jsdoc => OK
创建一个虚拟文件,src/x.js:
/**
* Represents a base element
* @extends HTMLElement
* @constructor
*/
function hello () {
console.log ('Hello world!');
}
运行 jsdoc src
查看结果(默认目录"out/"
):
换句话说:
a) 您可以指定一个 JS 文件,但您通常会指定一个 JS 包目录。
b) 默认情况下,JSDoc 不识别“.mjs”
建议:
指定配置文件,编辑source.includePatter=n
:
https://jsdoc.app/about-configuring-jsdoc.html#specifying-input-files
Specifying input files
The source set of options, in combination with paths given to JSDoc on
the command line, determines the set of input files that JSDoc uses to
generate documentation.
{
"source": {
"include": [ /* array of paths to files to generate documentation for */ ],
"exclude": [ /* array of paths to exclude */ ],
"includePattern": ".+\.js(doc|x)?$",
"excludePattern": "(^|\/|\\)_"
}
}
- source.include: An optional array of paths that contain files for which JSDoc should generate documentation. The paths given to JSDoc on
the command line are combined with these paths. You can use the -r
command-line option to recurse into subdirectories.
- source.exclude: An optional array of paths that JSDoc should ignore. In JSDoc 3.3.0 and later, this array may include subdirectories of the
paths in source.include.
- source.includePattern: An optional string, interpreted as a regular expression. If present, all filenames must match this regular
expression to be processed by JSDoc. By default, this option is set to
".+.js(doc|x)?$", meaning that only files with the extensions .js,
.jsdoc, and .jsx will be processed.
- source.excludePattern: An optional string, interpreted as a regular expression. If present, any file matching this regular expression
will be ignored. By default, this option is set so that files
beginning with an underscore (or anything under a directory beginning
with an underscore) is ignored.
祝你好运 - 请 post 找回你找到的东西!
我有以下...
/**
* Represents a base element
* @extends HTMLElement
* @constructor
*/
export class Base extends HTMLElement {
...
}
当我运行...
jsdoc src/jrg-base-element.mjs
然后我得到...
There are no input files to process.
我尝试了 --debug
并且得到了...
{"env":{"conf":{"plugins":[],"recurseDepth":10,"source":{"includePattern":".+\.js(doc|x)?$","excludePattern":"(^|\/|\)"},"sourceType":"module","tags":{"allowUnknownTags":true,"dictionaries":["jsdoc","closure"]},"templates":{"monospaceLinks":false,"cleverLinks":false,"default":{"outputSourceFiles":true}}},"opts":{"":["src/jrg-base-element.mjs"],"debug":true,"destination":"./out/","encoding":"utf8"}}}
这似乎接近于(The error message "There are no input files to process" from jsdoc),但我不知道该怎么做。
有什么想法吗?
我自己试了一下:
安装 JSDoc:
npm install -g jsdoc => OK
创建一个虚拟文件,src/x.js:
/** * Represents a base element * @extends HTMLElement * @constructor */ function hello () { console.log ('Hello world!'); }
运行
jsdoc src
查看结果(默认目录
"out/"
):
换句话说:
a) 您可以指定一个 JS 文件,但您通常会指定一个 JS 包目录。
b) 默认情况下,JSDoc 不识别“.mjs”
建议:
指定配置文件,编辑source.includePatter=n
:
https://jsdoc.app/about-configuring-jsdoc.html#specifying-input-files
Specifying input files
The source set of options, in combination with paths given to JSDoc on the command line, determines the set of input files that JSDoc uses to generate documentation.
{ "source": { "include": [ /* array of paths to files to generate documentation for */ ], "exclude": [ /* array of paths to exclude */ ], "includePattern": ".+\.js(doc|x)?$", "excludePattern": "(^|\/|\\)_" } }
- source.include: An optional array of paths that contain files for which JSDoc should generate documentation. The paths given to JSDoc on the command line are combined with these paths. You can use the -r command-line option to recurse into subdirectories.
- source.exclude: An optional array of paths that JSDoc should ignore. In JSDoc 3.3.0 and later, this array may include subdirectories of the paths in source.include.
- source.includePattern: An optional string, interpreted as a regular expression. If present, all filenames must match this regular expression to be processed by JSDoc. By default, this option is set to ".+.js(doc|x)?$", meaning that only files with the extensions .js, .jsdoc, and .jsx will be processed.
- source.excludePattern: An optional string, interpreted as a regular expression. If present, any file matching this regular expression will be ignored. By default, this option is set so that files beginning with an underscore (or anything under a directory beginning with an underscore) is ignored.
祝你好运 - 请 post 找回你找到的东西!