Skip to main content

JSDoc generator in Gaia

· 2 min read

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/ .

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.