编译以下代码以使用 JSDoc 3 生成文档时出现错误。如果我删除第一行“user strict”;,那么它可以工作。这是 JSDoc 中的错误,还是我遗漏了什么?
代码:
"use strict";
var BaseClass = require("./BaseClass").BaseClass;
/**
* @class
* @extends BaseClass
*/
var MyClass = BaseClass.extend(
/** @lends MyClass.prototype */
{
/**
* Initializer.
* @public
*/
initialize:function () {
this._id = -1;
},
/**
* Property id
* @public
* @property {number} id
*/
get id() {
return this._id;
},
set id(id) {
this._id = id;
}
});
exports.MyClass = MyClass;
这是我看到的错误:
./jsdoc3/jsdoc -c ./conf.json
js: "/xxx/src/main.js", line 31: Property "id" already defined in this object literal.
js: }
js: ....^
org.mozilla.javascript.EvaluatorException: Compilation produced 1 syntax errors. (/xxx/src/main.js#1)
at org.mozilla.javascript.tools.ToolErrorReporter.runtimeError(ToolErrorReporter.java:144)
at org.mozilla.javascript.Parser.parse(Parser.java:596)
at org.mozilla.javascript.Parser.parse(Parser.java:505)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:247)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18._c_anonymous_24(Unknown Source)
at org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18._c_anonymous_2(Unknown Source)
at org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1._c_main_3(Unknown Source)
at org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
at org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1._c_script_0(Unknown Source)
at org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3178)
at org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.call(Unknown Source)
at org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.exec(Unknown Source)
at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:654)
at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:552)
at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:507)
at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:499)
at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:215)
at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:134)
at org.mozilla.javascript.Context.call(Context.java:521)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:535)
at org.mozilla.javascript.tools.shell.Main.exec(Main.java:198)
at org.mozilla.javascript.tools.shell.Main.main(Main.java:174)
make: *** [docs] Error 1