Javascript 带ant的JS文档

Javascript 带ant的JS文档,javascript,ant,Javascript,Ant,我正试图让ant运行我的jsdoc工具包。在我从站点上的创建build.xml后,我最终得到以下结果: <taskdef name="jsdoctoolkit" classname="uk.co.darrenhurley.ant.tasks.JsDocToolkit" classpath="/jsdoc/jsrun.jar;/jsdoc/java/classes/js.jar"/> 由于我现在是java开发人员,我只能猜测我的类名(取自网站)是不正确的。但我现在知道用什么来代替它了

我正试图让ant运行我的jsdoc工具包。在我从站点上的创建build.xml后,我最终得到以下结果:

<taskdef name="jsdoctoolkit" classname="uk.co.darrenhurley.ant.tasks.JsDocToolkit" classpath="/jsdoc/jsrun.jar;/jsdoc/java/classes/js.jar"/>
由于我现在是java开发人员,我只能猜测我的类名(取自网站)是不正确的。但我现在知道用什么来代替它了


有人能帮我吗?

你现在的假设可能不正确。您遇到的XML错误告诉您,解析器在XML结构中的错误位置遇到了您的
元素。事实上,在这一点上,它甚至没有时间查看元素本身,因此您的
classname
属性不成问题

正如Pointy所说,尝试发布整个XML,或者至少自己查看一下,并检查
元素的位置是否正确。它需要位于
标记的顶层。如果将其嵌套在其他元素中,则这是无效的,并且无法工作

通常,您的构建文件可能如下所示:

<project name="MyProject" default="dist" basedir=".">
    <description>
        simple example build file
    </description>
  <!-- set global properties for this build -->
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist"  location="dist"/>

  <taskdef name="jsdoctoolkit" classname="uk.co.darrenhurley.ant.tasks.JsDocToolkit" classpath="/jsdoc/jsrun.jar;/jsdoc/java/classes/js.jar"/>

  <!-- Rest of file... -->

构建文件的简单示例

在所有情况下,如果您将
taskdef
行从现在的位置移动到文件顶部
行的正下方,我希望这会解决您的问题。

我也没有太多运气尝试让jsdoctoolkit任务正常工作。幸运的是,直接从Ant运行JSDoc工具包而不使用任务非常容易

<property name="source.dir" value="source" />
<property name="doc.dir" value="docs" />

<property name="tool.dir" value="tools" />

<property name="jsdoctoolkit.dir" value="${tool.dir}/jsdoc_toolkit-2.4.0/jsdoc-toolkit" />


<target name="docs" description="Generates documentation">
    <sequential>
        <delete dir="${doc.dir}"/>
        <mkdir dir="${doc.dir}" />

        <echo message="Running JSDoc Toolkit"/>

        <!-- The java exe is told to run in the dir where our source files reside.
                 If we instead ran it from the dir that the build file is in and gave it
                 full paths to the source files the documentation would include the full
                 filesystem paths (c:\path\to\source\) instead of relative ones.
                 Since this command is running in the source dir, all of the paths
                 given to it must first traverse down a level (../) to get back to the
                 build file dir.
        -->
        <exec executable="java" dir="${source.dir}">
            <arg line="-jar ../${jsdoctoolkit.dir}/jsrun.jar ../${jsdoctoolkit.dir}/app/run.js" />
            <!-- -d tells JSDoc toolkit where to output the documentation -->
            <arg line="-d=../${doc.dir}" />
            <!-- use the default template -->
            <arg line="-t=../${jsdoctoolkit.dir}/templates/jsdoc" />
            <!-- Create an arg element for each file you want to include in the documentation -->
            <arg line="my-javascript-file.js" />
            <arg line="another-javascript-file.js" />
            <arg line="subdir/yet-another-javascript-file.js" />
        </exec>
    </sequential>
</target>

你能发布所有build.xml吗?或者至少是你做这件事的地方?
<property name="source.dir" value="source" />
<property name="doc.dir" value="docs" />

<property name="tool.dir" value="tools" />

<property name="jsdoctoolkit.dir" value="${tool.dir}/jsdoc_toolkit-2.4.0/jsdoc-toolkit" />


<target name="docs" description="Generates documentation">
    <sequential>
        <delete dir="${doc.dir}"/>
        <mkdir dir="${doc.dir}" />

        <echo message="Running JSDoc Toolkit"/>

        <!-- The java exe is told to run in the dir where our source files reside.
                 If we instead ran it from the dir that the build file is in and gave it
                 full paths to the source files the documentation would include the full
                 filesystem paths (c:\path\to\source\) instead of relative ones.
                 Since this command is running in the source dir, all of the paths
                 given to it must first traverse down a level (../) to get back to the
                 build file dir.
        -->
        <exec executable="java" dir="${source.dir}">
            <arg line="-jar ../${jsdoctoolkit.dir}/jsrun.jar ../${jsdoctoolkit.dir}/app/run.js" />
            <!-- -d tells JSDoc toolkit where to output the documentation -->
            <arg line="-d=../${doc.dir}" />
            <!-- use the default template -->
            <arg line="-t=../${jsdoctoolkit.dir}/templates/jsdoc" />
            <!-- Create an arg element for each file you want to include in the documentation -->
            <arg line="my-javascript-file.js" />
            <arg line="another-javascript-file.js" />
            <arg line="subdir/yet-another-javascript-file.js" />
        </exec>
    </sequential>
</target>
build.xml
docs/
source/
    my-javascript-file.js
    another-javascript-file.js
    subdir/
        yet-another-javascript-file.js
tools/
    jsdoc_toolkit-2.4.0/
        jsdoc-toolkit/
            jsrun.js
            app/
                run.js