文章出處
文章列表
在前面的博文中探討自動化工程問題時,寫過基于NodeJS的,使用gulp、grunt的jsdoc插件實現文檔自動化。本文探討基于java環境的自動化實現。
一、Java安裝與環境配置
關于Java的安裝與環境配置,可以參考博文YUI Compressor for Sublime text2
二、jsdoc-tookit下載與使用
下載鏈接:jsdoc-tookit,現在地址可能被墻了,可以通過搜索其它渠道下載。下面完成后,解壓到工作目錄即可。
-> cmd -> 命令行窗口
-> cd到jsdoc-toolkit所在目錄(我的是G:\Workspace\jsdoc-toolkit)
-> windows:java -jar jsrun.jar app\run.js -a -t=templates\jsdoc myTest/myTest.js
Linux:$ java -jar jsrun.jar app/run.js -a -t=templates/jsdoc myTest/myTest.js
-> 運行后生成out(默認)目錄
-> 完成自動化API文檔。
當然myTest.js文件中的注釋需要符合jsDoc規范。 如果我們不想使用默認目錄out,可以通過-d命令來設置。
jsdoc-toolkit相關命令參考:
G:\Workspace\jsdoc-toolkit>java -jar jsrun.jar app\run.js --help USAGE: java -jar jsrun.jar app/run.js [OPTIONS] <SRC_DIR> <SRC_FILE> ... OPTIONS: -a or --allfunctions Include all functions, even undocumented ones. -c or --conf Load a configuration file. -d=<PATH> or --directory=<PATH> 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=<ENCODING> or --encoding=<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. -n or --nocode Ignore all code, only document comments with @name tags. -o=<PATH> or --out=<PATH> 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=<DEPTH> or --recurse=<DEPTH> Descend into src directories. -s or --suppress Suppress source code output. -S or --securemodules Use Secure Modules mode to parse source code. -t=<PATH> or --template=<PATH> 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>[,EXT]... or --ext=<EXT>[,EXT]... Scan source files with the given extension/s (defaults to js).
轉載聲明:
本文標題:使用jsdoc-toolkit實現JS API文檔自動化
本文鏈接:http://www.zuojj.com/archives/1064.html,轉載請注明轉自Benjamin-專注前端開發和用戶體驗
文章列表
全站熱搜