【问题标题】:Adding static files to JSDoc将静态文件添加到 JSDoc
【发布时间】:2015-05-08 23:31:59
【问题描述】:

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

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

目录 tutorials/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 教程/ -d ./docs 。教程/README.md --详细

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

【问题讨论】:

    标签: javascript jsdoc


    【解决方案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 本身。这不是最好的解决方案(不复制子目录),但对于我的目的来说已经足够了。

    【讨论】:

    • 只是一个更新:看起来他们修复了路径错误。 publish.js 现在包括:// The canonical property name is `include`. We accept `paths` for backwards compatibility // with a bug in JSDoc 3.2.x. 但是,显然仍然无法指定您希望 CSS 文件进入输出目录的子目录。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-19
    • 2013-07-04
    • 2013-01-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多