jsdoc-toolkit算是google推薦的JavaScript document generator,您可以在 http://code.google.com/p/jsdoc-toolkit/downloads/list下載。
由於jsdoc-toolkit是用java寫的,所以請先安裝好java,Windows底下執行命令把"/"改成"\"就可以了,執行java -jar jsrun.jar app\run.js -a -t=templates\jsdoc mycode.js就可以產生mycode.js的文件檔了,這部分可以參考裡面的README.txt,預設會將document寫到out目錄中。
手邊剛好有extjs,所以直接拿ext-all-debug.js當測試,卻得到exception from uncaught JavaScript throw: java.lang.OutOfMemoryError: Java heap space的錯誤。這導因於heap不夠,可透過設定Xmx解決(請參考後面說明)。
執行java -jar jsrun.jar app/run.js --help 可以獲取更多資訊。
brook@debian:~/jsdoc_toolkit-2.3.0/$ java -Xmx1024m -Xms512m -jar jsrun.jar app/run.js -a -v -t=templates/jsdoc/ ext/adapter/ext/ext-base.js ... 省略 ... brook@debian:~/jsdoc_toolkit-2.3.0/$ java -jar jsrun.jar app/run.js --help USAGE: java -jar jsrun.jar app/run.js [OPTIONS]out of memory.... 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. -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).
看到java.lang.OutOfMemoryError就是要加大記憶體空間啦,java 程式有-Xms跟-Xmx參數可以用。
-Xms Setting minimum heap size
-Xmx Setting maximum heap size
心得:感覺jsdoc-toolkit還是很陽春,而且很耗記憶體和CPU,感覺很慢,常常讓人以為當機了。不知道哪邊有像ext-js的document一樣漂亮的工具。
沒有留言:
張貼留言