mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 10:00:18 +02:00
Add jsdoc readme and plugin
This commit is contained in:
parent
666d2dd2fc
commit
5b244357e0
5 changed files with 73 additions and 0 deletions
1
scripts/jsdoc/.gitignore
vendored
Normal file
1
scripts/jsdoc/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
out
|
13
scripts/jsdoc/README.md
Normal file
13
scripts/jsdoc/README.md
Normal 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
|
8
scripts/jsdoc/config.json
Normal file
8
scripts/jsdoc/config.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"templates": {
|
||||||
|
"default": {
|
||||||
|
"outputSourceFiles": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"plugins": ["plugins/hifi"]
|
||||||
|
}
|
40
scripts/jsdoc/plugins/hifi.js
Normal file
40
scripts/jsdoc/plugins/hifi.js
Normal 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
11
scripts/jsdoc/root.js
Normal 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
|
||||||
|
//
|
||||||
|
|
Loading…
Reference in a new issue