我正在尝试使用TypeDoc生成文档文件。当我使用 follwing 命令运行 TypeDoc 时:
/node_modules/.bin/typedoc --module system --target ES5 --exclude *.spec.ts* --experimentalDecorators --out typedoc app/ --ignoreCompilerErrors
它作为输出给出:
Using TypeScript 1.6.2 from /development/node_modules/typedoc/node_modules/typescript/lib
Error: /development/app/angular2/app.ts(1)
Cannot find module 'angular2/core'.
Error: /development/app/angular2/app.ts(2)
Cannot find module 'angular2/upgrade'.
Error: /development/app/angular2/app.ts(3)
Cannot find module 'angular2/platform/browser'.
Error: /development/app/angular2/app.ts(5)
tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules"
]
}
我这里是否缺少某种参数来包含库或.d.ts.
文件?
我尝试使用 commonjs 模块,它起作用了。
typedoc --experimentalDecorators --target 'es5' --module 'commonjs' --out doc-destination/ src/
我将typedoc与angular2应用程序一起使用。虽然我通过 gulp-typedoc 运行它,但传递的参数应该是相同的。以下 gulp 任务为我完成了这项工作:
gulp.task("doc", function() {
return gulp
.src(["./myproject/**/*.ts"])
.pipe(typedoc({
// TypeScript options (see typescript docs)
module: "commonjs",
target: "es5",
includeDeclarations: false,
experimentalDecorators: true,
// Output options (see typedoc docs)
out: "./docs",
// TypeDoc options (see typedoc docs)
name: "MyProject",
ignoreCompilerErrors: false,
excludeExternals:true,
version: true,
}));
});
希望这有帮助。
在 tsconfig.json 中添加类型定义文件的配置并尝试
"typeRoots": [
"node_modules/@types" ]