11
2016
05

使用jsdoc-toolkit实现JS 自动生成API文档

JsDoc Toolkit 是一个把js描述格式化成文档的工具。开发者只需按JsDoc的规范写好注释就可以很方便导出API文档。

该工具由谷歌开发。谷歌code有好多很好的源码,可惜天朝不翻墙访问不了。

点击下载 jsdoc_toolkit-2.4.0.zip

该工具是java开发的,所以需要电脑上安装java虚拟机。

该工具通过命令行来使用,使用方法README.txt中写的很清楚(不要用记事本打开,记事本打开没有换行)。

常用命令:

::获得help信息

java -jar jsrun.jar app/run.js -h

::单个js文件

java -jar jsrun.jar app\run.js -a -t=templates\jsdoc mycode.js

::文件夹下所有js文件

java -jar jsrun.jar app\run.js -a -t=templates\jsdoc "E:\mycode\"

::指定输出目录(默认是命令行运行的目录下的out文件夹)

java -jar jsrun.jar app\run.js -a -t=templates\jsdoc -d="E:\doc" "E:\mycode\"

命令说明:

java -jar jsrun.jar是用命令行运行jar文件,后面的都是传给jsrun.jar的参数,第一个参数是app\run.js,就是app文件夹下的run.js文件,其实所有的功能都是js写的,java只是通过org.mozilla.javascript.tools.debugger.Main来运行js文件。

再后面的参数是通过java文件传给run.js的参数。具体参数如下(通过java -jar jsrun.jar app/run.js -h获取):


USAGE: java -jar jsrun.jar app/run.js [OPTIONS]...

OPTIONS:
  -a or --allfunctions
          Include all functions, even undocumented ones.

  -c or --conf
          Load a configuration file.

  -d=or --directory=Output to this directory (defaults to "out").

  -D="myVar:My value" or --define="myVar:My value"
          Multiple. Define a variable, available in JsDoc as JSDOC.opt.D.myVar.

  -e=or --encoding=Use this encoding to read and write files.

  -E="REGEX" or --exclude="REGEX"
          Multiple. Exclude files based on the supplied regex.

  -h or --help
          Show this message and exit.

  -m or --multiples
          Don't warn about symbols being documented more than once.

  -n or --nocode
          Ignore all code, only document comments with @name tags.

  -o=or --out=Print log messages to a file (defaults to stdout).

  -p or --private
          Include symbols tagged as private, underscored and inner symbols.

  -q or --quiet
          Do not output any messages, not even warnings.

  -r=or --recurse=Descend into src directories.

  -s or --suppress
          Suppress source code output.

  -S or --securemodules
          Use Secure Modules mode to parse source code.

  -t=or --template=Required. Use this template to format the output.

  -T or --test
          Run all unit tests and exit.

  -u or --unique
          Force file names to be unique, but not based on symbol names.

  -v or --verbose
          Provide verbose feedback about what is happening.

  -x=[,EXT]... or --ext=[,EXT]...
          Scan source files with the given extension/s (defaults to js).

  

-t指定模板;-d指定输出目录。



« 上一篇下一篇 »

相关文章:

显示fps  (2020-1-19 9:16:17)

js保留有效数字  (2019-7-30 15:32:12)

js的parseInt方法  (2019-2-15 9:12:44)

闪电效果  (2017-11-28 15:4:19)

js中判断一个对象的类型  (2017-3-30 14:27:35)

解九连环  (2016-12-1 20:58:11)

DataURL与File,Blob,canvas对象之间的互相转换的Javascript  (2016-11-25 14:58:41)

js生成条形码-barcode  (2016-10-12 15:59:51)

GeoJSON格式  (2016-9-23 13:28:44)

使用Typescript开发基于createjs的项目  (2016-8-25 9:54:40)

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。