angular - TypeDoc ไม่สามารถค้นหาโมดูล Angular2 ได้
ฉันกำลังพยายามสร้างไฟล์ doc โดยใช้ TypeDoc เมื่อฉันรัน 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. ไหม?
คำตอบ #1
ฉันลองใช้โมดูล commonjs และมันก็ใช้ได้
typedoc --experimentalDecorators --target 'es5' --module 'commonjs' --out doc-destination/ src/
คำตอบ #2
ฉันใช้ 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,
}));
});
หวังว่านี่จะช่วยได้
