蓋索林 Gasolin

人們總是高估一年可以完成的事,卻低估十年能完成的事

0%

JSDoc generator in Gaia

Last week I’ve post on dev-gaia to notice the change of JSDoc generator.

Now gaia’s jsdoc generator takes standard jsdoc config format from each app’s jsdoc.json file. And app owner could customize its look and feel if they prefer to do so. http://usejsdoc.org/about-configuring-jsdoc.html

Here’s the working jsdoc for Firefox OS settings app http://gasolin.github.io/gaia/settings/ .

[![](http://4.bp.blogspot.com/-diJKPL8ynts/VXUCIo35OBI/AAAAAAAAD5k/JG59TzUcjHI/s400/%25E8%259E%25A2%25E5%25B9%2595%25E5%25BF%25AB%25E7%2585%25A7%2B2015-06-08%2B%25E4%25B8%258A%25E5%258D%258810.46.21.png)](http://4.bp.blogspot.com/-diJKPL8ynts/VXUCIo35OBI/AAAAAAAAD5k/JG59TzUcjHI/s1600/%25E8%259E%25A2%25E5%25B9%2595%25E5%25BF%25AB%25E7%2585%25A7%2B2015-06-08%2B%25E4%25B8%258A%25E5%258D%258810.46.21.png)

The trick is done by gulp and shell commands, which can be apply on any other projects. Here’s how I did it.

First of all is install required packages

$ npm install gulp gulp-shell jsdoc --save-dev Then open gulpfile.js and add following scripts:

var gulp = require(‘gulp’); var shell = require(‘gulp-shell’);

gulp.task(‘jsdoc’, shell.task([   ‘./node_modules/jsdoc/jsdoc.js -c jsdoc.json’ ])); (It’s an simplified version because gaia contains 20+ web apps in it, so I add some tree-walking code to create bunch of gulp tasks. But basically its the same) The simplified version is now available for reuse in webapplate.

Bonus section:

Here’s how I upload jsdoc (http://gasolin.github.io/gaia/settings/ , http://gasolin.github.io/gaia/system/) to github gh pages.

Add another section in gulpfile.js with following script

var gulp = require(‘gulp’); var ghPages = require(‘gulp-gh-pages’);

gulp.task(‘github’, [‘jsdoc’], function() {   return gulp.src(’./docs/**/*’)     .pipe(ghPages()); }); Run gulp github command and the build tool will generate jsdoc and upload to github page automatically.