使用教程时,jaguarjs-jsdoc因ReferenceError而失败

时间:2014-10-23 15:27:40

标签: templates jsdoc

当我使用juaguarjs作为模板运行jsdoc作为模板时,我收到错误ReferenceError: filename is not defined

以下情况不会有错误:   - 我用它的默认模板运行jsdoc   - 我用jaguarjs模板运行jsdoc但没有教程配置

项目结构

|-- tut
|     |-- tut1.md
|     +--tut1.json
|-- jsdocconf.json
+-- Gruntfile.js

tut1.md

# Title 1
Text text text

tut1.json

{
    "title": "Tutorial 1"
}

jsdocconf.json

{
    "tags": {
        "allowUnknownTags" : true
    },
    "templates": {
        "cleverLinks": true,
        "monospaceLinks": true,
        "default": {
            "outputSourceFiles" : true
        },
        "applicationName": "SaphirJS",
        "disqus": "",
        "googleAnalytics": "",
        "linenums": false
    }
}

Gruntfile.js

jsdoc: {
    all: {
        src: [
            './src/main/js/**/*.js',
        ],
        options: {
            destination: 'doc',
            tutorials: './tut',
            template : "node_modules/jaguarjs-jsdoc",
            configure : "jsdocconf.json",
        },
    }
},

完整的错误堆栈如下:

>> An error occurs in jsdoc process:
>> org.mozilla.javascript.EcmaError: ReferenceError: "filename" is not defined. (<eval'ed string>#1(Function)#51)
>>  at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3785)
>>  at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3763)
>>  at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3848)
>>  at org.mozilla.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1847)
>>  at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1786)
>>  at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1780)
>>  at script.anonymous(<eval'ed string>#1(Function):51)
>>  at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
>>  at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
>>  at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2521)
>>  at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:300)
>>  at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
>>  at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_node_modules_underscore_underscore_js_21._c_anonymous_141(Unknown Source)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_node_modules_underscore_underscore_js_21.call(Unknown Source)
>>  at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2521)
>>  at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:300)
>>  at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
>>  at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_lib_jsdoc_template_js_50._c_anonymous_3(Unknown Source)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_lib_jsdoc_template_js_50.call(Unknown Source)
>>  at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_lib_jsdoc_template_js_50._c_anonymous_4(Unknown Source)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_lib_jsdoc_template_js_50.call(Unknown Source)
>>  at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_jaguarjs_jsdoc_publish_js_49._c_generateTutorial_33(Unknown Source)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_jaguarjs_jsdoc_publish_js_49.call(Unknown Source)
>>  at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_jaguarjs_jsdoc_publish_js_49._c_anonymous_35(Unknown Source)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_jaguarjs_jsdoc_publish_js_49.call(Unknown Source)
>>  at org.mozilla.javascript.NativeArray.iterativeMethod(NativeArray.java:1563)
>>  at org.mozilla.javascript.NativeArray.execIdCall(NativeArray.java:345)
>>  at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
>>  at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_jaguarjs_jsdoc_publish_js_49._c_saveChildren_34(Unknown Source)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_jaguarjs_jsdoc_publish_js_49.call(Unknown Source)
>>  at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_jaguarjs_jsdoc_publish_js_49._c_anonymous_23(Unknown Source)
>>  at org.mozilla.javascript.gen.file__home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_jaguarjs_jsdoc_publish_js_49.call(Unknown Source)
>>  at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
>>  at org.mozilla.javascript.gen._home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_jsdoc_js_1._c_main_3(Unknown Source)
>>  at org.mozilla.javascript.gen._home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_jsdoc_js_1.call(Unknown Source)
>>  at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
>>  at org.mozilla.javascript.gen._home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_jsdoc_js_1._c_script_0(Unknown Source)
>>  at org.mozilla.javascript.gen._home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_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._home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_jsdoc_js_1.call(Unknown Source)
>>  at org.mozilla.javascript.gen._home_younes_ouadi_Workspace_Dev_Web_SaphirJS_doc_node_modules_grunt_jsdoc_node_modules_jsdoc_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)

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,并解决了它。

eval'd字符串由下划线的模板方法评估。这用于解释&lt; ? js =在jaguarjs-jsdoc中使用的模板内进行模板化(请参阅tmpl目录中的文件)。

检查这些文件后,您会看到layout.tmpl使用(未绑定)变量文件名。这个变量,作为下划线的模板的方法的文档教给我们,将被传递给生成的方法的对象上的同名属性填充。 在查看jaguarjs-jsdoc的publish.js时,您会注意到作为渲染方法调用的最终参数传递的对象具有为非教程渲染设置的文件名属性。在教程渲染中,未设置此文件名属性。只需将其添加到在publish.js:493周围定义的tutorialData对象即可。我只是向他们提出一个问题。