Add jsdoc readme and plugin

This commit is contained in:
Anthony J. Thibault 2016-11-09 18:03:42 -08:00
parent 666d2dd2fc
commit 5b244357e0
5 changed files with 73 additions and 0 deletions

1
scripts/jsdoc/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
out

13
scripts/jsdoc/README.md Normal file
View file

@ -0,0 +1,13 @@
#JavaScript Documentation Generation
##Prerequisites
* Install node.js
* Install jsdoc via npm. `npm install jsdoc -g`
To generate html documentation for the High Fidelity JavaScript API
`cd scripts/jsdoc`
`jsdoc . -c config.json`
The out folder should contain index.html

View file

@ -0,0 +1,8 @@
{
"templates": {
"default": {
"outputSourceFiles": false
}
},
"plugins": ["plugins/hifi"]
}

View file

@ -0,0 +1,40 @@
function endsWith(path, exts) {
var result = false;
exts.forEach(function(ext) {
if (path.endsWith(ext)) {
result = true;
}
});
return result;
}
exports.handlers = {
beforeParse: function(e) {
console.log("Scanning hifi source for jsdoc comments...");
// directories to scan for jsdoc comments
var dirList = [
'../../interface/src',
'../../libraries/script-engine/src',
'../../libraries/networking/src',
'../../libraries/animation/src'
];
var exts = ['.h', '.cpp'];
const fs = require('fs');
dirList.forEach(function (dir) {
var files = fs.readdirSync(dir)
files.forEach(function (file) {
var path = dir + "/" + file;
if (fs.lstatSync(path).isFile() && endsWith(path, exts)) {
var data = fs.readFileSync(path, "utf8");
var reg = /(\/\*\*jsdoc(.|[\r\n])*?\*\/)/gm;
var matches = data.match(reg);
if (matches) {
e.source += matches.map(function (s) { return s.replace('/**jsdoc', '/**'); }).join('\n');
}
}
});
});
}
};

11
scripts/jsdoc/root.js Normal file
View file

@ -0,0 +1,11 @@
//
// root.js
//
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// Root of High Fidelity generated java script documentation
//