将静态文件添加到JSDoc

时间:2015-05-05 16:15:02

标签: javascript jsdoc

我需要为JSDoc中的教程添加静态资源。 我的项目结构是:

PROJECT ROOT 
| 
|
---> Project directory A
---> Project directory B
---> ...
|
---> Tutorials
     |
     |
     |
     -------->IMG

目录教程/ img包含我想要包含的静态资源。 我的conf文件是:

{
  "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。教程/ README.md   --verbose

但是任何静态文件都会导入到docs文件夹中,我无法在教程中使用任何图像。任何建议都表示赞赏。

1 个答案:

答案 0 :(得分:1)

该功能似乎非常多,至少在发布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本身。它不是最好的解决方案(子目录没有被复制),但它足以满足我的目的。

相关问题