我需要在 JSDoc 中为教程添加静态资源。 我的项目结构是:
PROJECT ROOT
|
|
---> Project directory A
---> Project directory B
---> ...
|
---> Tutorials
|
|
|
-------->IMG
目录 tutorials/img 包含我想要包含的静态资源。 我的配置文件是:
{
"tags": {
"allowUnknownTags": true,
"dictionaries": [
"jsdoc",
"closure"
]
},
"source": {
"include": [
"modules/abstractModel.js",
"modules/abstractMediator.js",
"modules/abstractTemplate.js",
"modules/abstractView.js",
"modules/modelEvent/modelEvent.js"
],
//"exclude": ["http/httpSession.js", "http/wyPlayWrapper.js", "util/service.js"],
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_"
},
"plugins": [],
"templates": {
"default": {
"staticFiles": {
"include": ["./trunk/tutorials/img/"]
}
}
}
}
这是我用来生成文档的命令行(从 shell 执行到 PROJECT ROOT 目录):
jsdoc -c conf/jsdoc.conf -u tutorials/ -d ./docs . tutorials/README.md --verbose
但是任何静态文件都被导入到 docs 文件夹中,我不能在教程中使用任何图像。任何建议表示赞赏。
最佳答案
该功能似乎有很多错误,至少在 JSDoc 3.3.0-dev 版本(2014 年 6 月 30 日星期一 00:12:06 GMT)中是这样。
首先,正确的语法似乎是:
{
....
"templates": {
"default": {
"staticFiles": {
"paths": ["./tutorials/img/"]
}
}
}
}
然后,在文件 jsdoc/templates/default/publish.js 中,我将 ~525 行从
var sourcePath = fs.toDir(filePath);
到
var sourcePath = fs.toDir(fileName);
这样,来自 tutorials/img 的文件被复制到 docs outdir 本身。这不是最佳解决方案(不复制子目录),但足以满足我的目的。
关于javascript - 将静态文件添加到 JSDoc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30058201/