From 9773b928ac57e0f39ecae029a0287d4f2351cadd Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Sat, 28 Apr 2018 00:25:07 -0700 Subject: [PATCH 01/10] copying to dir working --- tools/jsdoc/gravPrep.js | 272 ++++++++++++++++++++++++++++++++++++ tools/jsdoc/package.json | 6 +- tools/jsdoc/plugins/hifi.js | 12 +- 3 files changed, 283 insertions(+), 7 deletions(-) create mode 100644 tools/jsdoc/gravPrep.js diff --git a/tools/jsdoc/gravPrep.js b/tools/jsdoc/gravPrep.js new file mode 100644 index 0000000000..634f529891 --- /dev/null +++ b/tools/jsdoc/gravPrep.js @@ -0,0 +1,272 @@ +const htmlclean = require('htmlclean'); +const fs = require('fs'); +const path = require('path'); +const pretty = require('pretty'); +const cheerio = require('cheerio'); +const rimraf = require('rimraf'); + +// required directories +let dir_out = path.join(__dirname, 'out'); + +let dir_grav = path.join(dir_out, 'grav'); +let dir_css = path.join(dir_grav, 'css'); +let dir_js = path.join(dir_grav, 'js'); +let dir_twig = path.join(dir_grav, 'templates'); + +let dir_md = path.join(dir_grav, '06.api-reference'); +let dir_md_classes = path.join(dir_md, 'Objects'); +let dir_md_namespaces = path.join(dir_md, 'Namespaces'); +let dir_md_globals = path.join(dir_md, 'Globals'); + +// maps for sorting +let map_dir_md = { + "Class": dir_md_classes, + "Namespace": dir_md_namespaces, + "Global": dir_md_globals +} + +// html variables to be replaced +const html_reg_static = /\(static)\<\/span>/g; +const html_reg_title = /\.+?\<\/h1\>/g; +const html_reg_htmlExt = /\.html/g; + +// remove grav directory if exists to make sure old files aren't kept +if (fs.existsSync(dir_grav)){ + console.log("dir_grav exists"); + rimraf.sync(dir_grav); +} + +// array to itterate over and create if doesn't exist +let dirArray = [dir_grav, dir_css, dir_js, dir_twig, dir_md, dir_md_classes, dir_md_namespaces, dir_md_globals]; + +dirArray.forEach(function(dir){ + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } +}) + +// read jsdoc output folder + +/* + +let files = fs.readdirSync(dir_out); +files.forEach(function (file){ + let curSource = path.join(dir_out, file); + if (path.extname(curSource) == ".html") { + + // clean up the html source + + let loadedHtml = prepareHtml(curSource); + + // extract the title and the main div + + let splitTile = loadedHtml("title").text().split(": "); + let groupName = splitTitle[0]; + let htmlTitle = splitTile.pop(); + console.log(groupName); + // let mainDiv = loadedHtml("#main").html(); + // let mainDivNoTitle = mainDiv.replace(/\.+?\<\/h1\>/g, ""); + // let mainDivStripLinks = mainDivNoTitle.replace(/\.html/g, ""); + + // create the .md file and corresponding folder + + // let mdSource = makeMdSource(htmlTitle); + // let destinationDirectory = path.join(dir_md, htmlTitle); + // if (!fs.existsSync(destinationDirectory)) { + // fs.mkdirSync(destinationDirectory); + // } + // let destinationMDFile = path.join(destinationDirectory, `API_${htmlTitle}.md`); + // fs.writeFileSync(destinationMDFile, mdSource); + + // create the twig template + + // let twigBasePartial = makeTwigFile(mainDivStripLinks); + // let destinationFile = path.join(dir_twig, `API_${htmlTitle}.html.twig`); + // fs.writeFileSync(destinationFile, twigBasePartial); + } +}) + +*/ + +let curSource = path.join(dir_out, "Camera.html"); + +// clean up the html source + +let loadedHtml = prepareHtml(curSource); + +// extract the title, groupename, and the main div + +let splitTitle = loadedHtml("title").text().split(": "); +let groupName = splitTitle[1]; +let htmlTitle = splitTitle.pop(); +console.log("groupname:", groupName); +console.log("htmlTitle:", htmlTitle); + +// strip out undesired regex +let mainDiv = loadedHtml("#main").html(); +let mainDivRegexed = mainDiv.replace(html_reg_static,"") + .replace(html_reg_title,"") + .replace(html_reg_htmlExt,"") + +// create the .md file and corresponding folder + +console.log(map_dir_md[groupName]); +let mdSource = makeMdSource(htmlTitle); +let destinationDirectory = path.join(map_dir_md[groupName], htmlTitle); +if (!fs.existsSync(destinationDirectory)) { + fs.mkdirSync(destinationDirectory); +} +let destinationMDFile = path.join(destinationDirectory, `API_${htmlTitle}.md`); +fs.writeFileSync(destinationMDFile, mdSource); + +// create the twig template + +let twigBasePartial = makeTwigFile(mainDivRegexed); +let destinationFile = path.join(dir_twig, `API_${htmlTitle}.html.twig`); +fs.writeFileSync(destinationFile, twigBasePartial); + +function prepareHtml(source){ + let htmlBefore = fs.readFileSync(source, {encoding: 'utf8'}); + let htmlAfter = htmlclean(htmlBefore); + let htmlAfterPretty = pretty(htmlAfter); + return cheerio.load(htmlAfterPretty); +} + +function makeMdSource(title){ + return ( +`--- +title: '${title}' +taxonomy: + category: + - docs +visible: true +--- +` + ) +} + +function makeTwigFile(contentHtml){ + return ( +` +{% extends 'partials/base_noGit.html.twig' %} +{% set tags = page.taxonomy.tag %} +{% if tags %} + {% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs', 'tag': tags}},'order': {'by': 'default', 'dir': 'asc'}}) %} +{% else %} + {% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs'}},'order': {'by': 'default', 'dir': 'asc'}}) %} +{% endif %} + +{% block navigation %} + +{% endblock %} + +{% block content %} +
+

{{ page.title }}

+ ${contentHtml} +
+{% endblock %} +` + ) +} + +let targertTwigDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav/user/themes/learn2/"; +let targetMDDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav-content/"; + +let chapterMD = +`--- +title: 'High Fidelity API Reference' +taxonomy: + category: + - docs +--- + +### + +# API Reference + +**Under Construction**: We're currently working on creating an API Reference where you can access functions and events easily. + +Check out our latest API Reference here. We're doing our best to keep this reference up-to-date with each release. If you don't find information you are looking for, contact us at [docs@highfidelity.io](mailto:docs@highfidelity.io). + +` + +// Copy files to the Twig Directory +let files = fs.readdirSync(path.resolve(targertTwigDirectory)); +files.forEach(function(file){ + let curSource = path.join(targertTwigDirectory, file); + if(path.basename(file, '.html').indexOf("API") > -1){ + fs.unlink(curSource); + } +}) + +copyFolderRecursiveSync(dir_twig, targertTwigDirectory); + +// Copy files to the Md Directory + +let baseMdRefDir = path.join(targetMDDirectory,"06.api-reference"); + +if (fs.existsSync(targetMDDirectory)){ + rimraf.sync(baseMdRefDir); +} + +copyFolderRecursiveSync(dir_md, targetMDDirectory); +let chapterDestinationFile = path.join(baseMdRefDir, `chapter.md`); +fs.writeFileSync(chapterDestinationFile, chapterMD); + + +// helper functions +function copyFileSync( source, target ) { + console.log("sourece:" + source); + let targetFile = target; + + //if target is a directory a new file with the same name will be created + if ( fs.existsSync( target ) ) { + console.log("target exists"); + if ( fs.lstatSync( target ).isDirectory() ) { + console.log("target is a directory"); + + targetFile = path.join( target, path.basename( source ) ); + console.log("targetFile:" + targetFile); + + } + } + + fs.writeFileSync(targetFile, fs.readFileSync(source)); +} + +function copyFolderRecursiveSync( source, target ) { + var files = []; + + //check if folder needs to be created or integrated + console.log("target:" + target) + console.log("source:" + source) + console.log("basename source:" + path.basename( source )) + + var targetFolder = path.join( target, path.basename( source ) ); + console.log("targetFolder:" + targetFolder); + if ( !fs.existsSync( targetFolder ) ) { + fs.mkdirSync( targetFolder ); + } + + //copy + if ( fs.lstatSync( source ).isDirectory() ) { + files = fs.readdirSync( source ); + files.forEach( function ( file ) { + var curSource = path.join( source, file ); + if ( fs.lstatSync( curSource ).isDirectory() ) { + copyFolderRecursiveSync( curSource, targetFolder ); + } else { + copyFileSync( curSource, targetFolder ); + } + } ); + } +} diff --git a/tools/jsdoc/package.json b/tools/jsdoc/package.json index 215ceec177..d921762f72 100644 --- a/tools/jsdoc/package.json +++ b/tools/jsdoc/package.json @@ -1,7 +1,11 @@ { "name": "hifiJSDoc", "dependencies": { - "jsdoc": "^3.5.5" + "cheerio": "^1.0.0-rc.2", + "htmlclean": "^3.0.8", + "jsdoc": "^3.5.5", + "pretty": "^2.0.0", + "rimraf": "^2.6.2" }, "private": true } diff --git a/tools/jsdoc/plugins/hifi.js b/tools/jsdoc/plugins/hifi.js index 7c643d398c..b34247bd29 100644 --- a/tools/jsdoc/plugins/hifi.js +++ b/tools/jsdoc/plugins/hifi.js @@ -94,19 +94,19 @@ exports.handlers = { if (e.doclet.hifiInterface) { rows.push("Interface Scripts"); } - if (e.doclet.hifiAssignmentClient) { - rows.push("Assignment Client Scripts"); - } if (e.doclet.hifiClientEntity) { rows.push("Client Entity Scripts"); } if (e.doclet.hifiServerEntity) { rows.push("Server Entity Scripts"); } + if (e.doclet.hifiAssignmentClient) { + rows.push("Assignment Client Scripts"); + } // Append an Available In: table at the end of the namespace description. if (rows.length > 0) { - var table = "

Available In:" + rows.join("") + "
"; + var table = "

Available in:" + rows.join("") + "
"; e.doclet.description = e.doclet.description + table; } } @@ -124,7 +124,7 @@ exports.defineTags = function (dictionary) { }); // @hifi-assignment-client - dictionary.defineTag("hifi-assigment-client", { + dictionary.defineTag("hifi-assignment-client", { onTagged: function (doclet, tag) { doclet.hifiAssignmentClient = true; } @@ -143,4 +143,4 @@ exports.defineTags = function (dictionary) { doclet.hifiServerEntity = true; } }); -}; +}; \ No newline at end of file From 9db67229b93e72950b7441042ae3b5f87076f494 Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Sat, 28 Apr 2018 09:29:16 -0700 Subject: [PATCH 02/10] Name groupings working correctly, pre-adding ctrlAtlDavid's new tags --- tools/jsdoc/gravPrep.js | 161 ++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 95 deletions(-) diff --git a/tools/jsdoc/gravPrep.js b/tools/jsdoc/gravPrep.js index 634f529891..482a90c8b8 100644 --- a/tools/jsdoc/gravPrep.js +++ b/tools/jsdoc/gravPrep.js @@ -11,22 +11,22 @@ let dir_out = path.join(__dirname, 'out'); let dir_grav = path.join(dir_out, 'grav'); let dir_css = path.join(dir_grav, 'css'); let dir_js = path.join(dir_grav, 'js'); -let dir_twig = path.join(dir_grav, 'templates'); +let dir_template = path.join(dir_grav, 'templates'); let dir_md = path.join(dir_grav, '06.api-reference'); -let dir_md_classes = path.join(dir_md, 'Objects'); -let dir_md_namespaces = path.join(dir_md, 'Namespaces'); -let dir_md_globals = path.join(dir_md, 'Globals'); +let dir_md_objects = path.join(dir_md, '02.Objects'); +let dir_md_namespaces = path.join(dir_md, '01.Namespaces'); +let dir_md_globals = path.join(dir_md, '03.Globals'); // maps for sorting let map_dir_md = { - "Class": dir_md_classes, + "Class": dir_md_objects, "Namespace": dir_md_namespaces, - "Global": dir_md_globals + "Global": dir_md_globals, } // html variables to be replaced -const html_reg_static = /\(static)\<\/span>/g; +const html_reg_static = /\(static\)<\/span>/g const html_reg_title = /\.+?\<\/h1\>/g; const html_reg_htmlExt = /\.html/g; @@ -37,7 +37,7 @@ if (fs.existsSync(dir_grav)){ } // array to itterate over and create if doesn't exist -let dirArray = [dir_grav, dir_css, dir_js, dir_twig, dir_md, dir_md_classes, dir_md_namespaces, dir_md_globals]; +let dirArray = [dir_grav, dir_css, dir_js, dir_template, dir_md, dir_md_objects, dir_md_namespaces, dir_md_globals]; dirArray.forEach(function(dir){ if (!fs.existsSync(dir)) { @@ -45,85 +45,77 @@ dirArray.forEach(function(dir){ } }) -// read jsdoc output folder +function createMD(title, directory){ + let mdSource = makeMdSource(title); + let destinationMDFile = path.join(directory, `API_${title}.md`); + fs.writeFileSync(destinationMDFile, mdSource); +} -/* +function createTemplate(title,directory, content ){ + let twigBasePartial = makeTwigFile(content); + let destinationFile = path.join(directory, `API_${title}.html.twig`); + fs.writeFileSync(destinationFile, twigBasePartial); +} + +createMD("API-Reference", dir_md); +createTemplate("API-Reference", dir_template,""); +createMD("Globals", dir_md_globals); +createTemplate("Globals", dir_template,""); +createMD("Namespaces", dir_md_namespaces); +createTemplate("Namespaces", dir_template,""); +createMD("Objects", dir_md_objects); +createTemplate("Objects", dir_template,""); + +// read jsdoc output folder let files = fs.readdirSync(dir_out); files.forEach(function (file){ let curSource = path.join(dir_out, file); - if (path.extname(curSource) == ".html") { - + if (path.extname(curSource) == ".html" && path.basename(curSource, '.html') !== "index") { // clean up the html source let loadedHtml = prepareHtml(curSource); - // extract the title and the main div + // extract the title, groupename, and the main div - let splitTile = loadedHtml("title").text().split(": "); - let groupName = splitTitle[0]; - let htmlTitle = splitTile.pop(); - console.log(groupName); - // let mainDiv = loadedHtml("#main").html(); - // let mainDivNoTitle = mainDiv.replace(/\.+?\<\/h1\>/g, ""); - // let mainDivStripLinks = mainDivNoTitle.replace(/\.html/g, ""); + let splitTitle = loadedHtml("title").text().split(": "); + // console.log(splitTitle); + let groupName = splitTitle[1]; + let htmlTitle = splitTitle.pop(); + // strip out undesired regex + let mainDiv = loadedHtml("#main").html(); + let mainDivRegexed = mainDiv.replace(html_reg_static,"") + .replace(html_reg_title,"") + .replace(html_reg_htmlExt,"") // create the .md file and corresponding folder - // let mdSource = makeMdSource(htmlTitle); - // let destinationDirectory = path.join(dir_md, htmlTitle); - // if (!fs.existsSync(destinationDirectory)) { - // fs.mkdirSync(destinationDirectory); - // } - // let destinationMDFile = path.join(destinationDirectory, `API_${htmlTitle}.md`); - // fs.writeFileSync(destinationMDFile, mdSource); + if (htmlTitle !== "Global"){ + let mdSource = makeMdSource(htmlTitle); + let destinationDirectory = path.join(map_dir_md[groupName], htmlTitle); + if (!fs.existsSync(destinationDirectory)) { + fs.mkdirSync(destinationDirectory); + } + let destinationMDFile = path.join(destinationDirectory, `API_${htmlTitle}.md`); + fs.writeFileSync(destinationMDFile, mdSource); + } else { + let mdSource = makeMdSource(htmlTitle); + let destinationMDFile = path.join(map_dir_md[groupName], `API_Globals.md`); + fs.writeFileSync(destinationMDFile, mdSource); + } + // create the twig template - // let twigBasePartial = makeTwigFile(mainDivStripLinks); - // let destinationFile = path.join(dir_twig, `API_${htmlTitle}.html.twig`); - // fs.writeFileSync(destinationFile, twigBasePartial); + let twigBasePartial = makeTwigFile(mainDivRegexed); + let destinationFile = path.join(dir_template, `API_${htmlTitle}.html.twig`); + fs.writeFileSync(destinationFile, twigBasePartial); } }) -*/ +// let curSource = path.join(dir_out, "Camera.html"); -let curSource = path.join(dir_out, "Camera.html"); -// clean up the html source - -let loadedHtml = prepareHtml(curSource); - -// extract the title, groupename, and the main div - -let splitTitle = loadedHtml("title").text().split(": "); -let groupName = splitTitle[1]; -let htmlTitle = splitTitle.pop(); -console.log("groupname:", groupName); -console.log("htmlTitle:", htmlTitle); - -// strip out undesired regex -let mainDiv = loadedHtml("#main").html(); -let mainDivRegexed = mainDiv.replace(html_reg_static,"") - .replace(html_reg_title,"") - .replace(html_reg_htmlExt,"") - -// create the .md file and corresponding folder - -console.log(map_dir_md[groupName]); -let mdSource = makeMdSource(htmlTitle); -let destinationDirectory = path.join(map_dir_md[groupName], htmlTitle); -if (!fs.existsSync(destinationDirectory)) { - fs.mkdirSync(destinationDirectory); -} -let destinationMDFile = path.join(destinationDirectory, `API_${htmlTitle}.md`); -fs.writeFileSync(destinationMDFile, mdSource); - -// create the twig template - -let twigBasePartial = makeTwigFile(mainDivRegexed); -let destinationFile = path.join(dir_twig, `API_${htmlTitle}.html.twig`); -fs.writeFileSync(destinationFile, twigBasePartial); function prepareHtml(source){ let htmlBefore = fs.readFileSync(source, {encoding: 'utf8'}); @@ -181,47 +173,26 @@ function makeTwigFile(contentHtml){ let targertTwigDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav/user/themes/learn2/"; let targetMDDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav-content/"; -let chapterMD = -`--- -title: 'High Fidelity API Reference' -taxonomy: - category: - - docs ---- - -### - -# API Reference - -**Under Construction**: We're currently working on creating an API Reference where you can access functions and events easily. - -Check out our latest API Reference here. We're doing our best to keep this reference up-to-date with each release. If you don't find information you are looking for, contact us at [docs@highfidelity.io](mailto:docs@highfidelity.io). - -` - // Copy files to the Twig Directory -let files = fs.readdirSync(path.resolve(targertTwigDirectory)); -files.forEach(function(file){ +let templateFiles = fs.readdirSync(path.resolve(targertTwigDirectory)); +templateFiles.forEach(function(file){ let curSource = path.join(targertTwigDirectory, file); if(path.basename(file, '.html').indexOf("API") > -1){ fs.unlink(curSource); } }) -copyFolderRecursiveSync(dir_twig, targertTwigDirectory); +copyFolderRecursiveSync(dir_template, targertTwigDirectory); // Copy files to the Md Directory let baseMdRefDir = path.join(targetMDDirectory,"06.api-reference"); -if (fs.existsSync(targetMDDirectory)){ +if (fs.existsSync(baseMdRefDir)){ rimraf.sync(baseMdRefDir); } copyFolderRecursiveSync(dir_md, targetMDDirectory); -let chapterDestinationFile = path.join(baseMdRefDir, `chapter.md`); -fs.writeFileSync(chapterDestinationFile, chapterMD); - // helper functions function copyFileSync( source, target ) { @@ -247,12 +218,12 @@ function copyFolderRecursiveSync( source, target ) { var files = []; //check if folder needs to be created or integrated - console.log("target:" + target) - console.log("source:" + source) - console.log("basename source:" + path.basename( source )) + // console.log("target:" + target) + // console.log("source:" + source) + // console.log("basename source:" + path.basename( source )) var targetFolder = path.join( target, path.basename( source ) ); - console.log("targetFolder:" + targetFolder); + // console.log("targetFolder:" + targetFolder); if ( !fs.existsSync( targetFolder ) ) { fs.mkdirSync( targetFolder ); } From f35fffb97558d18f7dfea86e2e9f5f31d7042ade Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Sat, 28 Apr 2018 13:55:42 -0700 Subject: [PATCH 03/10] Added toc --- tools/jsdoc/gravPrep.js | 149 ++++++++++++++++++++++++++-------------- 1 file changed, 96 insertions(+), 53 deletions(-) diff --git a/tools/jsdoc/gravPrep.js b/tools/jsdoc/gravPrep.js index 841b61417e..04aeaa9069 100644 --- a/tools/jsdoc/gravPrep.js +++ b/tools/jsdoc/gravPrep.js @@ -5,6 +5,7 @@ const pretty = require('pretty'); const cheerio = require('cheerio'); const rimraf = require('rimraf'); + const dedent = require('dedent-js'); // Required directories let dir_out = path.join(__dirname, 'out'); @@ -46,16 +47,31 @@ const html_reg_htmlExt = /\.html/g; const html_reg_objectHeader = /
[\s\S]+?<\/header>/; const html_reg_objectSpanNew = /

<\/h4>/; + const html_reg_brRemove = /
[\s\S]+?
/; + +// Mapping for GroupNames and Members + let groupNameMemberMap = { + "Objects": [], + "Namespaces": [], + "Globals": [] + } // Procedural functions - function createMD(title, directory, needsDir){ + function createMD(title, directory, needsDir, isGlobal){ let mdSource = makeMdSource(title); + + // if (isGlobal){ + // mdSource = + // destinationMDFile = path.join(directory, `Globals.md`); + // } + if (needsDir){ if (!fs.existsSync(directory)) { fs.mkdirSync(directory); } } - let destinationMDFile = path.join(directory, `API_${title}.md`); + + let destinationMDFile = path.join(directory, `API_${title}.md`); fs.writeFileSync(destinationMDFile, mdSource); } @@ -112,71 +128,97 @@ } function makeMdSource(title){ - return ( - `--- - title: '${title}' - taxonomy: - category: - - docs - visible: true - --- - ` - ) + return dedent( + ` + --- + title: ${title} + taxonomy: + category: + - docs + visible: true + --- + ` + ) } function makeTwigFile(contentHtml){ - return ( - ` - {% extends 'partials/base_noGit.html.twig' %} - {% set tags = page.taxonomy.tag %} - {% if tags %} - {% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs', 'tag': tags}},'order': {'by': 'default', 'dir': 'asc'}}) %} - {% else %} - {% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs'}},'order': {'by': 'default', 'dir': 'asc'}}) %} - {% endif %} - - {% block navigation %} - - {% endblock %} - - {% block content %} -
-

{{ page.title }}

- ${contentHtml} -
- {% endblock %} - ` - ) + + {% block navigation %} + + {% endblock %} + + {% block content %} +
+

{{ page.title }}

+ ${contentHtml} +
+ {% endblock %} + ` + ) } function handleNamespace(title, content){ + groupNameMemberMap["Namespaces"].push(title); let destinationDirectory = path.join(map_dir_md["Namespace"], title); createMD(title, destinationDirectory, true); createTemplate(title, content); } function handleClass(title, content){ + groupNameMemberMap["Objects"].push(title); let destinationDirectory = path.join(map_dir_md["Class"], title); createMD(title, destinationDirectory, true) let formatedHtml = content - .replace(html_reg_objectHeader,"") - .replace(html_reg_objectSpanNew,""); + .replace(html_reg_objectSpanNew,"") + .replace(html_reg_brRemove, ""); createTemplate(title, formatedHtml); - } function handleGlobal(title, content){ - createMD("API_Globals", map_dir_md["Global"], false); - createTemplate("API_Globals", content); + groupNameMemberMap["Globals"].push("Globals"); + createMD("Globals", map_dir_md["Global"], false, true); + createTemplate("Globals", content); + } + + function makeGroupTOC(group){ + let mappedGroup; + if (!Array.isArray(group)){ + mappedGroup = groupNameMemberMap[group]; + } else { + mappedGroup = group; + } + let htmlGroup = mappedGroup.map( item => { + return dedent( + ` +
+ ${item} +
+ ` + ) + }) + return htmlGroup.join("\n"); } // Remove grav directory if exists to make sure old files aren't kept @@ -212,9 +254,11 @@ let mainDiv = loadedHtml("#main").html(); // Strip out undesired regex - let mainDivRegexed = mainDiv.replace(html_reg_static,"") - .replace(html_reg_title,"") - .replace(html_reg_htmlExt,""); + let mainDivRegexed = mainDiv + .replace(html_reg_static,"") + .replace(html_reg_title,"") + .replace(html_reg_objectHeader,"") + .replace(html_reg_htmlExt,""); // Handle Unique Categories switch(groupName){ case "Namespace": @@ -233,10 +277,9 @@ }) // Create the base Templates after processing individual files - createTemplate("API-Reference",""); - createTemplate("Globals",""); - createTemplate("Namespaces",""); - createTemplate("Objects",""); + createTemplate("API-Reference", makeGroupTOC(["Namespaces", "Objects", "Globals"])); + createTemplate("Namespaces", makeGroupTOC("Namespaces")); + createTemplate("Objects", makeGroupTOC("Objects")); // Copy files to the Twig Directory let templateFiles = fs.readdirSync(path.resolve(targetTemplateDirectory)); From 1ce4c9d1405c00b5b08e58dd16a2ce7b05f25d78 Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Sun, 29 Apr 2018 14:52:56 -0700 Subject: [PATCH 04/10] GravPrep working through first round of editing, starting explore file and jsdoc quality tests --- tools/jsdoc/Check.js | 140 +++++++++++++++ tools/jsdoc/gravPrep-Explore.js | 308 ++++++++++++++++++++++++++++++++ tools/jsdoc/gravPrep.js | 33 ++-- 3 files changed, 470 insertions(+), 11 deletions(-) create mode 100644 tools/jsdoc/Check.js create mode 100644 tools/jsdoc/gravPrep-Explore.js diff --git a/tools/jsdoc/Check.js b/tools/jsdoc/Check.js new file mode 100644 index 0000000000..b7e0fb1298 --- /dev/null +++ b/tools/jsdoc/Check.js @@ -0,0 +1,140 @@ +var fs = require('fs'); +var path = require('path'); + +function endsWith(path, exts) { + var result = false; + exts.forEach(function(ext) { + if (path.endsWith(ext)) { + result = true; + } + }); + return result; +} + +function WarningObject(file, type, issues){ + this.file = file; + this.type = type; + this.issues = issues; +} + +var warnings = []; + +function parse() { + var rootFolder = __dirname; + console.log("Scanning hifi source for jsdoc comments..."); + + // directories to scan for jsdoc comments + var dirList = [ + '../../interface/src', + '../../interface/src/assets', + '../../interface/src/audio', + '../../interface/src/avatar', + '../../interface/src/commerce', + '../../interface/src/devices', + '../../interface/src/java', + '../../interface/src/networking', + '../../interface/src/ui/', + '../../interface/src/scripting', + '../../interface/src/ui/overlays', + '../../interface/src/raypick', + '../../libraries/animation/src', + '../../libraries/audio-client/src', + '../../libraries/audio/src', + '../../libraries/avatars/src', + '../../libraries/avatars-renderer/src/avatars-renderer', + '../../libraries/controllers/src/controllers/', + '../../libraries/controllers/src/controllers/impl/', + '../../libraries/display-plugins/src/display-plugins/', + '../../libraries/entities/src', + '../../libraries/graphics-scripting/src/graphics-scripting/', + '../../libraries/input-plugins/src/input-plugins', + '../../libraries/model-networking/src/model-networking/', + '../../libraries/networking/src', + '../../libraries/octree/src', + '../../libraries/physics/src', + '../../libraries/pointers/src', + '../../libraries/script-engine/src', + '../../libraries/shared/src', + '../../libraries/shared/src/shared', + '../../libraries/trackers/src/trackers', + '../../libraries/ui/src/ui', + '../../plugins/oculus/src', + '../../plugins/openvr/src' + ]; + + // only files with this extension will be searched for jsdoc comments. + var exts = ['.h', '.cpp']; + + dirList.forEach(function (dir) { + var joinedDir = path.join(rootFolder, dir); + var files = fs.readdirSync(joinedDir); + files.forEach(function (file) { + var pathDir = path.join(joinedDir, file); + if (fs.lstatSync(pathDir).isFile() && endsWith(pathDir, exts)) { + // load entire file into a string + var data = fs.readFileSync(pathDir, "utf8"); + var fileName = path.basename(file); + var badJSDocWarnings = checkForBadJSDoc(data, fileName); + if (badJSDocWarnings.length > 0){ + warnings.push(badJSDocWarnings); + } + var badWordsList = checkForBadwordlist(data, fileName); + if (badWordsList){ + warnings.push(badWordsList); + } + + } + }); + }); +} + +function checkForBadJSDoc(dataToSearch, file){ + var warningList = []; + var reg = /\/\*\*js.*/g; + var matches = dataToSearch.match(reg); + if (matches) { + // add to source, but strip off c-comment asterisks + var filtered = matches.filter( item => { + return item.trim() !== '/**jsdoc'; + }); + if (filtered.length > 0){ + warningList.push(new WarningObject(file, "badJSDOC", filtered)); + } + } + return warningList; +} + +var badWordList = ["@params", "@return", "@bool"]; + +function checkForBadwordlist(dataToSearch, file){ + var warningList = []; + var reg = /(\/\*\*jsdoc(.|[\r\n])*?\*\/)/g; + var matches = dataToSearch.match(reg); + if (matches) { + var filtered = matches.forEach( item => { + var split = item.split(" "); + var filterList = []; + item.split(" ").forEach( item => { + badWordList.forEach(searchTerm => { + if (item === searchTerm) { + filterList.push(searchTerm); + } + }) + }) + if (filterList.length > 0) { + warningList.push(filterList); + } + }); + } + let flatten = warningList.reduce( (prev, cur) => { + return [...prev, ...cur]; + },[]) + let unique = [...new Set(flatten)]; + if (warningList.length > 0) { + return new WarningObject(file, "badWordList", unique); + } + +} + +parse(); +fs.writeFileSync(path.join(__dirname, "warningLog"), warnings.map( item => JSON.stringify(item)).join("\n")); \ No newline at end of file diff --git a/tools/jsdoc/gravPrep-Explore.js b/tools/jsdoc/gravPrep-Explore.js new file mode 100644 index 0000000000..4f31928923 --- /dev/null +++ b/tools/jsdoc/gravPrep-Explore.js @@ -0,0 +1,308 @@ +// Dependencies + const htmlclean = require('htmlclean'); + const fs = require('fs'); + const path = require('path'); + const pretty = require('pretty'); + const cheerio = require('cheerio'); + const rimraf = require('rimraf'); + const dedent = require('dedent-js'); + +// Required directories + let dir_out = path.join(__dirname, 'out'); + + let dir_grav = path.join(dir_out, 'grav'); + let dir_css = path.join(dir_grav, 'css'); + let dir_js = path.join(dir_grav, 'js'); + let dir_template = path.join(dir_grav, 'templates'); + + let dir_md = path.join(dir_grav, '06.api-reference'); + let dir_md_objects = path.join(dir_md, '02.Objects'); + let dir_md_namespaces = path.join(dir_md, '01.Namespaces'); + let dir_md_globals = path.join(dir_md, '03.Globals'); + +// Target Copy Directories + let targetTemplateDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav/user/themes/learn2/"; + let targetMDDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav-content/"; + +// Array to itterate over and create if doesn't exist + let dirArray = [dir_grav, dir_css, dir_js, dir_template, dir_md, dir_md_objects, dir_md_namespaces, dir_md_globals]; + +// Maps for directory names + let map_dir_md = { + "API-Reference": dir_md, + "Globals": dir_md_globals, + "Objects": dir_md_objects, + "Namespaces": dir_md_namespaces, + "Class": dir_md_objects, + "Namespace": dir_md_namespaces, + "Global": dir_md_globals + } + +// Base Grouping Directories for MD files + let baseMDDirectories = ["API-Reference", "Globals", "Namespaces", "Objects"] + +// Html variables to be handle regex replacements + const html_reg_static = /\(static\)<\/span>/g + const html_reg_title = /\.+?\<\/h1\>/g; + const html_reg_htmlExt = /\.html/g; + const html_reg_objectHeader = /
[\s\S]+?<\/header>/; + const html_reg_objectSpanNew = /

<\/h4>/; + const html_reg_brRemove = /
[\s\S]+?
/; + +// Mapping for GroupNames and Members + let groupNameMemberMap = { + "Objects": [], + "Namespaces": [], + "Globals": [] + } + +// Procedural functions + function createMD(title, directory, needsDir, isGlobal){ + let mdSource = makeMdSource(title); + + if (needsDir){ + if (!fs.existsSync(directory)) { + fs.mkdirSync(directory); + } + } + + let destinationMDFile = path.join(directory, `API_${title}.md`); + fs.writeFileSync(destinationMDFile, mdSource); + } + + function createTemplate(title,content){ + let twigBasePartial = makeTwigFile(content); + let destinationFile = path.join(dir_template, `API_${title}.html.twig`); + fs.writeFileSync(destinationFile, twigBasePartial); + } + + function copyFileSync( source, target ) { + let targetFile = target; + + // If target is a directory a new file with the same name will be created + if ( fs.existsSync( target ) ) { + // console.log("target exists"); + if ( fs.lstatSync( target ).isDirectory() ) { + // console.log("target is a directory"); + + targetFile = path.join( target, path.basename( source ) ); + } + } + + fs.writeFileSync(targetFile, fs.readFileSync(source)); + } + + function copyFolderRecursiveSync( source, target ) { + var files = []; + + // Check if folder needs to be created or integrated + var targetFolder = path.join( target, path.basename( source ) ); + if ( !fs.existsSync( targetFolder ) ) { + fs.mkdirSync( targetFolder ); + } + + // Copy + if ( fs.lstatSync( source ).isDirectory() ) { + files = fs.readdirSync( source ); + files.forEach( function ( file ) { + var curSource = path.join( source, file ); + if ( fs.lstatSync( curSource ).isDirectory() ) { + copyFolderRecursiveSync( curSource, targetFolder ); + } else { + copyFileSync( curSource, targetFolder ); + } + } ); + } + } + + function prepareHtml(source){ + let htmlBefore = fs.readFileSync(source, {encoding: 'utf8'}); + let htmlAfter = htmlclean(htmlBefore); + let htmlAfterPretty = pretty(htmlAfter); + return cheerio.load(htmlAfterPretty); + } + + function makeMdSource(title){ + return dedent( + ` + --- + title: ${title} + taxonomy: + category: + - docs + visible: true + --- + ` + ) + } + + function makeTwigFile(contentHtml){ + return dedent( + ` + {% extends 'partials/base_noGit.html.twig' %} + {% set tags = page.taxonomy.tag %} + {% if tags %} + {% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs', 'tag': tags}},'order': {'by': 'default', 'dir': 'asc'}}) %} + {% else %} + {% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs'}},'order': {'by': 'default', 'dir': 'asc'}}) %} + {% endif %} + + {% block navigation %} + + {% endblock %} + + {% block content %} +
+

{{ page.title }}

+ ${contentHtml} +
+ {% endblock %} + ` + ) + } + + function handleNamespace(title, content){ + groupNameMemberMap["Namespaces"].push(title); + let destinationDirectory = path.join(map_dir_md["Namespace"], title); + + createMD(title, destinationDirectory, true); + createTemplate(title, content); + } + + function handleClass(title, content){ + groupNameMemberMap["Objects"].push(title); + let destinationDirectory = path.join(map_dir_md["Class"], title); + createMD(title, destinationDirectory, true) + + let formatedHtml = content + .replace(html_reg_objectSpanNew,"") + .replace(html_reg_brRemove, ""); + createTemplate(title, formatedHtml); + } + + function handleGlobal(title, content){ + groupNameMemberMap["Globals"].push("Globals"); + createMD("Globals", map_dir_md["Global"], false, true); + createTemplate("Globals", content); + } + + function makeGroupTOC(group){ + let mappedGroup; + if (!Array.isArray(group)){ + mappedGroup = groupNameMemberMap[group]; + } else { + mappedGroup = group; + } + let htmlGroup = mappedGroup.map( item => { + return dedent( + ` +
+ ${item} +
+ ` + ) + }) + return htmlGroup.join("\n"); + } + +// Remove grav directory if exists to make sure old files aren't kept + if (fs.existsSync(dir_grav)){ + console.log("dir_grav exists"); + rimraf.sync(dir_grav); + } + +// Create Grav directories in JSDOC output + dirArray.forEach(function(dir){ + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } + }) + +// Create baseMD files + baseMDDirectories.forEach( md => { + createMD(md, map_dir_md[md]); + }) + +// Read jsdoc output folder and process html files + let curSource = path.join(dir_out, "Selection.html"); + // Clean up the html source + let loadedHtml = prepareHtml(curSource); + + // Extract the title, group name, and the main div + let splitTitle = loadedHtml("title").text().split(": "); + let groupName = splitTitle[1]; + let htmlTitle = splitTitle.pop(); + let mainDiv = loadedHtml("#main") + + // Exploring Extractions + let array = mainDiv.find('h4').toArray(); + + // console.log(array[2]) + var reducedArray = array.reduce((prev, cur) => { + try { + // console.log(cur.children[1]); + prev.push(cur.children[1].data); + } catch(e) { + + } + return prev; + }, []) + console.log("name", reducedArray.length); + + // Strip out undesired regex + let mainDivRegexed = mainDiv.html() + .replace(html_reg_static,"") + .replace(html_reg_title,"") + .replace(html_reg_objectHeader,"") + .replace(html_reg_htmlExt,""); + // Handle Unique Categories + switch(groupName){ + case "Namespace": + handleNamespace(htmlTitle, mainDivRegexed); + break; + case "Class": + handleClass(htmlTitle, mainDivRegexed); + break; + case "Global": + handleGlobal(htmlTitle, mainDivRegexed); + break; + default: + console.log(`Case not handled for ${groupName}`); + } + +// Create the base Templates after processing individual files + createTemplate("API-Reference", makeGroupTOC(["Namespaces", "Objects", "Globals"])); + createTemplate("Namespaces", makeGroupTOC("Namespaces")); + createTemplate("Objects", makeGroupTOC("Objects")); + +// Copy files to the Twig Directory + let templateFiles = fs.readdirSync(path.resolve(targetTemplateDirectory)); + // Remove Existing API files + templateFiles.forEach(function(file){ + let curSource = path.join(targetTemplateDirectory, file); + + if(path.basename(file, '.html').indexOf("API") > -1){ + fs.unlink(curSource); + } + }) + copyFolderRecursiveSync(dir_template, targetTemplateDirectory); + +// Copy files to the Md Directory + let baseMdRefDir = path.join(targetMDDirectory,"06.api-reference"); + // Remove existing MD directory + if (fs.existsSync(baseMdRefDir)){ + rimraf.sync(baseMdRefDir); + } + copyFolderRecursiveSync(dir_md, targetMDDirectory); diff --git a/tools/jsdoc/gravPrep.js b/tools/jsdoc/gravPrep.js index 04aeaa9069..d02116a02f 100644 --- a/tools/jsdoc/gravPrep.js +++ b/tools/jsdoc/gravPrep.js @@ -48,6 +48,16 @@ const html_reg_objectHeader = /
[\s\S]+?<\/header>/; const html_reg_objectSpanNew = /

<\/h4>/; const html_reg_brRemove = /
[\s\S]+?
/; + const html_reg_methodEdit = /

Methods<\/h3>/; + const html_reg_methodEdit_replace = '

Methods
'; + const html_reg_classesEdit = /

Classes<\/h3>/; + const html_reg_classesEdit_replace = '

Classes
'; + const html_reg_typeEdit = /(
Returns[\s\S]*?Type)(<\/dt[\s\S]*?type">)(.*?)(<\/span><\/dd>[\s\S]*?<\/dl>)/g; + const html_reg_typeEdit_replace = '$1: $3' + const html_reg_methodSize = /()(<\/h4>)/g; + const html_reg_methodSize_replace = ''; + const html_reg_returnSize = /
Returns:<\/h5>/g; + const html_reg_returnSize_replace = '
Returns:<\/h6>'; // Mapping for GroupNames and Members let groupNameMemberMap = { @@ -60,11 +70,6 @@ function createMD(title, directory, needsDir, isGlobal){ let mdSource = makeMdSource(title); - // if (isGlobal){ - // mdSource = - // destinationMDFile = path.join(directory, `Globals.md`); - // } - if (needsDir){ if (!fs.existsSync(directory)) { fs.mkdirSync(directory); @@ -188,7 +193,6 @@ let formatedHtml = content .replace(html_reg_objectSpanNew,"") - .replace(html_reg_brRemove, ""); createTemplate(title, formatedHtml); } @@ -251,14 +255,21 @@ let splitTitle = loadedHtml("title").text().split(": "); let groupName = splitTitle[1]; let htmlTitle = splitTitle.pop(); - let mainDiv = loadedHtml("#main").html(); - - // Strip out undesired regex - let mainDivRegexed = mainDiv + let mainDiv = loadedHtml("#main") + + // regex edits + let mainDivRegexed = mainDiv.html() .replace(html_reg_static,"") .replace(html_reg_title,"") .replace(html_reg_objectHeader,"") - .replace(html_reg_htmlExt,""); + .replace(html_reg_htmlExt,"") + .replace(html_reg_brRemove, "") + .replace(html_reg_methodEdit, html_reg_methodEdit_replace) + .replace(html_reg_classesEdit, html_reg_classesEdit_replace) + .replace(html_reg_typeEdit, html_reg_typeEdit_replace) + .replace(html_reg_returnSize, html_reg_returnSize_replace) + .replace(html_reg_methodSize, html_reg_methodSize_replace); + // Handle Unique Categories switch(groupName){ case "Namespace": From f520d13242ef09931193fab4af3f5be135e326c6 Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Mon, 30 Apr 2018 16:32:15 -0700 Subject: [PATCH 05/10] pre TOC add --- tools/jsdoc/.gitignore | 4 +- tools/jsdoc/grav.bat | 1 + tools/jsdoc/gravPrep-Explore.js | 118 ++++++++++++++++++--- tools/jsdoc/gravPrep.js | 176 ++++++++++++++++++++++++++------ 4 files changed, 251 insertions(+), 48 deletions(-) create mode 100644 tools/jsdoc/grav.bat diff --git a/tools/jsdoc/.gitignore b/tools/jsdoc/.gitignore index c585e19389..bfca56353a 100644 --- a/tools/jsdoc/.gitignore +++ b/tools/jsdoc/.gitignore @@ -1 +1,3 @@ -out \ No newline at end of file +out +grav.bat +gravPrep-Explore \ No newline at end of file diff --git a/tools/jsdoc/grav.bat b/tools/jsdoc/grav.bat new file mode 100644 index 0000000000..08c75edb8e --- /dev/null +++ b/tools/jsdoc/grav.bat @@ -0,0 +1 @@ +cmd /k node gravPrep true "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav/user/themes/learn2/" "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav-content/" \ No newline at end of file diff --git a/tools/jsdoc/gravPrep-Explore.js b/tools/jsdoc/gravPrep-Explore.js index 4f31928923..c8fea0a4df 100644 --- a/tools/jsdoc/gravPrep-Explore.js +++ b/tools/jsdoc/gravPrep-Explore.js @@ -48,6 +48,20 @@ const html_reg_objectHeader = /
[\s\S]+?<\/header>/; const html_reg_objectSpanNew = /

<\/h4>/; const html_reg_brRemove = /
[\s\S]+?
/; + const html_reg_subsectionEdit = /()([\s\S]*?)(<\/h.>)/g; + const html_reg_subsectionEdit_replace = '

$2

'; + const html_reg_typeEdit = /(
Returns[\s\S]*?Type)(<\/dt[\s\S]*?type">)(.*?)(<\/span><\/dd>[\s\S]*?<\/dl>)/g; + const html_reg_typeEdit_replace = '$1: $3' + const html_reg_methodSize = /()(<\/h4>)/g; + const html_reg_methodSize_replace = ''; + const html_reg_returnSize = /
Returns:<\/h5>/g; + const html_reg_returnSize_replace = '
Returns:<\/h6>'; + const html_reg_findByName = '
Methods
` + const html_reg_findByArticleClose = `` + const html_reg_signalTitle = `

Signals

`; + + // Mapping for GroupNames and Members let groupNameMemberMap = { @@ -71,7 +85,9 @@ } function createTemplate(title,content){ + // console.log("content:", content) let twigBasePartial = makeTwigFile(content); + // console.log("TWIG BASE:", twigBasePartial) let destinationFile = path.join(dir_template, `API_${title}.html.twig`); fs.writeFileSync(destinationFile, twigBasePartial); } @@ -170,6 +186,7 @@ } function handleNamespace(title, content){ + // console.log("Content from namespcae:", content) groupNameMemberMap["Namespaces"].push(title); let destinationDirectory = path.join(map_dir_md["Namespace"], title); @@ -236,7 +253,7 @@ }) // Read jsdoc output folder and process html files - let curSource = path.join(dir_out, "Selection.html"); + let curSource = path.join(dir_out, "AvatarInputs.html"); // Clean up the html source let loadedHtml = prepareHtml(curSource); @@ -244,29 +261,102 @@ let splitTitle = loadedHtml("title").text().split(": "); let groupName = splitTitle[1]; let htmlTitle = splitTitle.pop(); + // console.log("first loaded:", loadedHtml("#main").html()) let mainDiv = loadedHtml("#main") - + + // let signatures = mainDiv.find(".name") // Exploring Extractions - let array = mainDiv.find('h4').toArray(); + // let array = mainDiv.find('h4').toArray(); // console.log(array[2]) - var reducedArray = array.reduce((prev, cur) => { - try { - // console.log(cur.children[1]); - prev.push(cur.children[1].data); - } catch(e) { + // var reducedArray = array.reduce((prev, cur) => { + // try { + // // console.log(cur.children[1]); + // prev.push(cur.children[1].data); + // } catch(e) { - } - return prev; - }, []) - console.log("name", reducedArray.length); + // } + // return prev; + // }, []) + // console.log("name", reducedArray.length); - // Strip out undesired regex + // regex edits let mainDivRegexed = mainDiv.html() .replace(html_reg_static,"") .replace(html_reg_title,"") .replace(html_reg_objectHeader,"") - .replace(html_reg_htmlExt,""); + .replace(html_reg_htmlExt,"") + .replace(html_reg_brRemove, "") + .replace(html_reg_subsectionEdit, html_reg_subsectionEdit_replace) + .replace(html_reg_typeEdit, html_reg_typeEdit_replace) + .replace(html_reg_returnSize, html_reg_returnSize_replace) + .replace(html_reg_methodSize, html_reg_methodSize_replace); + + function splitBy(content, searchTerm){ + let foundArray = []; + let curIndex = -1; + let nextIndex = 0; + let findbyNameLength = searchTerm.length; + let curfoundArrayIndex = 0; + let curArticleCloseIndex = -1; + do { + curArticleCloseIndex = content.indexOf(""); + curIndex = content.indexOf(searchTerm); + nextIndex = content.indexOf(searchTerm,curIndex+findbyNameLength); + if (nextIndex === -1){ + nextIndex = curArticleCloseIndex + } + foundArray.push(content.slice(curIndex, nextIndex)) + content = content.replace(foundArray[curfoundArrayIndex], ""); + curfoundArrayIndex++; + } while (curIndex > -1) + return [content, foundArray]; + } + + function extractSignals(methodArray){ + let newMethodArray = []; + let signalArray = []; + methodArray.forEach( method => { + method.indexOf("Signal") > -1 + ? signalArray.push(method) + : newMethodArray.push(method); + }) + return [newMethodArray, signalArray] + } + + function append(content, areaToAppendTo, contentToAppend, appendBefore){ + var contentArray = content.split("\n"); + // console.log("contentArray:", contentArray) + // console.log("areaToAppendTo:", areaToAppendTo) + var foundIndex = findArrayTrim(contentArray, areaToAppendTo) + console.log(foundIndex) + foundIndex = appendBefore ? foundIndex : foundIndex +1 + + contentArray.splice(foundIndex,0,contentToAppend) + return contentArray.join("\n") + } + + function findArrayTrim(array, searchTerm){ + var index = -1; + for (var i = 0; i < array.length; i++){ + index = array[i].trim().indexOf(searchTerm.trim()); + if (index > -1){ + return i + } + } + return index; + } + + var nameArray = splitBy(mainDivRegexed, html_reg_findByName); + let currentContent = nameArray[0]; + let separatedMethods = extractSignals(nameArray[1]); + let methodsToAppend = separatedMethods[0].join("\n"); + separatedMethods[1].unshift(html_reg_signalTitle) + let signalsToAppend = separatedMethods[1].join("\n"); + currentContent = append(currentContent, html_reg_findByMethod, methodsToAppend); + mainDivRegexed = append(currentContent, html_reg_findByArticleClose, signalsToAppend,true); + + // console.log(mainDivRegexed); // Handle Unique Categories switch(groupName){ case "Namespace": diff --git a/tools/jsdoc/gravPrep.js b/tools/jsdoc/gravPrep.js index d02116a02f..4fa2a7b310 100644 --- a/tools/jsdoc/gravPrep.js +++ b/tools/jsdoc/gravPrep.js @@ -7,6 +7,16 @@ const rimraf = require('rimraf'); const dedent = require('dedent-js'); +// Arg Vars + const copyLocal = process.argv[2]; + console.log("copyLocal:", copyLocal); + let targetTemplateDirectory = '' + let targetMDDirectory = '' + if (copyLocal){ + targetTemplateDirectory = process.argv[3]; + targetMDDirectory = process.argv[4];; + } + // Required directories let dir_out = path.join(__dirname, 'out'); @@ -19,11 +29,7 @@ let dir_md_objects = path.join(dir_md, '02.Objects'); let dir_md_namespaces = path.join(dir_md, '01.Namespaces'); let dir_md_globals = path.join(dir_md, '03.Globals'); - -// Target Copy Directories - let targetTemplateDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav/user/themes/learn2/"; - let targetMDDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav-content/"; - + // Array to itterate over and create if doesn't exist let dirArray = [dir_grav, dir_css, dir_js, dir_template, dir_md, dir_md_objects, dir_md_namespaces, dir_md_globals]; @@ -48,16 +54,21 @@ const html_reg_objectHeader = /
[\s\S]+?<\/header>/; const html_reg_objectSpanNew = /

<\/h4>/; const html_reg_brRemove = /
[\s\S]+?
/; - const html_reg_methodEdit = /

Methods<\/h3>/; - const html_reg_methodEdit_replace = '

Methods
'; - const html_reg_classesEdit = /

Classes<\/h3>/; - const html_reg_classesEdit_replace = '

Classes
'; + const html_reg_subsectionEdit = /()([\s\S]*?)(<\/h.>)/g; + const html_reg_subsectionEdit_replace = '

$2

'; + const html_reg_propertiesHeaderEdit = '

Properties:

'; + const html_reg_propertiesHeaderEdit_Replace = '

Properties

'; const html_reg_typeEdit = /(
Returns[\s\S]*?Type)(<\/dt[\s\S]*?type">)(.*?)(<\/span><\/dd>[\s\S]*?<\/dl>)/g; const html_reg_typeEdit_replace = '$1: $3' const html_reg_methodSize = /()(<\/h4>)/g; const html_reg_methodSize_replace = ''; const html_reg_returnSize = /
Returns:<\/h5>/g; const html_reg_returnSize_replace = '
Returns:<\/h6>'; + const html_reg_findByName = '
Methods
` + const html_reg_findByArticleClose = `` + const html_reg_signalTitle = `

Signals

`; + // Mapping for GroupNames and Members let groupNameMemberMap = { @@ -67,6 +78,7 @@ } // Procedural functions + // Create the actual MD file function createMD(title, directory, needsDir, isGlobal){ let mdSource = makeMdSource(title); @@ -80,12 +92,14 @@ fs.writeFileSync(destinationMDFile, mdSource); } + // Create the actual Template file function createTemplate(title,content){ let twigBasePartial = makeTwigFile(content); let destinationFile = path.join(dir_template, `API_${title}.html.twig`); fs.writeFileSync(destinationFile, twigBasePartial); } + // Copy file from source to target - used for recurssive call function copyFileSync( source, target ) { let targetFile = target; @@ -102,6 +116,7 @@ fs.writeFileSync(targetFile, fs.readFileSync(source)); } + // Copy file from source to target function copyFolderRecursiveSync( source, target ) { var files = []; @@ -125,6 +140,7 @@ } } + // Clean up the Html function prepareHtml(source){ let htmlBefore = fs.readFileSync(source, {encoding: 'utf8'}); let htmlAfter = htmlclean(htmlBefore); @@ -132,6 +148,7 @@ return cheerio.load(htmlAfterPretty); } + // Base file for MD's function makeMdSource(title){ return dedent( ` @@ -146,6 +163,7 @@ ) } + // Base file for Templates function makeTwigFile(contentHtml){ return dedent( ` @@ -179,6 +197,7 @@ ) } + // Handle NameSpace Group function handleNamespace(title, content){ groupNameMemberMap["Namespaces"].push(title); let destinationDirectory = path.join(map_dir_md["Namespace"], title); @@ -186,6 +205,7 @@ createTemplate(title, content); } + // Handle Class Group function handleClass(title, content){ groupNameMemberMap["Objects"].push(title); let destinationDirectory = path.join(map_dir_md["Class"], title); @@ -196,12 +216,14 @@ createTemplate(title, formatedHtml); } + // Handle Global Group function handleGlobal(title, content){ groupNameMemberMap["Globals"].push("Globals"); createMD("Globals", map_dir_md["Global"], false, true); createTemplate("Globals", content); } + // Handle Group TOCs function makeGroupTOC(group){ let mappedGroup; if (!Array.isArray(group)){ @@ -225,6 +247,69 @@ return htmlGroup.join("\n"); } + // Helper for splitting up html + // Takes: Content to split, SearchTerm to Split by, and term to End Splitting By + // Returns: [newContent after Split, Array of extracted ] + function splitBy(content, searchTerm, endSplitTerm){ + let foundArray = []; + let curIndex = -1; + let nextIndex = 0; + let findbyNameLength = searchTerm.length; + let curfoundArrayIndex = 0; + let curEndSplitTermIndex = -1; + do { + curEndSplitTermIndex = content.indexOf(endSplitTerm); + curIndex = content.indexOf(searchTerm); + // Search after initial index + length of searchterm + nextIndex = content.indexOf(searchTerm,curIndex+findbyNameLength); + if (nextIndex === -1){ + nextIndex = curEndSplitTermIndex + } + foundArray.push(content.slice(curIndex, nextIndex)) + // remove that content + content = content.replace(foundArray[curfoundArrayIndex], ""); + curfoundArrayIndex++; + } while (curIndex > -1) + return [content, foundArray]; + } + + // Split the signals and methods [Might make this more generic] + function splitMethodsAndSignals(methodArray){ + let newMethodArray = []; + let signalArray = []; + methodArray.forEach( method => { + method.indexOf("Signal") > -1 + ? signalArray.push(method) + : newMethodArray.push(method);2 + }) + return [newMethodArray, signalArray] + } + + // Helper to append + // Takes content, the search term to appendTo, the content to append, + // and bool if the append is before the found area + function append(content, searchTermToAppendto, contentToAppend, appendBefore){ + let contentArray = content.split("\n"); + let foundIndex = findArrayTrim(contentArray, searchTermToAppendto) + foundIndex = appendBefore ? foundIndex : foundIndex +1 + + contentArray.splice(foundIndex,0,contentToAppend) + return contentArray.join("\n") + } + + // Helper function for append + function findArrayTrim(array, searchTerm){ + var index = -1; + for (var i = 0; i < array.length; i++){ + index = array[i].trim().indexOf(searchTerm.trim()); + if (index > -1){ + return i + } + } + return index; + } + + // Remove grav directory if exists to make sure old files aren't kept if (fs.existsSync(dir_grav)){ console.log("dir_grav exists"); @@ -257,29 +342,51 @@ let htmlTitle = splitTitle.pop(); let mainDiv = loadedHtml("#main") - // regex edits + // Basic Regex HTML edits let mainDivRegexed = mainDiv.html() .replace(html_reg_static,"") .replace(html_reg_title,"") .replace(html_reg_objectHeader,"") .replace(html_reg_htmlExt,"") .replace(html_reg_brRemove, "") - .replace(html_reg_methodEdit, html_reg_methodEdit_replace) - .replace(html_reg_classesEdit, html_reg_classesEdit_replace) + .replace(html_reg_subsectionEdit, html_reg_subsectionEdit_replace) + .replace(html_reg_propertiesHeaderEdit, html_reg_propertiesHeaderEdit_Replace) .replace(html_reg_typeEdit, html_reg_typeEdit_replace) .replace(html_reg_returnSize, html_reg_returnSize_replace) .replace(html_reg_methodSize, html_reg_methodSize_replace); - + + // Further HTML Manipulation + // Split HTML by Each named entry + let contentSplitArray = splitBy(mainDivRegexed, html_reg_findByName); + // Create a reference to the current content after split and the split functions + let currentContent = contentSplitArray[0]; + // Create references to the split methods and signals + let splitSignalsAndMethods = splitMethodsAndSignals(contentSplitArray[1]); + let splitMethods = splitSignalsAndMethods[0]; + let splitSignals = splitSignalsAndMethods[1]; + // Append Signals and Methods to the current Content + currentContent = append(currentContent, html_reg_findByMethod, splitMethods.join('\n')); + console.log(path.basename(curSource, '.html'), splitSignals.length); + if (splitSignals.length > 0) { + // Add the Signals header to the Signals HTML + splitSignals.unshift(html_reg_signalTitle) + currentContent = append(currentContent, html_reg_findByArticleClose, splitSignals.join('\n',true)); + } + + // Final Pretty Content + currentContent = htmlclean(currentContent); + currentContent = pretty(currentContent); + // Handle Unique Categories switch(groupName){ case "Namespace": - handleNamespace(htmlTitle, mainDivRegexed); + handleNamespace(htmlTitle, currentContent); break; case "Class": - handleClass(htmlTitle, mainDivRegexed); + handleClass(htmlTitle, currentContent); break; case "Global": - handleGlobal(htmlTitle, mainDivRegexed); + handleGlobal(htmlTitle, currentContent); break; default: console.log(`Case not handled for ${groupName}`); @@ -292,22 +399,25 @@ createTemplate("Namespaces", makeGroupTOC("Namespaces")); createTemplate("Objects", makeGroupTOC("Objects")); -// Copy files to the Twig Directory - let templateFiles = fs.readdirSync(path.resolve(targetTemplateDirectory)); - // Remove Existing API files - templateFiles.forEach(function(file){ - let curSource = path.join(targetTemplateDirectory, file); - - if(path.basename(file, '.html').indexOf("API") > -1){ - fs.unlink(curSource); +// Copy the files to the target Directories if Local + if (copyLocal){ + // Copy files to the Twig Directory + let templateFiles = fs.readdirSync(path.resolve(targetTemplateDirectory)); + // Remove Existing API files + templateFiles.forEach(function(file){ + let curSource = path.join(targetTemplateDirectory, file); + + if(path.basename(file, '.html').indexOf("API") > -1){ + fs.unlink(curSource); + } + }) + copyFolderRecursiveSync(dir_template, targetTemplateDirectory); + + // Copy files to the Md Directory + let baseMdRefDir = path.join(targetMDDirectory,"06.api-reference"); + // Remove existing MD directory + if (fs.existsSync(baseMdRefDir)){ + rimraf.sync(baseMdRefDir); } - }) - copyFolderRecursiveSync(dir_template, targetTemplateDirectory); - -// Copy files to the Md Directory - let baseMdRefDir = path.join(targetMDDirectory,"06.api-reference"); - // Remove existing MD directory - if (fs.existsSync(baseMdRefDir)){ - rimraf.sync(baseMdRefDir); + copyFolderRecursiveSync(dir_md, targetMDDirectory); } - copyFolderRecursiveSync(dir_md, targetMDDirectory); From ae935dcda52b40244d1973a0497c2734c5c5de33 Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Tue, 1 May 2018 16:23:50 -0700 Subject: [PATCH 06/10] saved before laptop acts up more --- tools/jsdoc/.gitignore | 1 + tools/jsdoc/ControllerExamine | 4792 ------------------------------- tools/jsdoc/gravPrep-Explore.js | 300 +- tools/jsdoc/gravPrep.js | 184 +- 4 files changed, 323 insertions(+), 4954 deletions(-) delete mode 100644 tools/jsdoc/ControllerExamine diff --git a/tools/jsdoc/.gitignore b/tools/jsdoc/.gitignore index 62238942c4..3f338a63fb 100644 --- a/tools/jsdoc/.gitignore +++ b/tools/jsdoc/.gitignore @@ -1,4 +1,5 @@ out grav.bat +gravE.bat gravPrep-Explore Examine \ No newline at end of file diff --git a/tools/jsdoc/ControllerExamine b/tools/jsdoc/ControllerExamine deleted file mode 100644 index 15f9f77f3f..0000000000 --- a/tools/jsdoc/ControllerExamine +++ /dev/null @@ -1,4792 +0,0 @@ - - -
- -
-
-
The Controller API provides facilities to interact with computer and controller hardware. -
Functions:
-

Properties

- -

Mappings

- -

Input, Hardware, and Action Reflection

- -

Input, Hardware, and Action Events

- -

Mouse, Keyboard, and Touch Events

- -

Control Capturing

- -

Action Capturing

- -

Controller and Action Values

- -

Haptics

- -

Display Information

- -

Virtual Game Pad

- -

Input Recordings

- - - - - - - - -
Available in:Interface ScriptsClient Entity Scripts
-
-

Properties

- - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
Actions Controller.ActionsPredefined actions on Interface and the user's avatar. These can be used as end points in a - RouteObject mapping. A synonym for Controller.Hardware.Actions. Read-only. -
Default mappings are provided from the Controller.Hardware.Keyboard and Controller.Standard to actions in - keyboardMouse.json and - standard.json, respectively.
Hardware Controller.HardwareStandard and hardware-specific controller and computer outputs, plus predefined actions on Interface and the user's avatar. The outputs can be mapped to Actions or functions in a - RouteObject mapping. Additionally, hardware-specific controller outputs can be mapped to Standard controller outputs. Read-only.
Standard Controller.StandardStandard controller outputs that can be mapped to Actions or functions in a - RouteObject mapping. Read-only. -
Each hardware device has a mapping from its outputs to Controller.Standard items, specified in a JSON file. For example, - leapmotion.json and - vive.json.
-
-
-

Methods

-
actionEvent(actionID, value) → {Signal}
-
Triggered when an action occurs.
-
Parameters:
- - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
actionID numberThe ID of the action, per - findAction.
value numberThe value associated with the action.
-
-
Returns:
-
-
Type: Signal
-
Example
-

Report action events as they occur.

var actionNamesForID = {};
-var actionNames = Controller.getActionNames();
-for (var i = 0, length = actionNames.length; i < length; i++) {
-    actionNamesForID[Controller.findAction(actionNames[i])] = actionNames[i];
-}
-
-function onActionEvent(action, value) {
-    print("onActionEvent() : " + action + " ( " + actionNamesForID[action] + " ) ; " + value);
-}
-
-Controller.actionEvent.connect(onActionEvent);
-
-Script.scriptEnding.connect(function () {
-    Controller.actionEvent.disconnect(onActionEvent);
-});
-
captureActionEvents()
-
Disable translating and rotating the user's avatar in response to keyboard and controller controls.
-
-
Example
-

Disable avatar translation and rotation for a short period.

Script.setTimeout(function () {
-    Controller.captureActionEvents();
-}, 5000);
-
-Script.setTimeout(function () {
-    Controller.releaseActionEvents();
-}, 10000);
-
captureEntityClickEvents()
- -
-
Example
-

Disable entity click events for a short period.

Entities.mousePressOnEntity.connect(function (entityID, event) {
-    print("Clicked on entity: " + entityID);
-});
-
-Script.setTimeout(function () {
-    Controller.captureEntityClickEvents();
-}, 5000);
-
-Script.setTimeout(function () {
-    Controller.releaseEntityClickEvents();
-}, 10000);
-
captureJoystick(joystickID)
-
Disable default Interface actions for a joystick.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
joystickID numberThe integer ID of the joystick.
-
-
Deprecated:
-
-
    -
  • This function no longer has any effect.
  • -
-
-
-
captureKeyEvents(event)
-
Disable default Interface actions for a particular key event.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event KeyEventDetails of the key event to be captured. The key property must be specified. The text property is ignored. The other properties default to false.
-
-
Example
-

Disable left and right strafing.

var STRAFE_LEFT = { "key": 16777234, isShifted: true };
-var STRAFE_RIGHT = { "key": 16777236, isShifted: true };
-
-Controller.captureKeyEvents(STRAFE_LEFT);
-Controller.captureKeyEvents(STRAFE_RIGHT);
-
-Script.scriptEnding.connect(function () {
-    Controller.releaseKeyEvents(STRAFE_LEFT);
-    Controller.releaseKeyEvents(STRAFE_RIGHT);
-});
-
captureMouseEvents()
-
Disable processing of mouse "move", "press", "double-press", and "release" events into - Controller.Hardware.Keyboard outputs.
-
-
Example
-

Disable Controller.Hardware.Keyboard mouse events for a short period.

var MAPPING_NAME = "com.highfidelity.controllers.example.newMapping";
-var mapping = Controller.newMapping(MAPPING_NAME);
-mapping.from(Controller.Hardware.Keyboard.MouseX).to(function (x) {
-    print("Mouse x = " + x);
-});
-mapping.from(Controller.Hardware.Keyboard.MouseY).to(function (y) {
-    print("Mouse y = " + y);
-});
-Controller.enableMapping(MAPPING_NAME);
-Script.scriptEnding.connect(function () {
-    Controller.disableMapping(MAPPING_NAME);
-});
-
-Script.setTimeout(function () {
-    Controller.captureMouseEvents();
-}, 5000);
-
-Script.setTimeout(function () {
-    Controller.releaseMouseEvents();
-}, 10000);
-
captureTouchEvents()
-
Disable processing of touch "begin", "update", and "end" events into - Controller.Hardware.Keyboard, - Controller.Hardware.Touchscreen, and - Controller.Hardware.TouchscreenVirtualPad outputs.
-
-
captureWheelEvents()
-
Disable processing of mouse wheel rotation events into - Controller.Hardware.Keyboard outputs.
-
-
disableMapping(mappingName)
-
Disable a controller mapping. When disabled, the routes in the mapping have no effect.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
mappingName stringThe name of the mapping.
-
-
enableMapping(mappingName, enable)
-
Enable or disable a controller mapping. When enabled, the routes in the mapping have effect.
-
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
mappingName stringThe name of the mapping.
enable boolean trueIf true then the mapping is enabled, otherwise it is disabled.
-
-
findAction(actionName) → {number}
-
Find the ID of an action from its name.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
actionName stringThe name of the action: one of the - Controller.Actions property names.
-
-
Returns:
-
The integer ID of the action if found, otherwise 4095. Note that this value is not the same as the value of the relevant - Controller.Actions property.
-
-
Type: number
-
Example
-

Get the ID of the "TranslateY" action. Compare with the property value.

var actionID = Controller.findAction("TranslateY");
-print("Action ID = " + actionID);  // 1
-print("Property value = " + Controller.Actions.TranslateY);  // 537001728 or similar value.
-
findDevice(deviceName) → {number}
-
Find the ID of a specific controller from its device name.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
deviceName stringThe name of the device to find.
-
-
Returns:
-
The integer ID of the device if available, otherwise 65535.
-
-
Type: number
-
Example
-

Get the ID of the Oculus Touch.

var deviceID = Controller.findDevice("OculusTouch");
-print("Device ID = " + deviceID);
-
getActionNames() → {Array.<string>}
-
Get the names of all actions available as properties of - Controller.Actions.
-
-
Returns:
-
An array of action names.
-
-
Type: Array.<string>
-
Example
-

Get the names of all actions.

var actionNames = Controller.getActionNames();
-print("Action names: " + JSON.stringify(actionNames));
-// ["TranslateX","TranslateY","TranslateZ","Roll", ...
-
getActions() → {Controller.Actions}
-
Get the - Controller.Actions property tree. Calling this function is the same as using the - Controller property, Controller.Actions.
-
-
Returns:
-
The - Controller.Actions property tree.
-
-
Type: Controller.Actions
-
getActionValue(actionID) → {number}
-
Get the current value of an action.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
actionID numberThe integer ID of the action.
-
-
Returns:
-
The current value of the action.
-
-
Type: number
-
Example
-

Periodically report the value of the "TranslateX" action.

var actionID = Controller.findAction("TranslateX");
-
-function reportValue() {
-    print(Controller.getActionValue(actionID));
-}
-reportTimer = Script.setInterval(reportValue, 1000);
-
getAllActions() → {Array.<Action>}
-
Get a list of all available actions.
-
-
Deprecated:
-
-
    -
  • This function no longer works.
  • -
-
-
-
Returns:
-
All available actions.
-
-
Type: Array.<Action>
-
getAvailableInputs(deviceID) → {Array.<NamedPair>}
-
Get a list of all available inputs for a hardware device.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
deviceID numberInteger ID of the hardware device.
-
-
Deprecated:
-
-
    -
  • This function no longer works.
  • -
-
-
-
Returns:
-
All available inputs for the device.
-
-
Type: Array.<NamedPair>
-
getAxisValue(source) → {number}
-
Get the value of a controller axis output. Note: Also gets the value of a controller button output.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
source numberThe - Controller.Standard or - Controller.Hardware item.
-
-
Returns:
-
The current value of the controller item output if source is valid, otherwise 0.
-
-
Type: number
-
getAxisValue(source, deviceopt) → {number}
-
Get the value of an axis control on a particular device.
-
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDefaultDescription
source StandardAxisChannelThe axis to get the value of.
device number <optional> -
-
0The ID of the hardware device to get the value from. The default value of 0 corresponds to Standard.
-
-
Deprecated:
-
-
    -
  • This function no longer works.
  • -
-
-
-
Returns:
-
The current value of the axis if the parameters are valid, otherwise 0.
-
-
Type: number
-
getButtonValue(source, deviceopt) → {number}
-
Get the value of a button on a particular device.
-
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDefaultDescription
source StandardButtonChannelThe button to get the value of.
device number <optional> -
-
0The ID of the hardware device to get the value from. The default value of 0 corresponds to Standard.
-
-
Deprecated:
-
-
    -
  • This function no longer works.
  • -
-
-
-
Returns:
-
The current value of the button if the parameters are valid, otherwise 0.
-
-
Type: number
-
getDeviceName(deviceID) → {string}
-
Find the name of a particular controller from its device ID.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
deviceID numberThe integer ID of the device.
-
-
Returns:
-
The name of the device if found, otherwise "unknown".
-
-
Type: string
-
Example
-

Get the name of the Oculus Touch controller from its ID.

var deviceID = Controller.findDevice("OculusTouch");
-print("Device ID = " + deviceID);
-
-var deviceName = Controller.getDeviceName(deviceID);
-print("Device name = " + deviceName);
-
getDeviceNames() → {Array.<string>}
-
Get the names of all currently available controller devices plus "Actions", "Application", and "Standard".
-
-
Returns:
-
An array of device names.
-
-
Type: Array.<string>
-
Example
-

Get the names of all currently available controller devices.

var deviceNames = Controller.getDeviceNames();
-print(JSON.stringify(deviceNames));
-// ["Standard","Keyboard","LeapMotion","OculusTouch","Application","Actions"] or similar.
-
getHardware() → {Controller.Hardware}
-
Get the - Controller.Hardware property tree. Calling this function is the same as using the - Controller property, Controller.Hardware.
-
-
Returns:
-
The - Controller.Hardware property tree.
-
-
Type: Controller.Hardware
-
getInputRecorderSaveDirectory() → {string}
-
Get the directory in which input recordings are saved.
-
-
Returns:
-
The directory in which input recordings are saved.
-
-
Type: string
-
getPoseValue(source) → {Pose}
-
Get the value of a controller pose output.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
source numberThe - Controller.Standard or - Controller.Hardware pose output.
-
-
Returns:
-
The current value of the controller pose output if source is a pose output, otherwise an invalid pose with Pose.valid == false.
-
-
Type: Pose
-
getPoseValue(source, deviceopt) → {Pose}
-
- Get the value of an pose control on a particular device.
-
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDefaultDescription
source StandardPoseChannelThe pose to get the value of.
device number <optional> -
-
0The ID of the hardware device to get the value from. The default value of 0 corresponds to Standard.
-
-
Deprecated:
-
-
    -
  • This function no longer works.
  • -
-
-
-
Returns:
-
The current value of the controller pose output if the parameters are valid, otherwise an invalid pose with Pose.valid == false.
-
-
Type: Pose
-
getRecommendedHUDRect() → {Rect}
-
Get the recommended area to position UI on the HUD surface if in HMD mode or Interface's window interior if in desktop mode.
-
-
Returns:
-
The recommended area in which to position UI.
-
-
Type: Rect
-
getStandard() → {Controller.Standard}
-
Get the - Controller.Standard property tree. Calling this function is the same as using the - Controller property, Controller.Standard.
-
-
Returns:
-
The - Controller.Standard property tree.
-
-
Type: Controller.Standard
-
getValue(source) → {number}
-
Get the value of a controller button or axis output. Note: Also gets the value of a controller axis output.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
source numberThe - Controller.Standard or - Controller.Hardware item.
-
-
Returns:
-
The current value of the controller item output if source is valid, otherwise 0.
-
-
Type: number
-
Example
-

Report the Standard and Vive right trigger values.

var triggerValue = Controller.getValue(Controller.Standard.RT);
-print("Trigger value: " + triggerValue);
-
-if (Controller.Hardware.Vive) {
-    triggerValue = Controller.getValue(Controller.Hardware.Vive.RT);
-    print("Vive trigger value: " + triggerValue);
-} else {
-    print("No Vive present");
-}
-
getViewportDimensions() → {Vec2}
-
Get the dimensions of the Interface window's interior if in desktop mode or the HUD surface if in HMD mode.
-
-
Returns:
-
The dimensions of the Interface window interior if in desktop mode or HUD surface if in HMD mode.
-
-
Type: Vec2
-
hardwareChanged() → {Signal}
-
Triggered when a device is registered or unregistered by a plugin. Not all plugins generate hardwareChanged events: for example connecting or disconnecting a mouse will not generate an event but connecting or disconnecting an Xbox - controller will.
-
-
Returns:
-
-
Type: Signal
-
inputEvent(action, value) → {Signal}
-
Triggered when there is a new controller input event.
-
Parameters:
- - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
action numberThe input action, per - Controller.Standard.
value numberThe value associated with the input action.
-
-
Returns:
-
-
Type: Signal
-
Example
-

Report input events as they occur.

var inputNamesForID = {};
-for (var property in Controller.Standard) {
-    inputNamesForID[Controller.Standard[property]] = "Controller.Standard." + property;
-}
-
-function onInputEvent(input, value) {
-    print("onInputEvent() : " + input + " ( " + inputNamesForID[input] + " ) ; " + value);
-}
-
-Controller.inputEvent.connect(onInputEvent);
-
-Script.scriptEnding.connect(function () {
-    Controller.inputEvent.disconnect(onInputEvent);
-});
-
keyPressEvent(event) → {Signal}
-
Triggered when a keyboard key is pressed.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event KeyEventDetails of the key press.
-
-
Returns:
-
-
Type: Signal
-
Example
-

Report the KeyEvent details for each key press.

Controller.keyPressEvent.connect(function (event) {
-    print(JSON.stringify(event));
-});
-
keyReleaseEvent(event) → {Signal}
-
Triggered when a keyboard key is released from being pressed.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event KeyEventDetails of the key release.
-
-
Returns:
-
-
Type: Signal
-
loadInputRecording(file)
-
Load an input recording, ready for play back.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
file stringThe path to the recording file, prefixed by "file:///".
-
-
loadMapping(jsonURL) → {MappingObject}
-
Create a new controller mapping from a - MappingJSON JSON file at a URL. Use - enableMapping to enable the mapping for it to take effect.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
jsonURL stringThe URL the - MappingJSON JSON file.
-
-
To Do:
-
-
    -
  • Implement this function. It currently does not load the mapping from the file; it just returns null.
  • -
-
-
-
Returns:
-
A controller mapping object.
-
-
Type: MappingObject
-
mouseDoublePressEvent(event) → {Signal}
-
Triggered when a mouse button is double-pressed.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event MouseEventDetails of the button double-press.
-
-
Returns:
-
-
Type: Signal
-
mouseMoveEvent(event) → {Signal}
-
Triggered when the mouse moves.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event MouseEventDetails of the mouse movement.
-
-
Returns:
-
-
Type: Signal
-
Example
-

Report the MouseEvent details for each mouse move.

Controller.mouseMoveEvent.connect(function (event) {
-    print(JSON.stringify(event));
-});
-
mousePressEvent(event) → {Signal}
-
Triggered when a mouse button is pressed.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event MouseEventDetails of the button press.
-
-
Returns:
-
-
Type: Signal
-
mouseReleaseEvent(event) → {Signal}
-
Triggered when a mouse button is released from being pressed.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event MouseEventDetails of the button release.
-
-
Returns:
-
-
Type: Signal
-
newMapping(mappingName) → {MappingObject}
-
Create a new controller mapping. Routes can then be added to the mapping using - MappingObject methods and routed to Standard controls, Actions, or script functions using - RouteObject methods. The mapping can then be enabled using - enableMapping for it to take effect.
-
Parameters:
- - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
mappingName string Uuid.generate()A unique name for the mapping. If not specified a new UUID generated by - Uuid.generate is used.
-
-
Returns:
-
A controller mapping object.
-
-
Type: MappingObject
-
Example
-

Create a simple mapping that makes the right trigger move your avatar up.

var MAPPING_NAME = "com.highfidelity.controllers.example.newMapping";
-var mapping = Controller.newMapping(MAPPING_NAME);
-
-mapping.from(Controller.Standard.RT).to(Controller.Actions.TranslateY);
-Controller.enableMapping(MAPPING_NAME);
-
-Script.scriptEnding.connect(function () {
-    Controller.disableMapping(MAPPING_NAME);
-});
-
parseMapping(jsonString) → {MappingObject}
-
Create a new controller mapping from a - MappingJSON string. Use - enableMapping to enable the mapping for it to take effect.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
jsonString stringA JSON string of the - MappingJSON.
-
-
Returns:
-
A controller mapping object.
-
-
Type: MappingObject
-
Example
-

Create a simple mapping that makes the right trigger move your avatar up.

var mappingJSON = {
-    "name": "com.highfidelity.controllers.example.jsonMapping",
-    "channels": [
-        { "from": "Standard.RT", "to": "Actions.TranslateY" }
-    ]
-};
-
-var mapping = Controller.parseMapping(JSON.stringify(mappingJSON));
-mapping.enable();
-
-Script.scriptEnding.connect(function () {
-    mapping.disable();
-});
-
releaseActionEvents()
-
Enable translating and rotating the user's avatar in response to keyboard and controller controls that were disabled using - captureActionEvents.
-
-
releaseEntityClickEvents()
-
Re-enable - Entities.mousePressOnEntity and - Entities.mouseDoublePressOnEntity events on entities that were disabled using - captureEntityClickEvents.
-
-
releaseJoystick(joystickID)
-
Re-enable default Interface actions for a joystick that has been disabled using - captureJoystick.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
joystickID numberThe integer ID of the joystick.
-
-
Deprecated:
-
-
    -
  • This function no longer has any effect.
  • -
-
-
-
releaseKeyEvents(event)
-
Re-enable default Interface actions for a particular key event that has been disabled using - captureKeyEvents.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event KeyEventDetails of the key event to release from capture. The key property must be specified. The text property is ignored. The other properties default to false.
-
-
releaseMouseEvents()
-
Enable processing of mouse "move", "press", "double-press", and "release" events into - Controller.Hardware.Keyboard outputs that were disabled using - captureMouseEvents.
-
-
releaseTouchEvents()
-
Enable processing of touch "begin", "update", and "end" events into - Controller.Hardware.Keyboard, - Controller.Hardware.Touchscreen, and - Controller.Hardware.TouchscreenVirtualPad outputs that were disabled using - captureTouchEvents.
-
-
releaseWheelEvents()
-
Enable processing of mouse wheel rotation events into - Controller.Hardware.Keyboard outputs that wer disabled using - captureWheelEvents.
-
-
saveInputRecording()
-
Save the current recording to a file. The current recording may have been recorded by - startInputRecording and - stopInputRecording, or loaded by - loadInputRecording. It is saved in the directory returned by - getInputRecorderSaveDirectory.
-
-
setVPadEnabled(enable)
-
Enables or disables the virtual game pad that is displayed on certain devices (e.g., Android).
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
enable booleanIf true then the virtual game pad doesn't work, otherwise it does work provided that it is not hidden by - setVPadHidden.
-
-
setVPadExtraBottomMargin(margin)
-
Sets the amount of extra margin between the virtual game pad that is displayed on certain devices (e.g., Android) and the bottom of the display.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
margin numberInteger number of pixels in the extra margin.
-
-
setVPadHidden(hidden)
-
Shows or hides the virtual game pad that is displayed on certain devices (e.g., Android).
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
hidden booleanIf true then the virtual game pad is hidden, otherwise it is shown.
-
-
startInputPlayback()
-
Play back the current recording from the beginning. The current recording may have been recorded by - startInputRecording and - stopInputRecording, or loaded by - loadInputRecording. Playback repeats in a loop until - stopInputPlayback is called.
-
-
Example
-

Play back a controller recording.

var file = Window.browse("Select Recording", Controller.getInputRecorderSaveDirectory());
-if (file !== null) {
-    print("Play recording: " + file);
-    Controller.loadInputRecording("file:///" + file);
-    Controller.startInputPlayback();
-
-    // Stop playback after 20s.
-    Script.setTimeout(function () {
-        print("Stop playing recording");
-        Controller.stopInputPlayback();
-    }, 20000);
-}
-
startInputRecording()
-
Start making a recording of currently active controllers.
-
-
Example
-

Make a controller recording.

// Delay start of recording for 2s.
-Script.setTimeout(function () {
-    print("Start input recording");
-    Controller.startInputRecording();
-}, 2000);
-
-// Make a 10s recording.
-Script.setTimeout(function () {
-    print("Stop input recording");
-    Controller.stopInputRecording();
-    Controller.saveInputRecording();
-    print("Input recording saved in: " + Controller.getInputRecorderSaveDirectory());
-}, 12000);
-
stopInputPlayback()
-
Stop play back of a recording started by - startInputPlayback.
-
-
stopInputRecording()
-
Stop making a recording started by - startInputRecording.
-
-
touchBeginEvent(event) → {Signal}
-
Triggered when a touch event starts in the Interface window on a touch-enabled display or device.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event TouchEventDetails of the touch begin.
-
-
Returns:
-
-
Type: Signal
-
Example
-

Report the TouchEvent details when a touch event starts.

Controller.touchBeginEvent.connect(function (event) {
-    print(JSON.stringify(event));
-});
-
touchEndEvent(event) → {Signal}
-
Triggered when a touch event ends in the Interface window on a touch-enabled display or device.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event TouchEventDetails of the touch end.
-
-
Returns:
-
-
Type: Signal
-
touchUpdateEvent(event) → {Signal}
-
Triggered when a touch event update occurs in the Interface window on a touch-enabled display or device.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event TouchEventDetails of the touch update.
-
-
Returns:
-
-
Type: Signal
-
triggerHapticPulse(strength, duration, hand)
-
Triggers a haptic pulse on connected and enabled devices that have the capability.
-
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
strength numberThe strength of the haptic pulse, 0.01.0.
duration numberThe duration of the haptic pulse, in milliseconds.
hand Controller.Hand 2The hand or hands to trigger the haptic pulse on.
-
-
Example
-

Trigger a haptic pulse on the right hand.

var HAPTIC_STRENGTH = 0.5;
-var HAPTIC_DURATION = 10;
-var RIGHT_HAND = 1;
-Controller.triggerHapticPulse(HAPTIC_STRENGTH, HAPTIC_DURATION, RIGHT_HAND);
-
triggerHapticPulseOnDevice(deviceID, strength, duration, hand)
-
Triggers a haptic pulse on a particular device if connected and enabled and it has the capability.
-
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
deviceID numberThe ID of the device to trigger the haptic pulse on.
strength numberThe strength of the haptic pulse, 0.01.0.
duration numberThe duration of the haptic pulse, in milliseconds.
hand Controller.Hand 2The hand or hands to trigger the haptic pulse on.
-
-
Example
-

Trigger a haptic pulse on an Oculus Touch controller.

var HAPTIC_STRENGTH = 0.5;
-var deviceID = Controller.findDevice("OculusTouch");
-var HAPTIC_DURATION = 10;
-var RIGHT_HAND = 1;
-Controller.triggerHapticPulseOnDevice(deviceID, HAPTIC_STRENGTH, HAPTIC_DURATION, RIGHT_HAND);
-
triggerShortHapticPulse(strength, hand)
-
Triggers a 250ms haptic pulse on connected and enabled devices that have the capability.
-
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
strength numberThe strength of the haptic pulse, 0.01.0.
hand Controller.Hand 2The hand or hands to trigger the haptic pulse on.
-
-
triggerShortHapticPulseOnDevice(deviceID, strength, hand)
-
Triggers a 250ms haptic pulse on a particular device if connected and enabled and it has the capability.
-
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
deviceID numberThe ID of the device to trigger the haptic pulse on.
strength numberThe strength of the haptic pulse, 0.01.0.
hand Controller.Hand 2The hand or hands to trigger the haptic pulse on.
-
-
wheelEvent(event) → {Signal}
-
Triggered when the mouse wheel is rotated.
-
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
event WheelEventDetails of the wheel movement.
-
-
Returns:
-
-
Type: Signal
-
Example
-

Report the WheelEvent details for each wheel rotation.

Controller.wheelEvent.connect(function (event) {
-    print(JSON.stringify(event));
-});
-     
-

Type Definitions

-

Actions

-
-

The Controller.Actions object has properties representing predefined actions on the user's avatar and Interface. The property values are integer IDs, uniquely identifying each action. Read-only. These can be used as end - points in the routes of a - MappingObject. The data routed to each action is either a number or a - Pose.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDataDescription
Avatar Movement
TranslateXnumbernumberMove the user's avatar in the direction of its x-axis, if the camera isn't in independent or mirror modes.
TranslateYnumbernumberMove the user's avatar in the direction of its y-axis, if the camera isn't in independent or mirror modes.
TranslateZnumbernumberMove the user's avatar in the direction of its z-axis, if the camera isn't in independent or mirror modes.
PitchnumbernumberRotate the user's avatar head and attached camera about its negative x-axis (i.e., positive values pitch down), if the camera isn't in HMD, independent, or mirror modes.
YawnumbernumberRotate the user's avatar about its y-axis, if the camera isn't in independent or mirror modes.
RollnumbernumberNo action.
StepTranslateXnumbernumberNo action.
StepTranslateYnumbernumberNo action.
StepTranslateZnumbernumberNo action.
StepPitchnumbernumberNo action.
StepYawnumbernumberRotate the user's avatar about its y-axis in a step increment, if the camera isn't in independent or mirror modes.
StepRollnumbernumberNo action.
Avatar Skeleton
Hipsnumber - Pose - Set the hips pose of the user's avatar.
Spine2number - Pose - Set the spine2 pose of the user's avatar.
Headnumber - Pose - Set the head pose of the user's avatar.
LeftArmnumber - Pose - Set the left arm pose of the user's avatar.
RightArmnumber - Pose - Set the right arm pose of the user's avatar.
LeftHandnumber - Pose - Set the left hand pose of the user's avatar.
LeftHandThumb1number - Pose - Set the left thumb 1 finger joint pose of the user's avatar.
LeftHandThumb2number - Pose - Set the left thumb 2 finger joint pose of the user's avatar.
LeftHandThumb3number - Pose - Set the left thumb 3 finger joint pose of the user's avatar.
LeftHandThumb4number - Pose - Set the left thumb 4 finger joint pose of the user's avatar.
LeftHandIndex1number - Pose - Set the left index 1 finger joint pose of the user's avatar.
LeftHandIndex2number - Pose - Set the left index 2 finger joint pose of the user's avatar.
LeftHandIndex3number - Pose - Set the left index 3 finger joint pose of the user's avatar.
LeftHandIndex4number - Pose - Set the left index 4 finger joint pose of the user's avatar.
LeftHandMiddle1number - Pose - Set the left middle 1 finger joint pose of the user's avatar.
LeftHandMiddle2number - Pose - Set the left middle 2 finger joint pose of the user's avatar.
LeftHandMiddle3number - Pose - Set the left middle 3 finger joint pose of the user's avatar.
LeftHandMiddle4number - Pose - Set the left middle 4 finger joint pose of the user's avatar.
LeftHandRing1number - Pose - Set the left ring 1 finger joint pose of the user's avatar.
LeftHandRing2number - Pose - Set the left ring 2 finger joint pose of the user's avatar.
LeftHandRing3number - Pose - Set the left ring 3 finger joint pose of the user's avatar.
LeftHandRing4number - Pose - Set the left ring 4 finger joint pose of the user's avatar.
LeftHandPinky1number - Pose - Set the left pinky 1 finger joint pose of the user's avatar.
LeftHandPinky2number - Pose - Set the left pinky 2 finger joint pose of the user's avatar.
LeftHandPinky3number - Pose - Set the left pinky 3 finger joint pose of the user's avatar.
LeftHandPinky4number - Pose - Set the left pinky 4 finger joint pose of the user's avatar.
RightHandnumber - Pose - Set the right hand of the user's avatar.
RightHandThumb1number - Pose - Set the right thumb 1 finger joint pose of the user's avatar.
RightHandThumb2number - Pose - Set the right thumb 2 finger joint pose of the user's avatar.
RightHandThumb3number - Pose - Set the right thumb 3 finger joint pose of the user's avatar.
RightHandThumb4number - Pose - Set the right thumb 4 finger joint pose of the user's avatar.
RightHandIndex1number - Pose - Set the right index 1 finger joint pose of the user's avatar.
RightHandIndex2number - Pose - Set the right index 2 finger joint pose of the user's avatar.
RightHandIndex3number - Pose - Set the right index 3 finger joint pose of the user's avatar.
RightHandIndex4number - Pose - Set the right index 4 finger joint pose of the user's avatar.
RightHandMiddle1number - Pose - Set the right middle 1 finger joint pose of the user's avatar.
RightHandMiddle2number - Pose - Set the right middle 2 finger joint pose of the user's avatar.
RightHandMiddle3number - Pose - Set the right middle 3 finger joint pose of the user's avatar.
RightHandMiddle4number - Pose - Set the right middle 4 finger joint pose of the user's avatar.
RightHandRing1number - Pose - Set the right ring 1 finger joint pose of the user's avatar.
RightHandRing2number - Pose - Set the right ring 2 finger joint pose of the user's avatar.
RightHandRing3number - Pose - Set the right ring 3 finger joint pose of the user's avatar.
RightHandRing4number - Pose - Set the right ring 4 finger joint pose of the user's avatar.
RightHandPinky1number - Pose - Set the right pinky 1 finger joint pose of the user's avatar.
RightHandPinky2number - Pose - Set the right pinky 2 finger joint pose of the user's avatar.
RightHandPinky3number - Pose - Set the right pinky 3 finger joint pose of the user's avatar.
RightHandPinky4number - Pose - Set the right pinky 4 finger joint pose of the user's avatar.
LeftFootnumber - Pose - Set the left foot pose of the user's avatar.
RightFootnumber - Pose - Set the right foot pose of the user's avatar.
Application
BoomInnumbernumberZoom camera in from third person toward first person view.
BoomOutnumbernumberZoom camera out from first person to third person view.
CycleCameranumbernumberCycle the camera view from first person, to third person, to full screen mirror, then back to first person and repeat.
ContextMenunumbernumberShow / hide the tablet.
ToggleMutenumbernumberToggle the microphone mute.
ToggleOverlaynumbernumberToggle the display of overlays.
SprintnumbernumberSet avatar sprint mode.
ReticleClicknumbernumberSet mouse-pressed.
ReticleXnumbernumberMove the cursor left/right in the x direction.
ReticleYnumbernumbermove the cursor up/down in the y direction.
ReticleLeftnumbernumberMove the cursor left.
ReticleRightnumbernumberMove the cursor right.
ReticleUpnumbernumberMove the cursor up.
ReticleDownnumbernumberMove the cursor down.
UiNavLateralnumbernumberGenerate a keyboard left or right arrow key event.
UiNavVerticalnumbernumberGenerate a keyboard up or down arrow key event.
UiNavGroupnumbernumberGenerate a keyboard tab or back-tab key event.
UiNavSelectnumbernumberGenerate a keyboard Enter key event.
UiNavBacknumbernumberGenerate a keyboard Esc key event.
LeftHandClicknumbernumberDeprecated: No action.
RightHandClicknumbernumberDeprecated: No action.
ShiftnumbernumberDeprecated: No action.
PrimaryActionnumbernumberDeprecated: No action.
SecondaryActionnumbernumberDeprecated: No action.
Aliases
BackwardnumbernumberAlias for TranslateZ in the positive direction.
ForwardnumbernumberAlias for TranslateZ in the negative direction.
StrafeRightnumbernumberAlias for TranslateX in the positive direction.
StrafeLeftnumbernumberAlias for TranslateX in the negative direction.
UpnumbernumberAlias for TranslateY in the positive direction.
DownnumbernumberAlias for TranslateY in the negative direction.
PitchDownnumbernumberAlias for Pitch in the positive direction.
PitchUpnumbernumberAlias for Pitch in the negative direction.
YawLeftnumbernumberAlias for Yaw in the positive direction.
YawRightnumbernumberAlias for Yaw in the negative direction.
Deprecated Aliases
LEFT_HANDnumber - Pose - Deprecated: Use LeftHand instead.
RIGHT_HANDnumber - Pose - Deprecated: Use RightHand instead.
BOOM_INnumbernumberDeprecated: Use BoomIn instead.
BOOM_OUTnumbernumberDeprecated: Use BoomOut instead.
CONTEXT_MENUnumbernumberDeprecated: Use ContextMenu instead.
TOGGLE_MUTEnumbernumberDeprecated: Use ToggleMute instead.
SPRINTnumbernumberDeprecated: Use Sprint instead.
LONGITUDINAL_BACKWARDnumbernumberDeprecated: Use Backward instead.
LONGITUDINAL_FORWARDnumbernumberDeprecated: Use Forward instead.
LATERAL_LEFTnumbernumberDeprecated: Use StrafeLeft instead.
LATERAL_RIGHTnumbernumberDeprecated: Use StrafeRight instead.
VERTICAL_UPnumbernumberDeprecated: Use Up instead.
VERTICAL_DOWNnumbernumberDeprecated: Use Down instead.
PITCH_DOWNnumbernumberDeprecated: Use PitchDown instead.
PITCH_UPnumbernumberDeprecated: Use PitchUp instead.
YAW_LEFTnumbernumberDeprecated: Use YawLeft instead.
YAW_RIGHTnumbernumberDeprecated: Use YawRight instead.
LEFT_HAND_CLICKnumbernumberDeprecated: Use LeftHandClick instead.
RIGHT_HAND_CLICKnumbernumberDeprecated: Use RightHandClick instead.
SHIFTnumbernumberDeprecated: Use Shift instead.
ACTION1numbernumberDeprecated: Use PrimaryAction instead.
ACTION2numbernumberDeprecated: Use SecondaryAction instead.
Deprecated Trackers
TrackedObject00number - Pose - Deprecated: No action.
TrackedObject01number - Pose - Deprecated: No action.
TrackedObject02number - Pose - Deprecated: No action.
TrackedObject03number - Pose - Deprecated: No action.
TrackedObject04number - Pose - Deprecated: No action.
TrackedObject05number - Pose - Deprecated: No action.
TrackedObject06number - Pose - Deprecated: No action.
TrackedObject07number - Pose - Deprecated: No action.
TrackedObject08number - Pose - Deprecated: No action.
TrackedObject09number - Pose - Deprecated: No action.
TrackedObject10number - Pose - Deprecated: No action.
TrackedObject11number - Pose - Deprecated: No action.
TrackedObject12number - Pose - Deprecated: No action.
TrackedObject13number - Pose - Deprecated: No action.
TrackedObject14number - Pose - Deprecated: No action.
TrackedObject15number - Pose - Deprecated: No action.
-
-
-

Hand

-
-

Some controller actions may be associated with one or both hands:

- - - - - - - - - - - - - - - - - - - - - -
ValueDescription
0Left hand.
1Right hand.
2Both hands.
-
-
Type:
-
    -
  • number
  • -
-
-

Hardware

-
-

The Controller.Hardware object has properties representing standard and hardware-specific controller and computer outputs, plus predefined actions on Interface and the user's avatar. Read-only. The outputs can be mapped - to actions or functions in a - RouteObject mapping. Additionally, hardware-specific controller outputs can be mapped to standard controller outputs. -

Controllers typically implement a subset of the - Controller.Standard controls, plus they may implement some extras. Some common controllers are included in the table. You can see the outputs provided by these and others by viewing their - MappingJSON files at - https://github.com/highfidelity/hifi/tree/master/interface/resources/controllers.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
Controller.Hardware.ActionsobjectSynonym for - Controller.Actions.
Controller.Hardware.ApplicationobjectInterface state outputs. See - Controller.Hardware-Application.
Controller.Hardware.KeyboardobjectKeyboard, mouse, and touch pad outputs. See - Controller.Hardware-Keyboard.
Controller.Hardware.OculusTouchobjectOculus Rift HMD outputs. See - Controller.Hardware-OculusTouch.
Controller.Hardware.ViveobjectVive HMD outputs. See - Controller.Hardware-Vive.
-
-
-
Example
-

List all the currently available Controller.Hardware properties.

function printProperties(string, item) {
-    print(string);
-    for (var key in item) {
-        if (item.hasOwnProperty(key)) {
-            printProperties(string + "." + key, item[key]);
-        }
-    }
-}
-
-printProperties("Controller.Hardware", Controller.Hardware);
- 
-

Hardware-Application

-
-

The Controller.Hardware.Application object has properties representing Interface's state. The property values are integer IDs, uniquely identifying each output. Read-only. These can be mapped to actions or functions or - Controller.Standard items in a - RouteObject mapping (e.g., using the - RouteObject#when method). Each data value is either 1.0 for "true" or 0.0 for "false".

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDataDescription
CameraFirstPersonnumbernumberThe camera is in first-person mode.
CameraThirdPersonnumbernumberThe camera is in third-person mode.
CameraFSMnumbernumberThe camera is in full screen mirror mode.
CameraIndependentnumbernumberThe camera is in independent mode.
CameraEntitynumbernumberThe camera is in entity mode.
InHMDnumbernumberThe user is in HMD mode.
AdvancedMovementnumbernumberAdvanced movement controls are enabled.
SnapTurnnumbernumberSnap turn is enabled.
GroundednumbernumberThe user's avatar is on the ground.
NavigationFocusednumbernumberNot used.
-
-
-

Hardware-Keyboard

-
-

The Controller.Hardware.Keyboard object has properties representing keyboard, mouse, and display touch events. The property values are integer IDs, uniquely identifying each output. Read-only. These can be mapped to actions - or functions or Controller.Standard items in a - RouteObject mapping. For presses, each data value is either 1.0 for "true" or 0.0 for "false".

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeData - Description
09numbernumberA "0" – "1" key on the keyboard or keypad is pressed.
AZnumbernumberA "A" – "Z" key on the keyboard is pressed.
SpacenumbernumberThe space bar on the keyboard is pressed.
TabnumbernumberThe tab key on the keyboard is pressed.
ShiftnumbernumberThe shift key on the keyboard is pressed.
ControlnumbernumberThe control key on the keyboard is pressed. (The "Command" key on OSX.)
LeftnumbernumberThe left arrow key on the keyboard or keypad is pressed.
RightnumbernumberThe right arrow key on the keyboard or keypad is pressed.
UpnumbernumberThe up arrow key on the keyboard or keypad is pressed.
DownnumbernumberThe down arrow key on the keyboard or keypad is pressed.
PgUpnumbernumberThe page up key on the keyboard or keypad is pressed.
PgDownnumbernumberThe page down key on the keyboard or keypad is pressed.
LeftMouseButtonnumbernumberThe left mouse button pressed.
MiddleMouseButtonnumbernumberThe middle mouse button pressed.
RightMouseButtonnumbernumberThe right mouse button pressed.
LeftMouseClickednumbernumberThe left mouse button clicked.
MiddleMouseClickednumbernumberThe middle mouse button clicked.
RightMouseClickednumbernumberThe right mouse button clicked.
MouseMoveRightnumbernumberThe mouse moved right.
MouseMoveLeftnumbernumberThe mouse moved left.
MouseMoveUpnumbernumberThe mouse moved up.
MouseMoveDownnumbernumberThe mouse moved down.
MouseXnumbernumberThe mouse x-coordinate changed. The data value is its new x-coordinate value.
MouseYnumbernumberThe mouse y-coordinate changed. The data value is its new y-coordinate value.
MouseWheelRightnumbernumberThe mouse wheel rotated left. The data value is the number of units rotated (typically 1.0).
MouseWheelLeftnumbernumberThe mouse wheel rotated left. The data value is the number of units rotated (typically 1.0).
MouseWheelUpnumbernumberThe mouse wheel rotated up. The data value is the number of units rotated (typically 1.0).
MouseWheelDownnumbernumberThe mouse wheel rotated down. The data value is the number of units rotated (typically 1.0).
TouchpadRightnumbernumberThe average touch on a touch-enabled device moved right. The data value is how far the average position of all touch points moved.
TouchpadLeftnumbernumberThe average touch on a touch-enabled device moved left. The data value is how far the average position of all touch points moved.
TouchpadUpnumbernumberThe average touch on a touch-enabled device moved up. The data value is how far the average position of all touch points moved.
TouchpadDownnumbernumberThe average touch on a touch-enabled device moved down. The data value is how far the average position of all touch points moved.
-
-
-
To Do:
-
-
    -
  • Currently, the mouse wheel in an ordinary mouse generates left/right wheel events instead of up/down.
  • -
-
-
-

Hardware-OculusTouch

-
-

The Controller.Hardware.OculusTouch object has properties representing Oculus Rift. The property values are integer IDs, uniquely identifying each output. Read-only. These can be mapped to actions or functions or Controller.Standard items in a - RouteObject mapping.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDataDescription
Buttons
Anumbernumber"A" button pressed.
Bnumbernumber"B" button pressed.
Xnumbernumber"X" button pressed.
Ynumbernumber"Y" button pressed.
LeftApplicationMenunumbernumberLeft application menu button pressed.
RightApplicationMenunumbernumberRight application menu button pressed.
Sticks
LXnumbernumberLeft stick x-axis scale.
LYnumbernumberLeft stick y-axis scale.
RXnumbernumberRight stick x-axis scale.
RYnumbernumberRight stick y-axis scale.
LSnumbernumberLeft stick button pressed.
RSnumbernumberRight stick button pressed.
LSTouchnumbernumberLeft stick is touched.
RSTouchnumbernumberRight stick is touched.
Triggers
LTnumbernumberLeft trigger scale.
RTnumbernumberRight trigger scale.
LeftGripnumbernumberLeft grip scale.
RightGripnumbernumberRight grip scale.
Finger Abstractions
LeftPrimaryThumbTouchnumbernumberLeft thumb touching primary thumb button.
LeftSecondaryThumbTouchnumbernumberLeft thumb touching secondary thumb button.
LeftThumbUpnumbernumberLeft thumb not touching primary or secondary thumb buttons.
RightPrimaryThumbTouchnumbernumberRight thumb touching primary thumb button.
RightSecondaryThumbTouchnumbernumberRight thumb touching secondary thumb button.
RightThumbUpnumbernumberRight thumb not touching primary or secondary thumb buttons.
LeftPrimaryIndexTouchnumbernumberLeft index finger is touching primary index finger control.
LeftIndexPointnumbernumberLeft index finger is pointing, not touching primary or secondary index finger controls.
RightPrimaryIndexTouchnumbernumberRight index finger is touching primary index finger control.
RightIndexPointnumbernumberRight index finger is pointing, not touching primary or secondary index finger controls.
Avatar Skeleton
Headnumber - Pose - Head pose.
LeftHandnumber - Pose - Left hand pose.
RightHandnumber - Pose - right hand pose.
-
-
-

Hardware-Vive

-
-

The Controller.Hardware.Vive object has properties representing Vive. The property values are integer IDs, uniquely identifying each output. Read-only. These can be mapped to actions or functions or Controller.Standard items in a - RouteObject mapping.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDataDescription
Touch Pad (Sticks)
LXnumbernumberLeft touch pad x-axis scale.
LYnumbernumberLeft touch pad y-axis scale.
RXnumbernumberRight stick x-axis scale.
RYnumbernumberRight stick y-axis scale.
LSnumbernumberLeft touch pad pressed.
LS_CENTERnumbernumberLeft touch pad center pressed.
LS_XnumbernumberLeft touch pad pressed x-coordinate.
LS_YnumbernumberLeft touch pad pressed y-coordinate.
RSnumbernumberRight touch pad pressed.
RS_CENTERnumbernumberRight touch pad center pressed.
RS_XnumbernumberRight touch pad pressed x-coordinate.
RS_YnumbernumberRight touch pad pressed y-coordinate.
LSTouchnumbernumberLeft touch pad is touched.
RSTouchnumbernumberRight touch pad is touched.
Triggers
LTnumbernumberLeft trigger scale.
RTnumbernumberRight trigger scale.
LTClicknumbernumberLeft trigger click.
RTClicknumbernumberRight trigger click.
LeftGripnumbernumberLeft grip scale.
RightGripnumbernumberRight grip scale.
Avatar Skeleton
Hipsnumber - Pose - Hips pose.
Spine2number - Pose - Spine2 pose.
Headnumber - Pose - Head pose.
LeftArmnumber - Pose - Left arm pose.
RightArmnumber - Pose - Right arm pose
LeftHandnumber - Pose - Left hand pose.
RightHandnumber - Pose - Right hand pose.
Trackers
TrackedObject00number - Pose - Tracker 0 pose.
TrackedObject01number - Pose - Tracker 1 pose.
TrackedObject02number - Pose - Tracker 2 pose.
TrackedObject03number - Pose - Tracker 3 pose.
TrackedObject04number - Pose - Tracker 4 pose.
TrackedObject05number - Pose - Tracker 5 pose.
TrackedObject06number - Pose - Tracker 6 pose.
TrackedObject07number - Pose - Tracker 7 pose.
TrackedObject08number - Pose - Tracker 8 pose.
TrackedObject09number - Pose - Tracker 9 pose.
TrackedObject10number - Pose - Tracker 10 pose.
TrackedObject11number - Pose - Tracker 11 pose.
TrackedObject12number - Pose - Tracker 12 pose.
TrackedObject13number - Pose - Tracker 13 pose.
TrackedObject14number - Pose - Tracker 14 pose.
TrackedObject15number - Pose - Tracker 15 pose.
-
-
-

MappingJSON

-
A - MappingObject can be specified in JSON format. A simple example is provided below. Full examples — the default mappings provided in Interface — can be found at - https://github.com/highfidelity/hifi/tree/master/interface/resources/controllers.
-
Type:
-
    -
  • object
  • -
-

Properties:

- - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name stringThe name of the mapping.
channels Array.<Controller.MappingJSONRoute>An array of routes.
-
-
Example
-

A simple mapping JSON that makes the right trigger move your avatar up after a dead zone.

{
-    "name": "com.highfidelity.controllers.example.jsonMapping",
-    "channels": [
-        { 
-            "from": "Standard.RT", 
-            "filters": { "type": "deadZone", "min": 0.05 },
-            "to": "Actions.TranslateY"
-        }
-    ]
-}
-

MappingJSONAxis

-
An axis pair in a - Controller.MappingJSONRoute.
-
Type:
-
    -
  • object
  • -
-

Properties:

- - - - - - - - - - - - - - - -
NameTypeDescription
makeAxis Array.<Array.<string>>A two-member array of single-member arrays of - Controller.Hardware property names. The leading "Controller.Hardware." can be omitted from the property names.
-
-
Example
-

An axis using the keyboard's left and right keys.

{ "makeAxis" : [
-        ["Keyboard.Left"],
-        ["Keyboard.Right"]
-    ]
-}
-

MappingJSONFilter

-
A filter in a - Controller.MappingJSONRoute.
-
Type:
-
    -
  • object
  • -
-

Properties:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
type stringThe name of the filter, being the name of the one of the - RouteObject's filter methods.
? string <optional> -
-
If the filter method has a first parameter, the property name is the name of that parameter and the property value is the value to use.
? string <optional> -
-
If the filter method has a second parameter, the property name is the name of that parameter and the property value is the value to use.
-
-
Example
-

A hysteresis filter.

{ 
-    "type": "hysteresis", 
-    "min": 0.85, 
-    "max": 0.9
-}
-

MappingJSONRoute

-
A route in a - Controller.MappingJSON.
-
Type:
-
    -
  • object
  • -
-

Properties:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDefaultDescription
from string | Controller.MappingJSONAxisThe name of a - Controller.Hardware property name or an axis made from them. If a property name, the leading "Controller.Hardware." can be omitted.
peek boolean <optional> -
-
falseIf - true then peeking is enabled per - RouteObject#peek.
debug boolean <optional> -
-
falseIf true then debug is enabled per - RouteObject#debug.
when string | Array.<string> <optional> -
-
[]One or more numeric - Controller.Hardware property names which are evaluated as booleans and ANDed together. Prepend with a ! to use the logical NOT of the property value. The leading "Controller.Hardware." can be omitted from - the property names.
filters Controller.MappingJSONFilter | Array.<Controller.MappingJSONFilter> <optional> -
-
[]One or more filters in the route.
to stringThe name of a - Controller.Actions or - Controller.Standard property. The leading "Controller." can be omitted.
-
-

Standard

-
-

The Controller.Standard object has properties representing standard controller outputs. Those for physical controllers are based on the XBox controller, with aliases for PlayStation. The property values are integer IDs, uniquely - identifying each output. Read-only. These can be mapped to actions or functions in a - RouteObject mapping.

-

The data value provided by each control is either a number or a - Pose. Numbers are typically normalized to 0.0 or 1.0 for button states, the range 0.0 – 1.0 for unidirectional scales, and the range -1.0 – 1.0 for bidirectional scales.

-

Each hardware device has a mapping from its outputs to Controller.Standard items, specified in a JSON file. For example, - leapmotion.json and - vive.json.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDataDescription
Buttons
Anumbernumber"A" button pressed.
Bnumbernumber"B" button pressed.
Xnumbernumber"X" button pressed.
Ynumbernumber"Y" button pressed.
DLnumbernumberD-pad left pressed.
DRnumbernumberD-pad right pressed.
DUnumbernumberD-pad up pressed.
DDnumbernumberD-pad down pressed.
Startnumbernumber"Start" center button pressed.
Backnumbernumber"Back" center button pressed.
LBnumbernumberLeft bumper button pressed.
RBnumbernumberRight bumper button pressed.
Sticks
LXnumbernumberLeft stick x-axis scale.
LYnumbernumberLeft stick y-axis scale.
RXnumbernumberRight stick x-axis scale.
RYnumbernumberRight stick y-axis scale.
LSnumbernumberLeft stick button pressed.
RSnumbernumberRight stick button pressed.
LSTouchnumbernumberLeft stick is touched.
RSTouchnumbernumberRight stick is touched.
Triggers
LTnumbernumberLeft trigger scale.
RTnumbernumberRight trigger scale.
LTClicknumbernumberLeft trigger click.
RTClicknumbernumberRight trigger click.
LeftGripnumbernumberLeft grip scale.
RightGripnumbernumberRight grip scale.
LeftGripTouchnumbernumberLeft grip is touched.
RightGripTouchnumbernumberRight grip is touched.
Aliases, PlayStation Style Names
CrossnumbernumberAlias for A.
CirclenumbernumberAlias for B.
SquarenumbernumberAlias for X.
TrianglenumbernumberAlias for Y.
LeftnumbernumberAlias for DL.
RightnumbernumberAlias for DR.
UpnumbernumberAlias for DU.
DownnumbernumberAlias for DD.
SelectnumbernumberAlias for Back.
L1numbernumberAlias for LB.
R1numbernumberAlias for RB.
L3numbernumberAlias for LS.
R3numbernumberAlias for RS.
L2numbernumberAlias for LT.
R2numbernumberAlias for RT.
Finger Abstractions
LeftPrimaryThumbnumbernumberLeft primary thumb button pressed.
LeftSecondaryThumbnumbernumberLeft secondary thumb button pressed.
RightPrimaryThumbnumbernumberRight primary thumb button pressed.
RightSecondaryThumbnumbernumberRight secondary thumb button pressed.
LeftPrimaryThumbTouchnumbernumberLeft thumb touching primary thumb button.
LeftSecondaryThumbTouchnumbernumberLeft thumb touching secondary thumb button.
LeftThumbUpnumbernumberLeft thumb not touching primary or secondary thumb buttons.
RightPrimaryThumbTouchnumbernumberRight thumb touching primary thumb button.
RightSecondaryThumbTouchnumbernumberRight thumb touching secondary thumb button.
RightThumbUpnumbernumberRight thumb not touching primary or secondary thumb buttons.
LeftPrimaryIndexnumbernumberLeft primary index control pressed. To Do: Implement this for current controllers.
LeftSecondaryIndexnumbernumberLeft secondary index control pressed.
RightPrimaryIndexnumbernumberRight primary index control pressed. To Do: Implement this for current controllers.
RightSecondaryIndexnumbernumberRight secondary index control pressed.
LeftPrimaryIndexTouchnumbernumberLeft index finger is touching primary index finger control.
LeftSecondaryIndexTouchnumbernumberLeft index finger is touching secondary index finger control.
LeftIndexPointnumbernumberLeft index finger is pointing, not touching primary or secondary index finger controls.
RightPrimaryIndexTouchnumbernumberRight index finger is touching primary index finger control.
RightSecondaryIndexTouchnumbernumberRight index finger is touching secondary index finger control.
RightIndexPointnumbernumberRight index finger is pointing, not touching primary or secondary index finger controls.
Avatar Skeleton
Hipsnumber - Pose - Hips pose.
Spine2number - Pose - Spine2 pose.
Headnumber - Pose - Head pose.
LeftArmnumber - Pose - Left arm pose.
RightArmnumber - Pose - Right arm pose
LeftHandnumber - Pose - Left hand pose.
LeftHandThumb1number - Pose - Left thumb 1 finger joint pose.
LeftHandThumb2number - Pose - Left thumb 2 finger joint pose.
LeftHandThumb3number - Pose - Left thumb 3 finger joint pose.
LeftHandThumb4number - Pose - Left thumb 4 finger joint pose.
LeftHandIndex1number - Pose - Left index 1 finger joint pose.
LeftHandIndex2number - Pose - Left index 2 finger joint pose.
LeftHandIndex3number - Pose - Left index 3 finger joint pose.
LeftHandIndex4number - Pose - Left index 4 finger joint pose.
LeftHandMiddle1number - Pose - Left middle 1 finger joint pose.
LeftHandMiddle2number - Pose - Left middle 2 finger joint pose.
LeftHandMiddle3number - Pose - Left middle 3 finger joint pose.
LeftHandMiddle4number - Pose - Left middle 4 finger joint pose.
LeftHandRing1number - Pose - Left ring 1 finger joint pose.
LeftHandRing2number - Pose - Left ring 2 finger joint pose.
LeftHandRing3number - Pose - Left ring 3 finger joint pose.
LeftHandRing4number - Pose - Left ring 4 finger joint pose.
LeftHandPinky1number - Pose - Left pinky 1 finger joint pose.
LeftHandPinky2number - Pose - Left pinky 2 finger joint pose.
LeftHandPinky3number - Pose - Left pinky 3 finger joint pose.
LeftHandPinky4number - Pose - Left pinky 4 finger joint pose.
RightHandnumber - Pose - Right hand pose.
RightHandThumb1number - Pose - Right thumb 1 finger joint pose.
RightHandThumb2number - Pose - Right thumb 2 finger joint pose.
RightHandThumb3number - Pose - Right thumb 3 finger joint pose.
RightHandThumb4number - Pose - Right thumb 4 finger joint pose.
RightHandIndex1number - Pose - Right index 1 finger joint pose.
RightHandIndex2number - Pose - Right index 2 finger joint pose.
RightHandIndex3number - Pose - Right index 3 finger joint pose.
RightHandIndex4number - Pose - Right index 4 finger joint pose.
RightHandMiddle1number - Pose - Right middle 1 finger joint pose.
RightHandMiddle2number - Pose - Right middle 2 finger joint pose.
RightHandMiddle3number - Pose - Right middle 3 finger joint pose.
RightHandMiddle4number - Pose - Right middle 4 finger joint pose.
RightHandRing1number - Pose - Right ring 1 finger joint pose.
RightHandRing2number - Pose - Right ring 2 finger joint pose.
RightHandRing3number - Pose - Right ring 3 finger joint pose.
RightHandRing4number - Pose - Right ring 4 finger joint pose.
RightHandPinky1number - Pose - Right pinky 1 finger joint pose.
RightHandPinky2number - Pose - Right pinky 2 finger joint pose.
RightHandPinky3number - Pose - Right pinky 3 finger joint pose.
RightHandPinky4number - Pose - Right pinky 4 finger joint pose.
LeftFootnumber - Pose - Left foot pose.
RightFootnumber - Pose - Right foot pose.
Trackers
TrackedObject00number - Pose - Tracker 0 pose.
TrackedObject01number - Pose - Tracker 1 pose.
TrackedObject02number - Pose - Tracker 2 pose.
TrackedObject03number - Pose - Tracker 3 pose.
TrackedObject04number - Pose - Tracker 4 pose.
TrackedObject05number - Pose - Tracker 5 pose.
TrackedObject06number - Pose - Tracker 6 pose.
TrackedObject07number - Pose - Tracker 7 pose.
TrackedObject08number - Pose - Tracker 8 pose.
TrackedObject09number - Pose - Tracker 9 pose.
TrackedObject10number - Pose - Tracker 10 pose.
TrackedObject11number - Pose - Tracker 11 pose.
TrackedObject12number - Pose - Tracker 12 pose.
TrackedObject13number - Pose - Tracker 13 pose.
TrackedObject14number - Pose - Tracker 14 pose.
TrackedObject15number - Pose - Tracker 15 pose.
-
-
-
-
- \ No newline at end of file diff --git a/tools/jsdoc/gravPrep-Explore.js b/tools/jsdoc/gravPrep-Explore.js index c8fea0a4df..6e58bea51f 100644 --- a/tools/jsdoc/gravPrep-Explore.js +++ b/tools/jsdoc/gravPrep-Explore.js @@ -7,6 +7,16 @@ const rimraf = require('rimraf'); const dedent = require('dedent-js'); +// Arg Vars + const copyLocal = process.argv[2]; + console.log("copyLocal:", copyLocal); + let targetTemplateDirectory = '' + let targetMDDirectory = '' + if (copyLocal){ + targetTemplateDirectory = process.argv[3]; + targetMDDirectory = process.argv[4];; + } + // Required directories let dir_out = path.join(__dirname, 'out'); @@ -19,11 +29,7 @@ let dir_md_objects = path.join(dir_md, '02.Objects'); let dir_md_namespaces = path.join(dir_md, '01.Namespaces'); let dir_md_globals = path.join(dir_md, '03.Globals'); - -// Target Copy Directories - let targetTemplateDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav/user/themes/learn2/"; - let targetMDDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav-content/"; - + // Array to itterate over and create if doesn't exist let dirArray = [dir_grav, dir_css, dir_js, dir_template, dir_md, dir_md_objects, dir_md_namespaces, dir_md_globals]; @@ -50,18 +56,22 @@ const html_reg_brRemove = /
[\s\S]+?
/; const html_reg_subsectionEdit = /()([\s\S]*?)(<\/h.>)/g; const html_reg_subsectionEdit_replace = '

$2

'; + const html_reg_propertiesHeaderEdit = '

Properties:

'; + const html_reg_propertiesHeaderEdit_Replace = '

Properties

'; const html_reg_typeEdit = /(
Returns[\s\S]*?Type)(<\/dt[\s\S]*?type">)(.*?)(<\/span><\/dd>[\s\S]*?<\/dl>)/g; const html_reg_typeEdit_replace = '$1: $3' const html_reg_methodSize = /()(<\/h4>)/g; const html_reg_methodSize_replace = ''; + const html_reg_typeDefSize = /()/g; + const html_reg_typeDefSize_replace = ''; const html_reg_returnSize = /
Returns:<\/h5>/g; const html_reg_returnSize_replace = '
Returns:<\/h6>'; const html_reg_findByName = '
Methods
` + const html_reg_findByTitle = '

'; + const html_reg_findByMethod = `

Methods

`; const html_reg_findByArticleClose = `` const html_reg_signalTitle = `

Signals

`; - - + const html_reg_typeDefinitonsTitle = `

Type Definitions

`; // Mapping for GroupNames and Members let groupNameMemberMap = { @@ -71,6 +81,7 @@ } // Procedural functions + // Create the actual MD file function createMD(title, directory, needsDir, isGlobal){ let mdSource = makeMdSource(title); @@ -84,14 +95,14 @@ fs.writeFileSync(destinationMDFile, mdSource); } + // Create the actual Template file function createTemplate(title,content){ - // console.log("content:", content) let twigBasePartial = makeTwigFile(content); - // console.log("TWIG BASE:", twigBasePartial) let destinationFile = path.join(dir_template, `API_${title}.html.twig`); fs.writeFileSync(destinationFile, twigBasePartial); } + // Copy file from source to target - used for recurssive call function copyFileSync( source, target ) { let targetFile = target; @@ -108,6 +119,7 @@ fs.writeFileSync(targetFile, fs.readFileSync(source)); } + // Copy file from source to target function copyFolderRecursiveSync( source, target ) { var files = []; @@ -131,6 +143,7 @@ } } + // Clean up the Html function prepareHtml(source){ let htmlBefore = fs.readFileSync(source, {encoding: 'utf8'}); let htmlAfter = htmlclean(htmlBefore); @@ -138,6 +151,7 @@ return cheerio.load(htmlAfterPretty); } + // Base file for MD's function makeMdSource(title){ return dedent( ` @@ -152,6 +166,7 @@ ) } + // Base file for Templates function makeTwigFile(contentHtml){ return dedent( ` @@ -185,15 +200,15 @@ ) } + // Handle NameSpace Group function handleNamespace(title, content){ - // console.log("Content from namespcae:", content) groupNameMemberMap["Namespaces"].push(title); let destinationDirectory = path.join(map_dir_md["Namespace"], title); - createMD(title, destinationDirectory, true); createTemplate(title, content); } + // Handle Class Group function handleClass(title, content){ groupNameMemberMap["Objects"].push(title); let destinationDirectory = path.join(map_dir_md["Class"], title); @@ -201,18 +216,19 @@ let formatedHtml = content .replace(html_reg_objectSpanNew,"") - .replace(html_reg_brRemove, ""); createTemplate(title, formatedHtml); } + // Handle Global Group function handleGlobal(title, content){ groupNameMemberMap["Globals"].push("Globals"); createMD("Globals", map_dir_md["Global"], false, true); createTemplate("Globals", content); } + // Handle Group TOCs function makeGroupTOC(group){ - let mappedGroup; + let mappedGroup; if (!Array.isArray(group)){ mappedGroup = groupNameMemberMap[group]; } else { @@ -234,6 +250,112 @@ return htmlGroup.join("\n"); } + // Handle Class TOCS + function makeClassTOC(group){ + let linkArray = [] + group.forEach( item => { + linkArray.push(`
${item.type}
`) + item.array.forEach( link => { + linkArray.push(``) + }) + }) + return linkArray.join("\n"); + } + + // Extract IDS for TOC + function extractIDs(groupToExtract){ + let firstLine = ""; + let id = ""; + let extractedIDs = []; + groupToExtract.forEach((item)=>{ + firstLine = item.split("\n")[0]; + try { + id = firstLine.split('id="')[1].split(`"`)[0]; + } catch (e){ + + } + extractedIDs.push(id) + }) + return extractedIDs; + } + + // Helper for splitting up html + // Takes: Content to split, SearchTerm to Split by, term to End Splitting By, and negate Term object array + // negateTermObject { term: "", distance: "3"} + // Returns: [newContent after Split, Array of extracted ] + function splitBy(content, searchTerm, endSplitTerm){ + let foundArray = []; + let curIndex = -1; + let afterCurSearchIndex = -1 + let negateTermIndex = -1; + let nextIndex = 0; + let findbyNameLength = searchTerm.length; + let curfoundArrayIndex = 0; + let curEndSplitTermIndex = -1; + do { + curEndSplitTermIndex = content.indexOf(endSplitTerm); + curIndex = content.indexOf(searchTerm); + afterCurSearchIndex = curIndex+findbyNameLength; + nextIndex = content.indexOf(searchTerm,afterCurSearchIndex); + if (nextIndex === -1){ + nextIndex = curEndSplitTermIndex; + } + foundArray.push(content.slice(curIndex, nextIndex)) + // remove that content + content = content.replace(foundArray[curfoundArrayIndex], ""); + curfoundArrayIndex++; + } while (curIndex > -1) + return [content, foundArray]; + } + + // Split the signals, methods, and typeDefs [Might make this more generic] + function splitMethodsSignalsAndTypeDefs(allItemToSplit){ + let methodArray = []; + let signalArray = []; + let typeDefArray = []; + console.log(allItemToSplit.length); + allItemToSplit.forEach( method => { + firstLine = method.split("\n")[0]; + if (firstLine.indexOf("Signal") > -1){ + console.log("Found signal") + signalArray.push(method); + } else if (firstLine.indexOf("span") > -1) { + // console.log("Found method") + methodArray.push(method); + } else { + // console.log("Found typeDef") + + typeDefArray.push(method); + } + }) + return [methodArray, signalArray, typeDefArray]; + } + + // Helper to append + // Takes content, the search term to appendTo, the content to append, + // and bool if the append is before the found area + function append(content, searchTermToAppendto, contentToAppend, appendBefore){ + let contentArray = content.split("\n"); + let foundIndex = findArrayTrim(contentArray, searchTermToAppendto) + foundIndex = appendBefore ? foundIndex : foundIndex +1 + + contentArray.splice(foundIndex,0,contentToAppend) + return contentArray.join("\n") + } + + // Helper function for append + function findArrayTrim(array, searchTerm){ + var index = -1; + for (var i = 0; i < array.length; i++){ + index = array[i].trim().indexOf(searchTerm.trim()); + if (index > -1){ + return i + } + } + return index; + } + + // Remove grav directory if exists to make sure old files aren't kept if (fs.existsSync(dir_grav)){ console.log("dir_grav exists"); @@ -253,7 +375,8 @@ }) // Read jsdoc output folder and process html files - let curSource = path.join(dir_out, "AvatarInputs.html"); + let curSource = path.join(dir_out, "Controller.html"); + if (path.extname(curSource) == ".html" && path.basename(curSource, '.html') !== "index") { // Clean up the html source let loadedHtml = prepareHtml(curSource); @@ -261,26 +384,12 @@ let splitTitle = loadedHtml("title").text().split(": "); let groupName = splitTitle[1]; let htmlTitle = splitTitle.pop(); - // console.log("first loaded:", loadedHtml("#main").html()) let mainDiv = loadedHtml("#main") - // let signatures = mainDiv.find(".name") - // Exploring Extractions - // let array = mainDiv.find('h4').toArray(); - - // console.log(array[2]) - // var reducedArray = array.reduce((prev, cur) => { - // try { - // // console.log(cur.children[1]); - // prev.push(cur.children[1].data); - // } catch(e) { - - // } - // return prev; - // }, []) - // console.log("name", reducedArray.length); - - // regex edits + let methodIDs = []; + let signalIDs = []; + let typeDefIDs = []; + // Basic Regex HTML edits let mainDivRegexed = mainDiv.html() .replace(html_reg_static,"") .replace(html_reg_title,"") @@ -288,96 +397,74 @@ .replace(html_reg_htmlExt,"") .replace(html_reg_brRemove, "") .replace(html_reg_subsectionEdit, html_reg_subsectionEdit_replace) + .replace(html_reg_propertiesHeaderEdit, html_reg_propertiesHeaderEdit_Replace) .replace(html_reg_typeEdit, html_reg_typeEdit_replace) .replace(html_reg_returnSize, html_reg_returnSize_replace) - .replace(html_reg_methodSize, html_reg_methodSize_replace); - - function splitBy(content, searchTerm){ - let foundArray = []; - let curIndex = -1; - let nextIndex = 0; - let findbyNameLength = searchTerm.length; - let curfoundArrayIndex = 0; - let curArticleCloseIndex = -1; - do { - curArticleCloseIndex = content.indexOf(""); - curIndex = content.indexOf(searchTerm); - nextIndex = content.indexOf(searchTerm,curIndex+findbyNameLength); - if (nextIndex === -1){ - nextIndex = curArticleCloseIndex - } - foundArray.push(content.slice(curIndex, nextIndex)) - content = content.replace(foundArray[curfoundArrayIndex], ""); - curfoundArrayIndex++; - } while (curIndex > -1) - return [content, foundArray]; + .replace(html_reg_methodSize, html_reg_methodSize_replace) + .replace(html_reg_typeDefSize, html_reg_typeDefSize_replace) + .replace(html_reg_typeDefinitonsTitle, ""); + + + // Further HTML Manipulation + // Split HTML by Each named entry + let contentSplitArray = splitBy(mainDivRegexed, html_reg_findByName, html_reg_findByArticleClose); + // Create a reference to the current content after split and the split functions + let currentContent = contentSplitArray[0]; + // Create references to the split methods and signals + let splitMethodsSignalsAndTypeDefs = splitMethodsSignalsAndTypeDefs(contentSplitArray[1]); + let splitMethods = splitMethodsSignalsAndTypeDefs[0]; + let splitSignals = splitMethodsSignalsAndTypeDefs[1]; + let splitTypeDefintions = splitMethodsSignalsAndTypeDefs[2]; + let splitMethodIDS = extractIDs(splitMethods); + let splitSignalIDS = extractIDs(splitSignals); + let splitTypeDefinitionIDS = extractIDs(splitTypeDefintions); + let classTOC = makeClassTOC([ + {type: "Methods", array: splitMethodIDS}, + {type: "Signals", array: splitSignalIDS}, + {type: "Type Definitions", array: splitTypeDefinitionIDS} + ]); + + // Append Signals and Methods to the current Content + currentContent = append(currentContent, html_reg_findByTitle, classTOC); + currentContent = append(currentContent, html_reg_findByMethod, splitMethods.join('\n')); + if (splitSignals.length > 0) { + // Add the Signals header to the Signals HTML + splitSignals.unshift(html_reg_signalTitle) + currentContent = append(currentContent, html_reg_findByArticleClose, splitSignals.join('\n'),true); + } + if (splitTypeDefintions.length > 0) { + // Add the Signals header to the Signals HTML + splitTypeDefintions.unshift(html_reg_typeDefinitonsTitle) + currentContent = append(currentContent, html_reg_findByArticleClose, splitTypeDefintions.join('\n'), true); } - function extractSignals(methodArray){ - let newMethodArray = []; - let signalArray = []; - methodArray.forEach( method => { - method.indexOf("Signal") > -1 - ? signalArray.push(method) - : newMethodArray.push(method); - }) - return [newMethodArray, signalArray] - } - - function append(content, areaToAppendTo, contentToAppend, appendBefore){ - var contentArray = content.split("\n"); - // console.log("contentArray:", contentArray) - // console.log("areaToAppendTo:", areaToAppendTo) - var foundIndex = findArrayTrim(contentArray, areaToAppendTo) - console.log(foundIndex) - foundIndex = appendBefore ? foundIndex : foundIndex +1 - - contentArray.splice(foundIndex,0,contentToAppend) - return contentArray.join("\n") - } - - function findArrayTrim(array, searchTerm){ - var index = -1; - for (var i = 0; i < array.length; i++){ - index = array[i].trim().indexOf(searchTerm.trim()); - if (index > -1){ - return i - } - } - return index; - } - - var nameArray = splitBy(mainDivRegexed, html_reg_findByName); - let currentContent = nameArray[0]; - let separatedMethods = extractSignals(nameArray[1]); - let methodsToAppend = separatedMethods[0].join("\n"); - separatedMethods[1].unshift(html_reg_signalTitle) - let signalsToAppend = separatedMethods[1].join("\n"); - currentContent = append(currentContent, html_reg_findByMethod, methodsToAppend); - mainDivRegexed = append(currentContent, html_reg_findByArticleClose, signalsToAppend,true); - - // console.log(mainDivRegexed); + // Final Pretty Content + currentContent = htmlclean(currentContent); + currentContent = pretty(currentContent); // Handle Unique Categories switch(groupName){ case "Namespace": - handleNamespace(htmlTitle, mainDivRegexed); + handleNamespace(htmlTitle, currentContent); break; case "Class": - handleClass(htmlTitle, mainDivRegexed); + handleClass(htmlTitle, currentContent); break; case "Global": - handleGlobal(htmlTitle, mainDivRegexed); + handleGlobal(htmlTitle, currentContent); break; default: console.log(`Case not handled for ${groupName}`); } + } // Create the base Templates after processing individual files - createTemplate("API-Reference", makeGroupTOC(["Namespaces", "Objects", "Globals"])); - createTemplate("Namespaces", makeGroupTOC("Namespaces")); - createTemplate("Objects", makeGroupTOC("Objects")); +createTemplate("API-Reference", makeGroupTOC(["Namespaces", "Objects", "Globals"])); +createTemplate("Namespaces", makeGroupTOC("Namespaces")); +createTemplate("Objects", makeGroupTOC("Objects")); -// Copy files to the Twig Directory +// Copy the files to the target Directories if Local +if (copyLocal){ + // Copy files to the Twig Directory let templateFiles = fs.readdirSync(path.resolve(targetTemplateDirectory)); // Remove Existing API files templateFiles.forEach(function(file){ @@ -389,10 +476,11 @@ }) copyFolderRecursiveSync(dir_template, targetTemplateDirectory); -// Copy files to the Md Directory + // Copy files to the Md Directory let baseMdRefDir = path.join(targetMDDirectory,"06.api-reference"); // Remove existing MD directory if (fs.existsSync(baseMdRefDir)){ rimraf.sync(baseMdRefDir); } copyFolderRecursiveSync(dir_md, targetMDDirectory); +} diff --git a/tools/jsdoc/gravPrep.js b/tools/jsdoc/gravPrep.js index 9aecf1af0f..adb1625e9a 100644 --- a/tools/jsdoc/gravPrep.js +++ b/tools/jsdoc/gravPrep.js @@ -62,12 +62,17 @@ const html_reg_typeEdit_replace = '$1: $3' const html_reg_methodSize = /()(<\/h4>)/g; const html_reg_methodSize_replace = ''; + const html_reg_typeDefSize = /()/g; + const html_reg_typeDefSize_replace = ''; const html_reg_returnSize = /
Returns:<\/h5>/g; const html_reg_returnSize_replace = '
Returns:<\/h6>'; const html_reg_findByName = '
Methods
` + const html_reg_findByTitle = '

'; + const html_reg_findByMethod = `

Methods

`; const html_reg_findByArticleClose = `` const html_reg_signalTitle = `

Signals

`; + const html_reg_typeDefinitonsTitle = `

Type Definitions

`; + const html_reg_firstTableClose = ``; // Mapping for GroupNames and Members @@ -136,7 +141,7 @@ } else { copyFileSync( curSource, targetFolder ); } - } ); + }); } } @@ -247,23 +252,55 @@ return htmlGroup.join("\n"); } + // Handle Class TOCS + function makeClassTOC(group){ + let linkArray = [] + group.forEach( item => { + linkArray.push(`
${item.type}
`) + item.array.forEach( link => { + linkArray.push(``) + }) + linkArray.push("
"); + }) + return linkArray.join("\n"); + } + + // Extract IDS for TOC + function extractIDs(groupToExtract){ + let firstLine = ""; + let id = ""; + let extractedIDs = []; + groupToExtract.forEach((item)=>{ + firstLine = item.split("\n")[0]; + try { + id = firstLine.split('id="')[1].split(`"`)[0]; + } catch (e){ + + } + extractedIDs.push(id) + }) + return extractedIDs; + } + // Helper for splitting up html // Takes: Content to split, SearchTerm to Split by, and term to End Splitting By // Returns: [newContent after Split, Array of extracted ] function splitBy(content, searchTerm, endSplitTerm){ let foundArray = []; let curIndex = -1; + let afterCurSearchIndex = -1 + let negateTermIndex = -1; let nextIndex = 0; let findbyNameLength = searchTerm.length; let curfoundArrayIndex = 0; let curEndSplitTermIndex = -1; do { - curEndSplitTermIndex = content.indexOf(endSplitTerm); + curEndSplitTermIndex = content.indexOf(endSplitTerm); curIndex = content.indexOf(searchTerm); - // Search after initial index + length of searchterm - nextIndex = content.indexOf(searchTerm,curIndex+findbyNameLength); + afterCurSearchIndex = curIndex+findbyNameLength; + nextIndex = content.indexOf(searchTerm,afterCurSearchIndex); if (nextIndex === -1){ - nextIndex = curEndSplitTermIndex + nextIndex = curEndSplitTermIndex; } foundArray.push(content.slice(curIndex, nextIndex)) // remove that content @@ -274,15 +311,27 @@ } // Split the signals and methods [Might make this more generic] - function splitMethodsAndSignals(methodArray){ - let newMethodArray = []; + function splitMethodsSignalsAndTypeDefs(allItemToSplit){ + let methodArray = []; let signalArray = []; - methodArray.forEach( method => { - method.indexOf("Signal") > -1 - ? signalArray.push(method) - : newMethodArray.push(method);2 + let typeDefArray = []; + // console.log(allItemToSplit.length); + allItemToSplit.forEach( method => { + firstLine = method.split("\n")[0]; + if (firstLine.indexOf("Signal") > -1){ + // console.log("Found signal") + signalArray.push(method); + } else if (firstLine.indexOf("span") > -1) { + // console.log("Found method") + methodArray.push(method); + } else { + // console.log("Found typeDef") + if(firstLine.trim() !== ""){ + typeDefArray.push(method); + } + } }) - return [newMethodArray, signalArray] + return [methodArray, signalArray, typeDefArray]; } // Helper to append @@ -337,51 +386,74 @@ let loadedHtml = prepareHtml(curSource); // Extract the title, group name, and the main div - let splitTitle = loadedHtml("title").text().split(": "); - let groupName = splitTitle[1]; - let htmlTitle = splitTitle.pop(); - let mainDiv = loadedHtml("#main") - - // Basic Regex HTML edits - let mainDivRegexed = mainDiv.html() - .replace(html_reg_static,"") - .replace(html_reg_title,"") - .replace(html_reg_objectHeader,"") - .replace(html_reg_htmlExt,"") - .replace(html_reg_brRemove, "") - .replace(html_reg_subsectionEdit, html_reg_subsectionEdit_replace) - .replace(html_reg_propertiesHeaderEdit, html_reg_propertiesHeaderEdit_Replace) - .replace(html_reg_typeEdit, html_reg_typeEdit_replace) - .replace(html_reg_returnSize, html_reg_returnSize_replace) - .replace(html_reg_methodSize, html_reg_methodSize_replace); - - // Further HTML Manipulation - // Split HTML by Each named entry - if (path.basename(curSource, '.html') === "Controller"){ - var cleanup = htmlclean(mainDivRegexed); - cleanup = pretty(cleanup) - fs.writeFileSync(__dirname+'/Examine/ControllerExamine', cleanup); - } + let splitTitle = loadedHtml("title").text().split(": "); + let groupName = splitTitle[1]; + let htmlTitle = splitTitle.pop(); + let mainDiv = loadedHtml("#main") - let contentSplitArray = splitBy(mainDivRegexed, html_reg_findByName); - // Create a reference to the current content after split and the split functions - let currentContent = contentSplitArray[0]; - // Create references to the split methods and signals - let splitSignalsAndMethods = splitMethodsAndSignals(contentSplitArray[1]); - let splitMethods = splitSignalsAndMethods[0]; - let splitSignals = splitSignalsAndMethods[1]; - // Append Signals and Methods to the current Content - currentContent = append(currentContent, html_reg_findByMethod, splitMethods.join('\n')); - console.log(path.basename(curSource, '.html'), splitSignals.length); - if (splitSignals.length > 0) { - // Add the Signals header to the Signals HTML - splitSignals.unshift(html_reg_signalTitle) - currentContent = append(currentContent, html_reg_findByArticleClose, splitSignals.join('\n',true)); - } + let methodIDs = []; + let signalIDs = []; + let typeDefIDs = []; + // Basic Regex HTML edits + let mainDivRegexed = mainDiv.html() + .replace(html_reg_static,"") + .replace(html_reg_title,"") + .replace(html_reg_objectHeader,"") + .replace(html_reg_htmlExt,"") + .replace(html_reg_brRemove, "") + .replace(html_reg_subsectionEdit, html_reg_subsectionEdit_replace) + .replace(html_reg_propertiesHeaderEdit, html_reg_propertiesHeaderEdit_Replace) + .replace(html_reg_typeEdit, html_reg_typeEdit_replace) + .replace(html_reg_returnSize, html_reg_returnSize_replace) + .replace(html_reg_methodSize, html_reg_methodSize_replace) + .replace(html_reg_typeDefSize, html_reg_typeDefSize_replace) + .replace(html_reg_typeDefinitonsTitle, "") + .replace(html_reg_findByMethod, ""); + + // Further HTML Manipulation + // Split HTML by Each named entry + let contentSplitArray = splitBy(mainDivRegexed, html_reg_findByName, html_reg_findByArticleClose); + // Create a reference to the current content after split and the split functions + let currentContent = contentSplitArray[0]; + // Create references to the split methods and signals + let processedMethodsSignalsAndTypeDefs = splitMethodsSignalsAndTypeDefs(contentSplitArray[1]); + let splitMethods = processedMethodsSignalsAndTypeDefs[0]; + let splitSignals = processedMethodsSignalsAndTypeDefs[1]; + let splitTypeDefintions = processedMethodsSignalsAndTypeDefs[2]; + let splitMethodIDS = extractIDs(splitMethods); + let splitSignalIDS = extractIDs(splitSignals); + let splitTypeDefinitionIDS = extractIDs(splitTypeDefintions); + let arrayToPassToClassToc = []; - // Final Pretty Content - currentContent = htmlclean(currentContent); - currentContent = pretty(currentContent); + // Append Signals and Methods to the current Content + if (splitMethods.length > 0) { + arrayToPassToClassToc.push({type: "Methods", array: splitMethodIDS}); + // Add the Signals header to the Signals HTML + splitMethods.unshift(html_reg_findByMethod) + currentContent = append(currentContent, html_reg_findByArticleClose, splitMethods.join('\n'), true); + } + if (splitSignals.length > 0) { + arrayToPassToClassToc.push({type: "Signals", array: splitSignalIDS}); + // Add the Signals header to the Signals HTML + splitSignals.unshift(html_reg_signalTitle) + currentContent = append(currentContent, html_reg_findByArticleClose, splitSignals.join('\n'),true); + } + if (splitTypeDefintions.length > 0) { + + // console.log(path.basename(curSource, '.html')); + // console.log(splitTypeDefintions.length); + arrayToPassToClassToc.push({type: "Type Definitions", array: splitTypeDefinitionIDS}); + // Add the Signals header to the Signals HTML + splitTypeDefintions.unshift(html_reg_typeDefinitonsTitle) + currentContent = append(currentContent, html_reg_findByArticleClose, splitTypeDefintions.join('\n'), true); + } + + let classTOC = makeClassTOC(arrayToPassToClassToc); + currentContent = append(currentContent, html_reg_firstTableClose, classTOC); + + // Final Pretty Content + currentContent = htmlclean(currentContent); + currentContent = pretty(currentContent); // Handle Unique Categories switch(groupName){ From 22065ad611d38612e0883a4d310087dccb7cab2b Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Sun, 6 May 2018 21:39:37 -0700 Subject: [PATCH 07/10] Links fixed --- tools/jsdoc/Check.js | 97 +- tools/jsdoc/Links-Untouched | 1484 +++++++++++++++++++++++++++++++ tools/jsdoc/badLinks | 0 tools/jsdoc/gravPrep-Explore.js | 831 ++++++++--------- tools/jsdoc/gravPrep.js | 178 +++- tools/jsdoc/package.json | 1 + tools/jsdoc/warningLog | 0 7 files changed, 2144 insertions(+), 447 deletions(-) create mode 100644 tools/jsdoc/Links-Untouched create mode 100644 tools/jsdoc/badLinks create mode 100644 tools/jsdoc/warningLog diff --git a/tools/jsdoc/Check.js b/tools/jsdoc/Check.js index b7e0fb1298..af449dafc1 100644 --- a/tools/jsdoc/Check.js +++ b/tools/jsdoc/Check.js @@ -1,5 +1,71 @@ var fs = require('fs'); var path = require('path'); +var request = require('request'); + +var badLinks = []; +var baseLink = `http://localhost:8000/api-reference/`; +var linkList = fs.readFileSync(__dirname + '/Links-Untouched','utf8').split('\n'); +console.log("link list", linkList); +// console.log("filtered List", JSON.stringify(filteredList)); +var linkHash = {}; + +var currentGroup; +linkList.forEach( link => { + link = link.trim() + console.log("link", link) + if (link.slice(-1) === ':'){ + currentGroup = link.slice(0, link.length-1); + // console.log("current Group: ", currentGroup); + linkHash[currentGroup] = {}; + } else { + if (!linkHash[currentGroup][link]){ + linkHash[currentGroup][link] = link; + } + } +}); + +// console.log("linkHash:", JSON.stringify(linkHash)) +var badLinks = []; + + +var stream = fs.createWriteStream("badLinks", {flags: 'a'}); +var linkReg = /="([\s\S]*?)"/g +var keys = Object.keys(linkHash); + +keys.forEach( key => { + for (var linkKey in linkHash[key]){ + var link = linkHash[key][linkKey]; + console.log("link", link); + var extractLink = link.split(`"`)[1]; + console.log("extractLink", extractLink) + if (!extractLink.indexOf('http') > -1){ + extractLink = baseLink + extractLink; + } + console.log("about to make a request for", extractLink) + setTimeout(function(){ + request.get(extractLink) + .on('response', response => { + if (response.statusCode(404)){ + console.log("found bad link") + console.log(JSON.stringify({file: key, link: extractLink})) + + // badLinks.push({file: key, link: link}) + stream.write(JSON.stringify({file: key, link: extractLink})); + } + }, 4000) + }) + + } + +}) +stream.end(); +// */ + +/* + +*/ + + function endsWith(path, exts) { var result = false; @@ -74,14 +140,19 @@ function parse() { // load entire file into a string var data = fs.readFileSync(pathDir, "utf8"); var fileName = path.basename(file); - var badJSDocWarnings = checkForBadJSDoc(data, fileName); - if (badJSDocWarnings.length > 0){ - warnings.push(badJSDocWarnings); - } - var badWordsList = checkForBadwordlist(data, fileName); - if (badWordsList){ - warnings.push(badWordsList); - } + // var badJSDocWarnings = checkForBadJSDoc(data, fileName); + // if (badJSDocWarnings.length > 0){ + // warnings.push(badJSDocWarnings); + // } + // var badWordsList = checkForBadwordlist(data, fileName); + // if (badWordsList){ + // warnings.push(badWordsList); + // } + // var dotDescriptionList = checkForDotDescription(data, fileName); + // if (dotDescriptionList.length > 0){ + // warnings.push(dotDescriptionList); + // } + } }); @@ -104,6 +175,16 @@ function checkForBadJSDoc(dataToSearch, file){ return warningList; } +function checkForDotDescription(dataToSearch, file){ + var warningList = []; + var reg = /@property {.+?\..+?}/g + var matches = dataToSearch.match(reg); + if (matches) { + warningList.push(new WarningObject(file, "dotDescription", matches)); + } + return warningList; +} + var badWordList = ["@params", "@return", "@bool"]; function checkForBadwordlist(dataToSearch, file){ diff --git a/tools/jsdoc/Links-Untouched b/tools/jsdoc/Links-Untouched new file mode 100644 index 0000000000..9da3060726 --- /dev/null +++ b/tools/jsdoc/Links-Untouched @@ -0,0 +1,1484 @@ +AnimationCache: + Resource +Resource +Resource +Resource +Resource +Resource +Assets: + Assets~downloadDataCallback +Assets~getAssetCallback +Assets~getMappingCallback +Assets~setMappingCallback +Assets~uploadDataCallback +AudioStats: + AudioStats.AudioStreamStats +AudioStats.AudioStreamStats +AudioStreamStats +AvatarManager: + Uuid +Uuid +Uuid +Uuid +PickRay +Uuid +Uuid +PickRay +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Vec3 +Uuid +Uuid +Uuid +Uuid +Camera: + Vec3 +Quat +ViewFrustum +Uuid +PickRay +PickRay +PickRay +PickRay +PickRay +Uuid +Uuid +Quat +Quat +Vec3 +Vec3 +Vec3 +Vec3 +Uuid +Quat +Vec3 +Clipboard: + Uuid +Vec3 +Vec3 +Uuid +Vec3 +Uuid +Controller: + MyAvatar.sessionUUID +RouteObject +keyboardMouse.json +standard.json +RouteObject +RouteObject +leapmotion.json +vive.json +KeyEvent +Controller +Controller +Pose +Pose +Pose +Pose +Rect +Rect +Controller +Vec2 +Vec2 +KeyEvent +KeyEvent +MappingObject +MappingObject +MouseEvent +MouseEvent +MouseEvent +MouseEvent +MappingObject +MappingObject +RouteObject +MappingObject +MappingObject +MappingObject +KeyEvent +Controller.Hardware.Keyboard +TouchEvent +TouchEvent +TouchEvent +WheelEvent +MappingObject +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +RouteObject +https://github.com/highfidelity/hifi/tree/master/interface/resources/controllers +Controller.Hardware-Application +Controller.Hardware-Keyboard +Controller.Hardware-OculusTouch +Controller.Hardware-Vive +RouteObject +RouteObject +RouteObject +Pose +Pose +Pose +RouteObject +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +MappingObject +https://github.com/highfidelity/hifi/tree/master/interface/resources/controllers +RouteObject +RouteObject +Pose +leapmotion.json +vive.json +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +Pose +DebugDraw: + Quat +Vec3 +Vec4 +Quat +Vec3 +Vec4 +Vec3 +Vec3 +Vec4 +Entities: + Uuid +Uuid.NULL +Vec3 +Vec3 +Vec3 +Vec3 +Uuid +Uuid +Uuid +Uuid +Uuid.NULL +Uuid +Uuid +Uuid +Vec3 +Uuid +Uuid +Uuid +Uuid +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +Uuid +Collision +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Vec3 +Uuid +Uuid +Vec3 +Uuid +Uuid +Vec3 +Uuid +Uuid +Vec3 +Uuid +Uuid +Vec3 +Vec3 +Uuid +Uuid +ViewFrustum +Uuid +PickRay +PickRay +Uuid +Uuid +PickRay +PickRay +Uuid +Uuid +Quat +Uuid +Quat.IDENTITY +Quat +Vec3 +Uuid +Vec3.ZERO +Vec3 +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Picks +Quat +Uuid +Quat.IDENTITY +Quat +Vec3 +Uuid +Vec3.ZERO +Vec3 +Uuid +Entities~getMeshesCallback +Graphics +Uuid +Uuid +Entities~getServerScriptStatusCallback +Uuid +Picks +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +Uuid +Uuid +Vec3 +Uuid +Vec3 +Vec3.ZERO +Vec3 +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +Uuid +Entities~queryPropertyMetadataCallback +Uuid +Entities~queryPropertyMetadataCallback +Uuid +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +Quat +Uuid +Vec3 +Uuid +Vec3 +Uuid +Uuid +Uuid.NULL +Picks +Uuid +Quat +Uuid +Quat +Uuid +Quat +Vec3 +Uuid +Vec3 +Uuid +Vec3 +Uuid +Vec3 +Uuid +Vec3 +Vec3 +Uuid +Vec3 +Vec3 +Uuid +Vec3 +Picks +Uuid +Uuid +Uuid +Vec3 +Uuid +Vec3 +Vec3.ZERO +Vec3 +Vec3 +Uuid +Vec3 +Vec3.ZERO +Vec3 +Uuid +Uuid +Vec3 +Uuid +Vec3 +Vec3.ZERO +Vec3 +ActionArguments-FarGrab +ActionArguments-Hold +ActionArguments-Offset +ActionArguments-Tractor +ActionArguments-TravelOriented +ActionArguments-Hinge +ActionArguments-Slider +ActionArguments-ConeTwist +ActionArguments-BallSocket +Vec3 +Uuid +Vec3 +Vec3 +Vec3 +Uuid +Vec3 +Vec3 +Vec3 +Quat +Uuid +Vec3 +Vec3 +Uuid +Vec3 +Vec3 +Uuid +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Uuid +Vec3 +Vec3 +Vec3 +Quat +Uuid +Vec3 +Entities.ActionArguments-FarGrab +Entities.ActionArguments-Hold +Entities.ActionArguments-Offset +Entities.ActionArguments-Tractor +Entities.ActionArguments-TravelOriented +Entities.ActionArguments-Hinge +ActionArguments-Slider +Entities.ActionArguments-ConeTwist +Entities.ActionArguments-BallSocket +Vec3 +Vec3 +Vec3 +Vec3 +Uuid +Uuid +Uuid.NULL +Uuid +keyLight +Vec3 +Quat +Vec3 +Vec3.ZERO +Vec3.ONE +Vec3.ZERO +Vec3.ONE +Vec3 +Vec3.ZERO +Vec3 +Vec3.ONE +Vec3 +Vec3 +Vec3 +Vec3.ZERO +Vec3 +Vec3.ZERO +SoundCache +Uuid +Uuid.NULL +Vec3 +Quat +Vec3 +Vec3 +Vec3 +AACube +EntityProperties-Box +EntityProperties-Light +EntityProperties-Line +EntityProperties-Material +EntityProperties-Model +EntityProperties-ParticleEffect +EntityProperties-PolyLine +EntityProperties-PolyVox +EntityProperties-Shape +EntityProperties-Sphere +EntityProperties-Text +EntityProperties-Web +EntityProperties-Zone +Vec3 +Color +Vec3 +Vec3 +Color +MaterialResource +MaterialResource +MaterialResource +Vec2 +Vec2 +MaterialResource +Vec3 +Color +ShapeType +Quat +Vec3 +Vec3 +Quat +Color +Color +Color +Color +ShapeType +Vec3 +Vec3 +Vec3 +Vec3 +Color +Volumes of Fun +library documentation +Vec3 +Vec3 +Uuid +Uuid.NULL +Uuid +Uuid.NULL +Uuid +Uuid.NULL +Uuid +Uuid.NULL +Uuid +Uuid.NULL +Uuid +Uuid.NULL +Vec3 +Color +Vec3 +Color +Color +Vec3 +Vec3 +ShapeType +EntityProperties-Box +EntityProperties-Light +EntityProperties-Line +EntityProperties-Material +EntityProperties-Model +EntityProperties-ParticleEffect +EntityProperties-PolyLine +EntityProperties-PolyVox +EntityProperties-Shape +EntityProperties-Sphere +EntityProperties-Text +EntityProperties-Web +EntityProperties-Zone +Color +Color +Color +Vec3 +PickRay +PickRay +Uuid +PickRay +Vec3 +Vec3 +BoxFace +Color +MeshProxy +MeshProxy +Graphics +Global: + ContactEventType +Uuid +Uuid +Vec3 +Vec3 +Vec3 +http://doc.qt.io/qt-5/qt#Key-enum +Vec3Color +RGBS +Vec3Color +RGBS +Vec3Color +RGBS +Vec3Color +RGBS +Material +Material +Vec3 +Vec3 +Vec2 +Vec3 +Vec3 +Vec3 +KeyboardModifiers +Vec3 +Quat +Vec3 +Vec3 +Quat +Vec3 +Quat +Vec3 +Vec2 +Vec3 +Vec3 +Vec3 +Quat +Graphics: + Vec3 +Vec3 +Vec3 +Vec2 +Material +Uuid +HMD: + Vec3 +Vec3.ZERO +Quat +Quat.IDENTITY +Uuid +Uuid +Uuid +Uuid +Vec3 +Vec3 +Vec3 +Vec3.ZERO +Vec3 +Vec2 +Vec3 +Vec2 +Vec2 +Vec2 +Vec2 +Vec2 +Vec2 +Vec2 +Vec3 +Vec2 +Vec3 +location: + Uuid +Uuid.NULL +Uuid +Vec3 +Quat +Quat.IDENTITY +Uuid +Uuid +Uuid +Settings +MappingObject: + Controller +RouteObject +MappingObject +MappingObject +MappingObject +MappingObject +RouteObject +RouteObject +Pose +RouteObject +RouteObject +RouteObject +RouteObject +Pose +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +Menu: + KeyEvent +KeyEvent +MeshProxy: + Graphics +Graphics +Vec3 +Graphics +Vec3 +Messages: + Uuid +Uuid +ModelCache: + Resource +Resource +Resource +Resource +MyAvatar: + Vec3 +Vec3 +Vec3 +Quat +Vec3 +Vec3.ZERO +Vec3 +Vec3.ZERO +Vec3 +Vec3.ZERO +Vec3 +Vec3.ZERO +Pose +Pose +Pose +Pose +Uuid +Vec3 +Vec3 +Vec3 +Quat +Quat +Vec3 +Vec3 +Uuid +Vec3 +Entities +Vec3 +Quat +Uuid +Collision +Quat +Quat +Vec3 +Vec3 +Quat +Quat +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Quat +Quat +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Quat +Avatar Standards +Quat +Quat +Avatar Standards +Quat +Quat +Quat +Vec3 +Avatar Standards +Vec3 +Vec3 +Avatar Standards +Vec3 +Vec3 +Vec3 +Pose +Pose +Vec3 +Vec3.ZERO +Vec3 +Pose +Pose +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Quat +Quat +Uuid +Uuid +Vec3 +Vec3 +Pose +Pose +Vec3 +Vec3.ZERO +Vec3 +Pose +Pose +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Quat +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Quat +Quat +Quat +Avatar Standards +Avatar Standards +Vec3 +Quat +Vec3 +Quat +Vec3 +Quat +Vec3 +Quat +Vec3 +Quat +Quat +Quat +Vec3 +Vec3 +Vec3 +Uuid +Uuid +Vec3 +Vec3 +MyAvatar.hmdLeanRecenterEnabled +MyAvatar.hmdLeanRecenterEnabled +Uuid +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Quat +Quat +Quat +Vec3 +Vec3 +Overlays: + Uuid +Uuid.NULL +Uuid +Uuid.NULL +Uuid +Uuid +Uuid +Uuid.NULL +Uuid +Uuid +Uuid +Uuid +Uuid +Vec3 +Uuid +PickRay +PickRay +Uuid +Uuid +Uuid +Uuid +Uuid +Vec2 +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +Uuid +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +PointerEvent +Uuid +Uuid.NULL +Size +Uuid +Size +Vec3 +Vec3 +Quat +Quat +Uuid +Vec2 +Color +Color +Color +Color +Color +Color +Color +Color +Color +Color +Color +Color +Vec3 +Vec3 +Quat +Quat +Uuid +Vec3 +Color +Vec3 +Vec3 +Quat +Quat +Uuid +Vec2 +Color +Vec3 +Vec3 +Quat +Quat +Uuid +Vec2 +Rect +Rect +Vec2 +Color +Color +Vec3 +Vec3 +Quat +Quat +Uuid +Uuid +Vec3 +Vec3 +Vec3 +Vec3 +Color +Vec3 +Vec3 +Quat +Quat +Uuid +Vec3 +Vec3 +Quat +Vec3 +Quat +Vec3 +PickRay +PickRay +Uuid +PickRay +Vec3 +Vec3 +Color +Vec3 +Vec3 +Quat +Quat +Uuid +Vec2 +Rect +Color +Color +Color +Vec3 +Vec3 +Quat +Quat +Uuid +Vec3 +Color +Vec3 +Vec3 +Quat +Quat +Uuid +Vec3 +Color +Vec3 +Vec3 +Quat +Quat +Uuid +Vec2 +Color +Rect +Color +Color +Color +Vec3 +Vec3 +Quat +Quat +Uuid +Vec2 +Picks: + Uuid +Uuid +Vec3 +Vec3 +Vec3 +Vec3 +Uuid +Vec3 +Vec3 +PickRay +Uuid +Vec3 +Vec3 +StylusTip +Pointers: + Uuid +Uuid +Quat: + Quat +Quat +Quat +Vec3 +Quat +Vec3 +Quat +Vec3 +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Vec3 +Vec3 +Quat +Quat +Vec3 +Vec3 +Quat +Vec3 +Quat +Vec3 +Vec3 +Quat +Vec3 +Vec3 +Quat +Vec3 +Vec3 +Quat +Vec3 +Quat +Quat +Quat +Quat +Vec3 +Vec3 +Vec3 +Quat +Quat +Vec3 +Vec3 +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Vec3 +Vec3 +Quat +Vec3 +Quat +Vec3 +Vec3 +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Quat +Recording: + Recording~loadRecordingCallback +Reticle: + Vec2 +Vec2 +Vec2 +Vec2 +Vec2 +Vec2 +Vec2 +RouteObject: + MappingObject +Controller +MappingObject +Pose +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +Pose +RouteObject +RouteObject +RouteObject +RouteObject +Pose +RouteObject +RouteObject +RouteObject +RouteObject +Pose +RouteObject +RouteObject +RouteObject +RouteObject +Pose +RouteObject +RouteObject +RouteObject +RouteObject +Pose +Quat +RouteObject +RouteObject +Pose +RouteObject +RouteObject +Pose +RouteObject +RouteObject +Pose +Vec3 +RouteObject +RouteObject +RouteObject +RouteObject +RouteObject +Scene: + Scene.Stage +Stage +Stage: + Scene.Stage.KeyLight +Scene.Stage.Location +Scene.Stage.Time +Quat +Vec3 +Vec3 +Script: + Uuid +Uuid +Uuid +Collision +Uuid +PointerEvent +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +ScriptDiscoveryService: + ScriptsModel +ScriptsModelFilter +ScriptsModel: + ScriptDiscoveryService +http://doc.qt.io/qt-5/qabstractitemmodel +ScriptsModelFilter: + ScriptDiscoveryService +http://doc.qt.io/qt-5/qsortfilterproxymodel +Selection: + Uuid +Uuid +Color +Color +Color +Color +Uuid +Uuid +Uuid +SoundCache: + Resource +Resource +Resource +Resource +Tablet: + TabletProxy +TabletProxy +TabletButtonProxy: + Uuid +TabletProxy: + TabletButtonProxy +TabletButtonProxy +TabletButtonProxy +TextureCache: + Resource +Resource +Resource +Resource +Resource +Resource +Users: + Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid: + Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Uuid +Vec3: + Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Quat +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Vec3 +Window: + location +Rect +Vec2 +Vec2 +Vec2 +Camera.mode \ No newline at end of file diff --git a/tools/jsdoc/badLinks b/tools/jsdoc/badLinks new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/jsdoc/gravPrep-Explore.js b/tools/jsdoc/gravPrep-Explore.js index 6e58bea51f..e0f56de1f2 100644 --- a/tools/jsdoc/gravPrep-Explore.js +++ b/tools/jsdoc/gravPrep-Explore.js @@ -1,446 +1,474 @@ // Dependencies - const htmlclean = require('htmlclean'); - const fs = require('fs'); - const path = require('path'); - const pretty = require('pretty'); - const cheerio = require('cheerio'); - const rimraf = require('rimraf'); - const dedent = require('dedent-js'); +const htmlclean = require('htmlclean'); +const fs = require('fs'); +const path = require('path'); +const pretty = require('pretty'); +const cheerio = require('cheerio'); +const rimraf = require('rimraf'); +const dedent = require('dedent-js'); // Arg Vars - const copyLocal = process.argv[2]; - console.log("copyLocal:", copyLocal); - let targetTemplateDirectory = '' - let targetMDDirectory = '' - if (copyLocal){ - targetTemplateDirectory = process.argv[3]; - targetMDDirectory = process.argv[4];; - } +const copyLocal = process.argv[2]; +console.log("copyLocal:", copyLocal); +let targetTemplateDirectory = '' +let targetMDDirectory = '' +if (copyLocal){ + targetTemplateDirectory = process.argv[3]; + targetMDDirectory = process.argv[4];; +} // Required directories - let dir_out = path.join(__dirname, 'out'); +let dir_out = path.join(__dirname, 'out'); - let dir_grav = path.join(dir_out, 'grav'); - let dir_css = path.join(dir_grav, 'css'); - let dir_js = path.join(dir_grav, 'js'); - let dir_template = path.join(dir_grav, 'templates'); +let dir_grav = path.join(dir_out, 'grav'); +let dir_css = path.join(dir_grav, 'css'); +let dir_js = path.join(dir_grav, 'js'); +let dir_template = path.join(dir_grav, 'templates'); + +let dir_md = path.join(dir_grav, '06.api-reference'); +let dir_md_objects = path.join(dir_md, '02.Objects'); +let dir_md_namespaces = path.join(dir_md, '01.Namespaces'); +let dir_md_globals = path.join(dir_md, '03.Globals'); - let dir_md = path.join(dir_grav, '06.api-reference'); - let dir_md_objects = path.join(dir_md, '02.Objects'); - let dir_md_namespaces = path.join(dir_md, '01.Namespaces'); - let dir_md_globals = path.join(dir_md, '03.Globals'); - // Array to itterate over and create if doesn't exist - let dirArray = [dir_grav, dir_css, dir_js, dir_template, dir_md, dir_md_objects, dir_md_namespaces, dir_md_globals]; +let dirArray = [dir_grav, dir_css, dir_js, dir_template, dir_md, dir_md_objects, dir_md_namespaces, dir_md_globals]; // Maps for directory names - let map_dir_md = { - "API-Reference": dir_md, - "Globals": dir_md_globals, - "Objects": dir_md_objects, - "Namespaces": dir_md_namespaces, - "Class": dir_md_objects, - "Namespace": dir_md_namespaces, - "Global": dir_md_globals - } +let map_dir_md = { + "API-Reference": dir_md, + "Globals": dir_md_globals, + "Objects": dir_md_objects, + "Namespaces": dir_md_namespaces, + "Class": dir_md_objects, + "Namespace": dir_md_namespaces, + "Global": dir_md_globals +} // Base Grouping Directories for MD files - let baseMDDirectories = ["API-Reference", "Globals", "Namespaces", "Objects"] +let baseMDDirectories = ["API-Reference", "Globals", "Namespaces", "Objects"] // Html variables to be handle regex replacements - const html_reg_static = /\(static\)<\/span>/g - const html_reg_title = /\.+?\<\/h1\>/g; - const html_reg_htmlExt = /\.html/g; - const html_reg_objectHeader = /
[\s\S]+?<\/header>/; - const html_reg_objectSpanNew = /

<\/h4>/; - const html_reg_brRemove = /
[\s\S]+?
/; - const html_reg_subsectionEdit = /()([\s\S]*?)(<\/h.>)/g; - const html_reg_subsectionEdit_replace = '

$2

'; - const html_reg_propertiesHeaderEdit = '

Properties:

'; - const html_reg_propertiesHeaderEdit_Replace = '

Properties

'; - const html_reg_typeEdit = /(
Returns[\s\S]*?Type)(<\/dt[\s\S]*?type">)(.*?)(<\/span><\/dd>[\s\S]*?<\/dl>)/g; - const html_reg_typeEdit_replace = '$1: $3' - const html_reg_methodSize = /()(<\/h4>)/g; - const html_reg_methodSize_replace = ''; - const html_reg_typeDefSize = /()/g; - const html_reg_typeDefSize_replace = ''; - const html_reg_returnSize = /
Returns:<\/h5>/g; - const html_reg_returnSize_replace = '
Returns:<\/h6>'; - const html_reg_findByName = '
Methods
`; - const html_reg_findByArticleClose = `` - const html_reg_signalTitle = `

Signals

`; - const html_reg_typeDefinitonsTitle = `

Type Definitions

`; +const html_reg_static = /\(static\)<\/span>/g +const html_reg_title = /\.+?\<\/h1\>/g; +const html_reg_htmlExt = /\.html/g; +const html_reg_objectHeader = /
[\s\S]+?<\/header>/; +const html_reg_objectSpanNew = /

<\/h4>/; +const html_reg_brRemove = /
[\s\S]+?
/; +const html_reg_subsectionEdit = /()([\s\S]*?)(<\/h.>)/g; +const html_reg_subsectionEdit_replace = '

$2

'; +const html_reg_propertiesHeaderEdit = '

Properties:

'; +const html_reg_propertiesHeaderEdit_Replace = '

Properties

'; +const html_reg_typeEdit = /(
Returns[\s\S]*?Type)(<\/dt[\s\S]*?type">)(.*?)(<\/span><\/dd>[\s\S]*?<\/dl>)/g; +const html_reg_typeEdit_replace = '$1: $3' +const html_reg_methodSize = /()(<\/h4>)/g; +const html_reg_methodSize_replace = ''; +const html_reg_typeDefSize = /()/g; +const html_reg_typeDefSize_replace = ''; +const html_reg_returnSize = /
Returns:<\/h5>/g; +const html_reg_returnSize_replace = '
Returns:<\/h6>'; +const html_reg_findByName = '
Methods
`; +const html_reg_findByArticleClose = `` +const html_reg_signalTitle = `

Signals

`; +const html_reg_typeDefinitonsTitle = `

Type Definitions

`; +const html_reg_firstTableClose = ``; + // Mapping for GroupNames and Members - let groupNameMemberMap = { - "Objects": [], - "Namespaces": [], - "Globals": [] - } +let groupNameMemberMap = { + "Objects": [], + "Namespaces": [], + "Globals": [] +} // Procedural functions - // Create the actual MD file - function createMD(title, directory, needsDir, isGlobal){ - let mdSource = makeMdSource(title); - - if (needsDir){ - if (!fs.existsSync(directory)) { - fs.mkdirSync(directory); - } - } - - let destinationMDFile = path.join(directory, `API_${title}.md`); - fs.writeFileSync(destinationMDFile, mdSource); - } - - // Create the actual Template file - function createTemplate(title,content){ - let twigBasePartial = makeTwigFile(content); - let destinationFile = path.join(dir_template, `API_${title}.html.twig`); - fs.writeFileSync(destinationFile, twigBasePartial); - } - - // Copy file from source to target - used for recurssive call - function copyFileSync( source, target ) { - let targetFile = target; - - // If target is a directory a new file with the same name will be created - if ( fs.existsSync( target ) ) { - // console.log("target exists"); - if ( fs.lstatSync( target ).isDirectory() ) { - // console.log("target is a directory"); - - targetFile = path.join( target, path.basename( source ) ); - } - } - - fs.writeFileSync(targetFile, fs.readFileSync(source)); - } - - // Copy file from source to target - function copyFolderRecursiveSync( source, target ) { - var files = []; - - // Check if folder needs to be created or integrated - var targetFolder = path.join( target, path.basename( source ) ); - if ( !fs.existsSync( targetFolder ) ) { - fs.mkdirSync( targetFolder ); - } - - // Copy - if ( fs.lstatSync( source ).isDirectory() ) { - files = fs.readdirSync( source ); - files.forEach( function ( file ) { - var curSource = path.join( source, file ); - if ( fs.lstatSync( curSource ).isDirectory() ) { - copyFolderRecursiveSync( curSource, targetFolder ); - } else { - copyFileSync( curSource, targetFolder ); - } - } ); +// Create the actual MD file +function createMD(title, directory, needsDir, isGlobal){ + let mdSource = makeMdSource(title); + + if (needsDir){ + if (!fs.existsSync(directory)) { + fs.mkdirSync(directory); } } - // Clean up the Html - function prepareHtml(source){ - let htmlBefore = fs.readFileSync(source, {encoding: 'utf8'}); - let htmlAfter = htmlclean(htmlBefore); - let htmlAfterPretty = pretty(htmlAfter); - return cheerio.load(htmlAfterPretty); - } + let destinationMDFile = path.join(directory, `API_${title}.md`); + fs.writeFileSync(destinationMDFile, mdSource); +} - // Base file for MD's - function makeMdSource(title){ - return dedent( - ` - --- - title: ${title} - taxonomy: - category: - - docs - visible: true - --- - ` - ) - } +// Create the actual Template file +function createTemplate(title,content){ + let twigBasePartial = makeTwigFile(content); + let destinationFile = path.join(dir_template, `API_${title}.html.twig`); + fs.writeFileSync(destinationFile, twigBasePartial); +} - // Base file for Templates - function makeTwigFile(contentHtml){ - return dedent( - ` - {% extends 'partials/base_noGit.html.twig' %} - {% set tags = page.taxonomy.tag %} - {% if tags %} - {% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs', 'tag': tags}},'order': {'by': 'default', 'dir': 'asc'}}) %} - {% else %} - {% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs'}},'order': {'by': 'default', 'dir': 'asc'}}) %} - {% endif %} +// Copy file from source to target - used for recurssive call +function copyFileSync( source, target ) { + let targetFile = target; + + // If target is a directory a new file with the same name will be created + if ( fs.existsSync( target ) ) { + // console.log("target exists"); + if ( fs.lstatSync( target ).isDirectory() ) { + // console.log("target is a directory"); - {% block navigation %} - - {% endblock %} - - {% block content %} -
-

{{ page.title }}

- ${contentHtml} -
- {% endblock %} - ` - ) - } - - // Handle NameSpace Group - function handleNamespace(title, content){ - groupNameMemberMap["Namespaces"].push(title); - let destinationDirectory = path.join(map_dir_md["Namespace"], title); - createMD(title, destinationDirectory, true); - createTemplate(title, content); - } - - // Handle Class Group - function handleClass(title, content){ - groupNameMemberMap["Objects"].push(title); - let destinationDirectory = path.join(map_dir_md["Class"], title); - createMD(title, destinationDirectory, true) - - let formatedHtml = content - .replace(html_reg_objectSpanNew,"") - createTemplate(title, formatedHtml); - } - - // Handle Global Group - function handleGlobal(title, content){ - groupNameMemberMap["Globals"].push("Globals"); - createMD("Globals", map_dir_md["Global"], false, true); - createTemplate("Globals", content); - } - - // Handle Group TOCs - function makeGroupTOC(group){ - let mappedGroup; - if (!Array.isArray(group)){ - mappedGroup = groupNameMemberMap[group]; - } else { - mappedGroup = group; + targetFile = path.join( target, path.basename( source ) ); } - let htmlGroup = mappedGroup.map( item => { - return dedent( - ` -
- ${item} -
- ` - ) - }) - return htmlGroup.join("\n"); } - // Handle Class TOCS - function makeClassTOC(group){ - let linkArray = [] - group.forEach( item => { - linkArray.push(`
${item.type}
`) - item.array.forEach( link => { - linkArray.push(``) - }) - }) - return linkArray.join("\n"); + fs.writeFileSync(targetFile, fs.readFileSync(source)); +} + +// Copy file from source to target +function copyFolderRecursiveSync( source, target ) { + var files = []; + + // Check if folder needs to be created or integrated + var targetFolder = path.join( target, path.basename( source ) ); + if ( !fs.existsSync( targetFolder ) ) { + fs.mkdirSync( targetFolder ); } - // Extract IDS for TOC - function extractIDs(groupToExtract){ - let firstLine = ""; - let id = ""; - let extractedIDs = []; - groupToExtract.forEach((item)=>{ - firstLine = item.split("\n")[0]; - try { - id = firstLine.split('id="')[1].split(`"`)[0]; - } catch (e){ - - } - extractedIDs.push(id) - }) - return extractedIDs; - } - - // Helper for splitting up html - // Takes: Content to split, SearchTerm to Split by, term to End Splitting By, and negate Term object array - // negateTermObject { term: "", distance: "3"} - // Returns: [newContent after Split, Array of extracted ] - function splitBy(content, searchTerm, endSplitTerm){ - let foundArray = []; - let curIndex = -1; - let afterCurSearchIndex = -1 - let negateTermIndex = -1; - let nextIndex = 0; - let findbyNameLength = searchTerm.length; - let curfoundArrayIndex = 0; - let curEndSplitTermIndex = -1; - do { - curEndSplitTermIndex = content.indexOf(endSplitTerm); - curIndex = content.indexOf(searchTerm); - afterCurSearchIndex = curIndex+findbyNameLength; - nextIndex = content.indexOf(searchTerm,afterCurSearchIndex); - if (nextIndex === -1){ - nextIndex = curEndSplitTermIndex; - } - foundArray.push(content.slice(curIndex, nextIndex)) - // remove that content - content = content.replace(foundArray[curfoundArrayIndex], ""); - curfoundArrayIndex++; - } while (curIndex > -1) - return [content, foundArray]; - } - - // Split the signals, methods, and typeDefs [Might make this more generic] - function splitMethodsSignalsAndTypeDefs(allItemToSplit){ - let methodArray = []; - let signalArray = []; - let typeDefArray = []; - console.log(allItemToSplit.length); - allItemToSplit.forEach( method => { - firstLine = method.split("\n")[0]; - if (firstLine.indexOf("Signal") > -1){ - console.log("Found signal") - signalArray.push(method); - } else if (firstLine.indexOf("span") > -1) { - // console.log("Found method") - methodArray.push(method); + // Copy + if ( fs.lstatSync( source ).isDirectory() ) { + files = fs.readdirSync( source ); + files.forEach( function ( file ) { + var curSource = path.join( source, file ); + if ( fs.lstatSync( curSource ).isDirectory() ) { + copyFolderRecursiveSync( curSource, targetFolder ); } else { - // console.log("Found typeDef") - - typeDefArray.push(method); + copyFileSync( curSource, targetFolder ); } - }) - return [methodArray, signalArray, typeDefArray]; + }); } +} - // Helper to append - // Takes content, the search term to appendTo, the content to append, - // and bool if the append is before the found area - function append(content, searchTermToAppendto, contentToAppend, appendBefore){ - let contentArray = content.split("\n"); - let foundIndex = findArrayTrim(contentArray, searchTermToAppendto) - foundIndex = appendBefore ? foundIndex : foundIndex +1 +// Clean up the Html +function prepareHtml(source){ + let htmlBefore = fs.readFileSync(source, {encoding: 'utf8'}); + let htmlAfter = htmlclean(htmlBefore); + let htmlAfterPretty = pretty(htmlAfter); + return cheerio.load(htmlAfterPretty); +} + +// Base file for MD's +function makeMdSource(title){ + return dedent( + ` + --- + title: ${title} + taxonomy: + category: + - docs + visible: true + --- + ` + ) +} + +// Base file for Templates +function makeTwigFile(contentHtml){ + return dedent( + ` + {% extends 'partials/base_noGit.html.twig' %} + {% set tags = page.taxonomy.tag %} + {% if tags %} + {% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs', 'tag': tags}},'order': {'by': 'default', 'dir': 'asc'}}) %} + {% else %} + {% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs'}},'order': {'by': 'default', 'dir': 'asc'}}) %} + {% endif %} - contentArray.splice(foundIndex,0,contentToAppend) - return contentArray.join("\n") - } + {% block navigation %} + + {% endblock %} + + {% block content %} +
+

{{ page.title }}

+ ${contentHtml} +
+ {% endblock %} + ` + ) +} - // Helper function for append - function findArrayTrim(array, searchTerm){ - var index = -1; - for (var i = 0; i < array.length; i++){ - index = array[i].trim().indexOf(searchTerm.trim()); - if (index > -1){ - return i +// Handle NameSpace Group +function handleNamespace(title, content){ + groupNameMemberMap["Namespaces"].push(title); + let destinationDirectory = path.join(map_dir_md["Namespace"], title); + createMD(title, destinationDirectory, true); + createTemplate(title, content); +} + +// Handle Class Group +function handleClass(title, content){ + groupNameMemberMap["Objects"].push(title); + let destinationDirectory = path.join(map_dir_md["Class"], title); + createMD(title, destinationDirectory, true) + + let formatedHtml = content + .replace(html_reg_objectSpanNew,"") + createTemplate(title, formatedHtml); +} + +// Handle Global Group +function handleGlobal(title, content){ + groupNameMemberMap["Globals"].push("Globals"); + createMD("Globals", map_dir_md["Global"], false, true); + createTemplate("Globals", content); +} + +// Handle Group TOCs +function makeGroupTOC(group){ + let mappedGroup; + if (!Array.isArray(group)){ + mappedGroup = groupNameMemberMap[group]; + } else { + mappedGroup = group; + } + let htmlGroup = mappedGroup.map( item => { + return dedent( + ` +
+ ${item} +
+ ` + ) + }) + return htmlGroup.join("\n"); +} + +// Handle Class TOCS +function makeClassTOC(group){ + console.log("group", group) + let linkArray = [] + group.forEach( item => { + linkArray.push(`
${item.type}
`) + item.array.forEach( link => { + if ( link.indexOf('.') > -1 ){ + linkArray.push(``); + } else { + linkArray.push(``); + } + + }) + linkArray.push("
"); + }) + return linkArray.join("\n"); +} + +// Extract IDS for TOC +function extractIDs(groupToExtract){ + let firstLine = ""; + let id = ""; + let extractedIDs = []; + groupToExtract.forEach((item)=>{ + firstLine = item.split("\n")[0]; + try { + id = firstLine.split('id="')[1].split(`"`)[0]; + } catch (e){ + + } + extractedIDs.push(id) + }) + return extractedIDs; +} + +// Helper for splitting up html +// Takes: Content to split, SearchTerm to Split by, and term to End Splitting By +// Returns: [newContent after Split, Array of extracted ] +function splitBy(content, searchTerm, endSplitTerm){ + let foundArray = []; + let curIndex = -1; + let afterCurSearchIndex = -1 + let negateTermIndex = -1; + let nextIndex = 0; + let findbyNameLength = searchTerm.length; + let curfoundArrayIndex = 0; + let curEndSplitTermIndex = -1; + do { + curEndSplitTermIndex = content.indexOf(endSplitTerm); + curIndex = content.indexOf(searchTerm); + afterCurSearchIndex = curIndex+findbyNameLength; + nextIndex = content.indexOf(searchTerm,afterCurSearchIndex); + if (nextIndex === -1){ + nextIndex = curEndSplitTermIndex; + } + foundArray.push(content.slice(curIndex, nextIndex)) + // remove that content + content = content.replace(foundArray[curfoundArrayIndex], ""); + curfoundArrayIndex++; + } while (curIndex > -1) + return [content, foundArray]; +} + +// Split the signals and methods [Might make this more generic] +function splitMethodsSignalsAndTypeDefs(allItemToSplit){ + let methodArray = []; + let signalArray = []; + let typeDefArray = []; + let description; + // console.log(allItemToSplit.length); + allItemToSplit.forEach( content => { + firstLine = content.split("\n")[0]; + if (firstLine.indexOf("Signal") > -1){ + // console.log("Found signal") + signalArray.push(content); + } else if (firstLine.indexOf("span") > -1) { + // console.log("Found method") + if (content.indexOf("Available") > -1){ + console.log("found Available"); + description = content; + } else { + methodArray.push(content); + } + } else { + // console.log("Found typeDef") + if(firstLine.trim() !== ""){ + typeDefArray.push(content); } } - return index; + }) + return [methodArray, signalArray, typeDefArray, description]; +} + +// Helper to append +// Takes content, the search term to appendTo, the content to append, +// and bool if the append is before the found area +function append(content, searchTermToAppendto, contentToAppend, appendBefore){ + let contentArray = content.split("\n"); + let foundIndex = findArrayTrim(contentArray, searchTermToAppendto) + foundIndex = appendBefore ? foundIndex : foundIndex +1 + + contentArray.splice(foundIndex,0,contentToAppend) + return contentArray.join("\n") +} + +// Helper function for append +function findArrayTrim(array, searchTerm){ + var index = -1; + for (var i = 0; i < array.length; i++){ + index = array[i].trim().indexOf(searchTerm.trim()); + if (index > -1){ + return i + } } + return index; +} // Remove grav directory if exists to make sure old files aren't kept - if (fs.existsSync(dir_grav)){ - console.log("dir_grav exists"); - rimraf.sync(dir_grav); - } +if (fs.existsSync(dir_grav)){ + console.log("dir_grav exists"); + rimraf.sync(dir_grav); +} // Create Grav directories in JSDOC output - dirArray.forEach(function(dir){ - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); - } - }) +dirArray.forEach(function(dir){ + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } +}) // Create baseMD files - baseMDDirectories.forEach( md => { - createMD(md, map_dir_md[md]); - }) +baseMDDirectories.forEach( md => { + createMD(md, map_dir_md[md]); +}) // Read jsdoc output folder and process html files - let curSource = path.join(dir_out, "Controller.html"); + let curSource = path.join(dir_out, 'global.html'); if (path.extname(curSource) == ".html" && path.basename(curSource, '.html') !== "index") { // Clean up the html source - let loadedHtml = prepareHtml(curSource); + let loadedHtml = prepareHtml(curSource); // Extract the title, group name, and the main div - let splitTitle = loadedHtml("title").text().split(": "); - let groupName = splitTitle[1]; - let htmlTitle = splitTitle.pop(); - let mainDiv = loadedHtml("#main") + let splitTitle = loadedHtml("title").text().split(": "); + let groupName = splitTitle[1]; + let htmlTitle = splitTitle.pop(); + let mainDiv = loadedHtml("#main") - let methodIDs = []; - let signalIDs = []; - let typeDefIDs = []; - // Basic Regex HTML edits - let mainDivRegexed = mainDiv.html() - .replace(html_reg_static,"") - .replace(html_reg_title,"") - .replace(html_reg_objectHeader,"") - .replace(html_reg_htmlExt,"") - .replace(html_reg_brRemove, "") - .replace(html_reg_subsectionEdit, html_reg_subsectionEdit_replace) - .replace(html_reg_propertiesHeaderEdit, html_reg_propertiesHeaderEdit_Replace) - .replace(html_reg_typeEdit, html_reg_typeEdit_replace) - .replace(html_reg_returnSize, html_reg_returnSize_replace) - .replace(html_reg_methodSize, html_reg_methodSize_replace) - .replace(html_reg_typeDefSize, html_reg_typeDefSize_replace) - .replace(html_reg_typeDefinitonsTitle, ""); - + let methodIDs = []; + let signalIDs = []; + let typeDefIDs = []; + // Basic Regex HTML edits + let mainDivRegexed = mainDiv.html() + .replace(html_reg_static,"") + .replace(html_reg_title,"") + .replace(html_reg_objectHeader,"") + .replace(html_reg_htmlExt,"") + .replace(html_reg_brRemove, "") + .replace(html_reg_subsectionEdit, html_reg_subsectionEdit_replace) + .replace(html_reg_propertiesHeaderEdit, html_reg_propertiesHeaderEdit_Replace) + .replace(html_reg_typeEdit, html_reg_typeEdit_replace) + .replace(html_reg_returnSize, html_reg_returnSize_replace) + .replace(html_reg_methodSize, html_reg_methodSize_replace) + .replace(html_reg_typeDefSize, html_reg_typeDefSize_replace) + .replace(html_reg_typeDefinitonsTitle, "") + .replace(html_reg_findByMethod, ""); + fs.writeFileSync(__dirname + "/Examine/global.html", mainDivRegexed); + // Further HTML Manipulation + // Split HTML by Each named entry + let contentSplitArray = splitBy(mainDivRegexed, html_reg_findByName, html_reg_findByArticleClose); + // Create a reference to the current content after split and the split functions + let currentContent = contentSplitArray[0]; + // Create references to the split methods and signals + let processedMethodsSignalsAndTypeDefs = splitMethodsSignalsAndTypeDefs(contentSplitArray[1]); + let splitMethods = processedMethodsSignalsAndTypeDefs[0]; + let splitSignals = processedMethodsSignalsAndTypeDefs[1]; + let splitTypeDefintions = processedMethodsSignalsAndTypeDefs[2]; + let splitDescription = processedMethodsSignalsAndTypeDefs[3]; + let splitMethodIDS = extractIDs(splitMethods); + let splitSignalIDS = extractIDs(splitSignals); + let splitTypeDefinitionIDS = extractIDs(splitTypeDefintions); + let arrayToPassToClassToc = []; + + // Append Signals and Methods to the current Content + if (!splitDescription) { + currentContent = append(currentContent, html_reg_title, splitDescription); + } + if (splitMethods.length > 0) { + arrayToPassToClassToc.push({type: "Methods", array: splitMethodIDS}); + // Add the Signals header to the Signals HTML + splitMethods.unshift(html_reg_findByMethod) + currentContent = append(currentContent, html_reg_findByArticleClose, splitMethods.join('\n'), true); + } + if (splitSignals.length > 0) { + arrayToPassToClassToc.push({type: "Signals", array: splitSignalIDS}); + // Add the Signals header to the Signals HTML + splitSignals.unshift(html_reg_signalTitle) + currentContent = append(currentContent, html_reg_findByArticleClose, splitSignals.join('\n'),true); + } + if (splitTypeDefintions.length > 0) { + + // console.log(path.basename(curSource, '.html')); + // console.log(splitTypeDefintions.length); + arrayToPassToClassToc.push({type: "Type Definitions", array: splitTypeDefinitionIDS}); + // Add the Signals header to the Signals HTML + splitTypeDefintions.unshift(html_reg_typeDefinitonsTitle) + currentContent = append(currentContent, html_reg_findByArticleClose, splitTypeDefintions.join('\n'), true); + } + + let classTOC = makeClassTOC(arrayToPassToClassToc); + currentContent = append(currentContent, html_reg_firstTableClose, classTOC); - // Further HTML Manipulation - // Split HTML by Each named entry - let contentSplitArray = splitBy(mainDivRegexed, html_reg_findByName, html_reg_findByArticleClose); - // Create a reference to the current content after split and the split functions - let currentContent = contentSplitArray[0]; - // Create references to the split methods and signals - let splitMethodsSignalsAndTypeDefs = splitMethodsSignalsAndTypeDefs(contentSplitArray[1]); - let splitMethods = splitMethodsSignalsAndTypeDefs[0]; - let splitSignals = splitMethodsSignalsAndTypeDefs[1]; - let splitTypeDefintions = splitMethodsSignalsAndTypeDefs[2]; - let splitMethodIDS = extractIDs(splitMethods); - let splitSignalIDS = extractIDs(splitSignals); - let splitTypeDefinitionIDS = extractIDs(splitTypeDefintions); - let classTOC = makeClassTOC([ - {type: "Methods", array: splitMethodIDS}, - {type: "Signals", array: splitSignalIDS}, - {type: "Type Definitions", array: splitTypeDefinitionIDS} - ]); - - // Append Signals and Methods to the current Content - currentContent = append(currentContent, html_reg_findByTitle, classTOC); - currentContent = append(currentContent, html_reg_findByMethod, splitMethods.join('\n')); - if (splitSignals.length > 0) { - // Add the Signals header to the Signals HTML - splitSignals.unshift(html_reg_signalTitle) - currentContent = append(currentContent, html_reg_findByArticleClose, splitSignals.join('\n'),true); - } - if (splitTypeDefintions.length > 0) { - // Add the Signals header to the Signals HTML - splitTypeDefintions.unshift(html_reg_typeDefinitonsTitle) - currentContent = append(currentContent, html_reg_findByArticleClose, splitTypeDefintions.join('\n'), true); - } - - // Final Pretty Content - currentContent = htmlclean(currentContent); - currentContent = pretty(currentContent); + // Final Pretty Content + currentContent = htmlclean(currentContent); + currentContent = pretty(currentContent); + // Handle Unique Categories switch(groupName){ case "Namespace": @@ -462,25 +490,4 @@ createTemplate("API-Reference", makeGroupTOC(["Namespaces", "Objects", "Globals" createTemplate("Namespaces", makeGroupTOC("Namespaces")); createTemplate("Objects", makeGroupTOC("Objects")); -// Copy the files to the target Directories if Local -if (copyLocal){ - // Copy files to the Twig Directory - let templateFiles = fs.readdirSync(path.resolve(targetTemplateDirectory)); - // Remove Existing API files - templateFiles.forEach(function(file){ - let curSource = path.join(targetTemplateDirectory, file); - - if(path.basename(file, '.html').indexOf("API") > -1){ - fs.unlink(curSource); - } - }) - copyFolderRecursiveSync(dir_template, targetTemplateDirectory); - - // Copy files to the Md Directory - let baseMdRefDir = path.join(targetMDDirectory,"06.api-reference"); - // Remove existing MD directory - if (fs.existsSync(baseMdRefDir)){ - rimraf.sync(baseMdRefDir); - } - copyFolderRecursiveSync(dir_md, targetMDDirectory); -} +// Copy the files to the target Directories if Local \ No newline at end of file diff --git a/tools/jsdoc/gravPrep.js b/tools/jsdoc/gravPrep.js index adb1625e9a..0193f781ae 100644 --- a/tools/jsdoc/gravPrep.js +++ b/tools/jsdoc/gravPrep.js @@ -43,6 +43,12 @@ "Namespace": dir_md_namespaces, "Global": dir_md_globals } +// Map for Links + let map_links = { + "Global": "globals", + "Namespace": "namespaces", + "Class": "objects" + } // Base Grouping Directories for MD files let baseMDDirectories = ["API-Reference", "Globals", "Namespaces", "Objects"] @@ -52,7 +58,7 @@ const html_reg_title = /\.+?\<\/h1\>/g; const html_reg_htmlExt = /\.html/g; const html_reg_objectHeader = /
[\s\S]+?<\/header>/; - const html_reg_objectSpanNew = /

<\/h4>/; + const html_reg_objectSpanNew = /

<\/h5>/; const html_reg_brRemove = /
[\s\S]+?
/; const html_reg_subsectionEdit = /()([\s\S]*?)(<\/h.>)/g; const html_reg_subsectionEdit_replace = '

$2

'; @@ -69,11 +75,21 @@ const html_reg_findByName = '
Methods
`; + const html_reg_containerOverview = `
` + const html_reg_findByArticleOpen = `
` const html_reg_findByArticleClose = `
` const html_reg_signalTitle = `

Signals

`; const html_reg_typeDefinitonsTitle = `

Type Definitions

`; const html_reg_firstTableClose = ``; - + const html_reg_fixLinkHashIssue = /()/g; + const html_reg_fixLinkHashIssue_replace = "$1$2#$4" + const html_reg_findLinks = /([\s\S]+?<\/a>)/g; + const html_reg_findGlobalLinks = /()/g; + const html_reg_findClassLinks = /([\s\S]+?<\/a>)/g; + // Mapping for GroupNames and Members let groupNameMemberMap = { @@ -83,7 +99,73 @@ } // Procedural functions + + function isMultipleDots(content){ + let count = 0; + let regEx = /\./g + let tempArray; + while ((tempArray = regEx.exec(content)) !== null){ + count++; + } + if (count > 1){ + return true; + } + } + + function modifyClassLinks(match, p1,p2,p3,p4){ + let matchedp = [p2,p3].join(""); + if(!isMultipleDots(matchedp)){ + return; + } + p2 = p2.split('.')[1].toLowerCase(); + return [p1,p2,p3,p4].join(""); + } + + function lowerCaseGeneralLinks(match, p1, p2, p3, p4){ + let modifiedString = [p1,p2.toLowerCase(),p3,p4].join(""); + return modifiedString; + } + + function contentReplace(content, title){ + var linksNoHashes = []; + var tempArray; + while(( tempArray = html_reg_findLinksNoHashes.exec(content)) !== null ){ + let tempArrayToPush = tempArray.slice(0,4) + tempArrayToPush.push(tempArray.index); + linksNoHashes.push(tempArrayToPush); + } + if (!linksNoHashes){ + return content; + } + for(var i = linksNoHashes.length-1; i > -1; i--){ + if (linksNoHashes[i][0].indexOf("http") > -1){ + continue; + } + let linkLength = linksNoHashes[i][0].length; + let group1 = linksNoHashes[i][1]; + let group2 = linksNoHashes[i][2]; + if (group2.indexOf(".") > -1){ + group2 = group2.split(".")[1].toLowerCase(); + } + let group3 = linksNoHashes[i][3]; + let index = linksNoHashes[i][4]; + let newString = `${group1}/api-reference/${returnRightGroup(group2)}/${group2.toLowerCase()}${group3}`; + content = [content.slice(0,index), newString, content.slice(index+linkLength)].join(""); + } + return content; + } + // Create the actual MD file + function returnRightGroup(methodToCheck){ + for ( var key in groupNameMemberMap ){ + for (i = 0; i < groupNameMemberMap[key].length; i++ ){ + if (methodToCheck.toLowerCase() === groupNameMemberMap[key][i].toLowerCase()){ + return key.toLowerCase(); + } + } + } + } + function createMD(title, directory, needsDir, isGlobal){ let mdSource = makeMdSource(title); @@ -110,10 +192,7 @@ // If target is a directory a new file with the same name will be created if ( fs.existsSync( target ) ) { - // console.log("target exists"); if ( fs.lstatSync( target ).isDirectory() ) { - // console.log("target is a directory"); - targetFile = path.join( target, path.basename( source ) ); } } @@ -204,7 +283,6 @@ // Handle NameSpace Group function handleNamespace(title, content){ - groupNameMemberMap["Namespaces"].push(title); let destinationDirectory = path.join(map_dir_md["Namespace"], title); createMD(title, destinationDirectory, true); createTemplate(title, content); @@ -212,7 +290,6 @@ // Handle Class Group function handleClass(title, content){ - groupNameMemberMap["Objects"].push(title); let destinationDirectory = path.join(map_dir_md["Class"], title); createMD(title, destinationDirectory, true) @@ -223,7 +300,6 @@ // Handle Global Group function handleGlobal(title, content){ - groupNameMemberMap["Globals"].push("Globals"); createMD("Globals", map_dir_md["Global"], false, true); createTemplate("Globals", content); } @@ -258,7 +334,12 @@ group.forEach( item => { linkArray.push(`
${item.type}
`) item.array.forEach( link => { - linkArray.push(`
`) + if ( link.indexOf('.') > -1 ){ + linkArray.push(``); + } else { + linkArray.push(``); + + } }) linkArray.push("
"); }) @@ -315,23 +396,25 @@ let methodArray = []; let signalArray = []; let typeDefArray = []; - // console.log(allItemToSplit.length); - allItemToSplit.forEach( method => { - firstLine = method.split("\n")[0]; + let description; + + allItemToSplit.forEach( content => { + firstLine = content.split("\n")[0]; if (firstLine.indexOf("Signal") > -1){ - // console.log("Found signal") - signalArray.push(method); + signalArray.push(content); } else if (firstLine.indexOf("span") > -1) { - // console.log("Found method") - methodArray.push(method); + if (content.indexOf("Available in:") > -1){ + description = content; + } else { + methodArray.push(content); + } } else { - // console.log("Found typeDef") if(firstLine.trim() !== ""){ - typeDefArray.push(method); + typeDefArray.push(content); } } }) - return [methodArray, signalArray, typeDefArray]; + return [methodArray, signalArray, typeDefArray, description]; } // Helper to append @@ -378,12 +461,34 @@ }) // Read jsdoc output folder and process html files + let links = []; + let unTouchedLinks = []; let files = fs.readdirSync(dir_out); + // Create initial Group name member map to handle individual link :: TODO find better way to do this + files.forEach(function (file){ + let curSource = path.join(dir_out, file); + if (path.extname(curSource) == ".html" && path.basename(curSource, '.html') !== "index") { + let loadedHtml = prepareHtml(curSource); + let splitTitle = loadedHtml("title").text().split(": "); + let groupName = splitTitle[1]; + let htmlTitle = splitTitle.pop(); + switch(groupName){ + case "Namespace": + groupNameMemberMap["Namespaces"].push(htmlTitle); + break; + case "Class": + groupNameMemberMap["Objects"].push(htmlTitle); + break; + default: + console.log(`Case not handled for ${groupName}`); + } + } + }) files.forEach(function (file){ let curSource = path.join(dir_out, file); if (path.extname(curSource) == ".html" && path.basename(curSource, '.html') !== "index") { // Clean up the html source - let loadedHtml = prepareHtml(curSource); + let loadedHtml = prepareHtml(curSource); // Extract the title, group name, and the main div let splitTitle = loadedHtml("title").text().split(": "); @@ -408,8 +513,20 @@ .replace(html_reg_methodSize, html_reg_methodSize_replace) .replace(html_reg_typeDefSize, html_reg_typeDefSize_replace) .replace(html_reg_typeDefinitonsTitle, "") - .replace(html_reg_findByMethod, ""); - + .replace(html_reg_findGlobalLinks, html_reg_findGlobalLinks_replace) + .replace(html_reg_findGeneralLinks, lowerCaseGeneralLinks) + .replace(html_reg_findClassLinks, modifyClassLinks) + .replace(html_reg_findByMethod, ""); + + // Fix for namespace and object links + mainDivRegexed = contentReplace(mainDivRegexed, htmlTitle); + + // Grab all links for link changes + let matches = mainDivRegexed.match(html_reg_findLinks); + if (matches){ + unTouchedLinks.push(`${htmlTitle}:\n ${matches.join('\n')}`); + } + // Further HTML Manipulation // Split HTML by Each named entry let contentSplitArray = splitBy(mainDivRegexed, html_reg_findByName, html_reg_findByArticleClose); @@ -420,12 +537,15 @@ let splitMethods = processedMethodsSignalsAndTypeDefs[0]; let splitSignals = processedMethodsSignalsAndTypeDefs[1]; let splitTypeDefintions = processedMethodsSignalsAndTypeDefs[2]; + let splitDescription = processedMethodsSignalsAndTypeDefs[3]; let splitMethodIDS = extractIDs(splitMethods); let splitSignalIDS = extractIDs(splitSignals); let splitTypeDefinitionIDS = extractIDs(splitTypeDefintions); let arrayToPassToClassToc = []; - // Append Signals and Methods to the current Content + if (splitDescription) { + currentContent = append(currentContent, html_reg_containerOverview, splitDescription); + } if (splitMethods.length > 0) { arrayToPassToClassToc.push({type: "Methods", array: splitMethodIDS}); // Add the Signals header to the Signals HTML @@ -439,9 +559,6 @@ currentContent = append(currentContent, html_reg_findByArticleClose, splitSignals.join('\n'),true); } if (splitTypeDefintions.length > 0) { - - // console.log(path.basename(curSource, '.html')); - // console.log(splitTypeDefintions.length); arrayToPassToClassToc.push({type: "Type Definitions", array: splitTypeDefinitionIDS}); // Add the Signals header to the Signals HTML splitTypeDefintions.unshift(html_reg_typeDefinitonsTitle) @@ -449,7 +566,11 @@ } let classTOC = makeClassTOC(arrayToPassToClassToc); - currentContent = append(currentContent, html_reg_firstTableClose, classTOC); + if (groupName === "Global"){ + currentContent = append(currentContent, html_reg_findByTitle, classTOC); + } else { + currentContent = append(currentContent, html_reg_firstTableClose, classTOC); + } // Final Pretty Content currentContent = htmlclean(currentContent); @@ -477,6 +598,8 @@ createTemplate("Namespaces", makeGroupTOC("Namespaces")); createTemplate("Objects", makeGroupTOC("Objects")); + fs.writeFileSync('Links-Untouched', unTouchedLinks.join('\n')); + // Copy the files to the target Directories if Local if (copyLocal){ // Copy files to the Twig Directory @@ -488,6 +611,7 @@ if(path.basename(file, '.html').indexOf("API") > -1){ fs.unlink(curSource); } + }) copyFolderRecursiveSync(dir_template, targetTemplateDirectory); diff --git a/tools/jsdoc/package.json b/tools/jsdoc/package.json index 14ef88390b..f30fa707ab 100644 --- a/tools/jsdoc/package.json +++ b/tools/jsdoc/package.json @@ -6,6 +6,7 @@ "htmlclean": "^3.0.8", "jsdoc": "^3.5.5", "pretty": "^2.0.0", + "request": "^2.85.0", "rimraf": "^2.6.2" }, "private": true diff --git a/tools/jsdoc/warningLog b/tools/jsdoc/warningLog new file mode 100644 index 0000000000..e69de29bb2 From 6cb4901baecfe3d9961bf6c0aaf35a432e8746db Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Mon, 7 May 2018 15:49:53 -0700 Subject: [PATCH 08/10] fixed undefined errors --- tools/jsdoc/Check.js | 64 ++-- tools/jsdoc/Links-Untouched | 680 +++++++++++++++++++++++++++++++++++- tools/jsdoc/gravPrep.js | 15 +- tools/jsdoc/package.json | 1 + 4 files changed, 710 insertions(+), 50 deletions(-) diff --git a/tools/jsdoc/Check.js b/tools/jsdoc/Check.js index af449dafc1..8005db743a 100644 --- a/tools/jsdoc/Check.js +++ b/tools/jsdoc/Check.js @@ -1,18 +1,20 @@ var fs = require('fs'); var path = require('path'); var request = require('request'); +var axios = require('axios'); var badLinks = []; -var baseLink = `http://localhost:8000/api-reference/`; +// var baseLink = `http://localhost:8000/api-reference/`; +var baseLink = `https://docs.highfidelity.com`; var linkList = fs.readFileSync(__dirname + '/Links-Untouched','utf8').split('\n'); -console.log("link list", linkList); +// console.log("link list", linkList); // console.log("filtered List", JSON.stringify(filteredList)); var linkHash = {}; var currentGroup; linkList.forEach( link => { link = link.trim() - console.log("link", link) + // console.log("link", link) if (link.slice(-1) === ':'){ currentGroup = link.slice(0, link.length-1); // console.log("current Group: ", currentGroup); @@ -35,37 +37,39 @@ var keys = Object.keys(linkHash); keys.forEach( key => { for (var linkKey in linkHash[key]){ var link = linkHash[key][linkKey]; - console.log("link", link); + // console.log("link", link); var extractLink = link.split(`"`)[1]; - console.log("extractLink", extractLink) - if (!extractLink.indexOf('http') > -1){ - extractLink = baseLink + extractLink; - } - console.log("about to make a request for", extractLink) - setTimeout(function(){ - request.get(extractLink) - .on('response', response => { - if (response.statusCode(404)){ - console.log("found bad link") - console.log(JSON.stringify({file: key, link: extractLink})) - - // badLinks.push({file: key, link: link}) - stream.write(JSON.stringify({file: key, link: extractLink})); - } - }, 4000) - }) - } + if (!(extractLink.indexOf(':') > -1)){ + console.log(" adding link") + extractLink = baseLink + extractLink; + } else { + // console.log("found https") + } + console.log("extractLink", extractLink) -}) + // console.log("about to make a request for", extractLink) + axios.get(extractLink) + .then( response => { + console.log("response") + if (response.status === 404){ + console.log("found bad link") + // console.log(JSON.stringify({file: key, link: extractLink})) + // stream.write(JSON.stringify({file: key, link: extractLink})); + } + }) + .catch( error => { + console.log("error") + // console.log(error); + // if (error.response.status === 404){ + // console.log("found bad link") + // console.log(JSON.stringify({file: key, link: extractLink})) + // stream.write(JSON.stringify({file: key, link: extractLink})); + // } + }) + } + }) stream.end(); -// */ - -/* - -*/ - - function endsWith(path, exts) { var result = false; diff --git a/tools/jsdoc/Links-Untouched b/tools/jsdoc/Links-Untouched index 9da3060726..bea2009fa5 100644 --- a/tools/jsdoc/Links-Untouched +++ b/tools/jsdoc/Links-Untouched @@ -7,10 +7,18 @@ AnimationCache: Resource Assets: Assets~downloadDataCallback +Assets.GetOptions +Assets.GetOptions Assets~getAssetCallback Assets~getMappingCallback +Assets.PutOptions Assets~setMappingCallback Assets~uploadDataCallback +Assets.getAsset +Assets.putAsset +Assets.putAsset +Assets.getAsset +Assets.putAsset AudioStats: AudioStats.AudioStreamStats AudioStats.AudioStreamStats @@ -40,55 +48,165 @@ AvatarManager: Camera: Vec3 Quat +Camera.Mode ViewFrustum Uuid PickRay PickRay PickRay +Entities.findRayIntersection +Overlays.findRayIntersection PickRay PickRay Uuid Uuid +Camera.Mode +Camera.Mode Quat Quat Vec3 Vec3 Vec3 Vec3 +Camera.Mode Uuid +Camera.Mode Quat Vec3 Clipboard: Uuid Vec3 Vec3 +Clipboard.exportEntities Uuid Vec3 Uuid Controller: - MyAvatar.sessionUUID + getActions +getHardware +getStandard +disableMapping +enableMapping +loadMapping +newMapping +parseMapping +findAction +findDevice +getActionNames +getAllActions +getAvailableInputs +getDeviceName +getDeviceNames +actionEvent +hardwareChanged +inputEvent +keyPressEvent +keyReleaseEvent +mouseDoublePressEvent +mouseMoveEvent +mousePressEvent +mouseReleaseEvent +touchBeginEvent +touchEndEvent +touchUpdateEvent +wheelEvent +captureMouseEvents +captureTouchEvents +captureWheelEvents +releaseMouseEvents +releaseTouchEvents +releaseWheelEvents +captureActionEvents +captureEntityClickEvents +captureJoystick +captureKeyEvents +releaseActionEvents +releaseEntityClickEvents +releaseJoystick +releaseKeyEvents +getValue +getAxisValue +getgetPoseValue +getButtonValue +getAxisValue +getPoseValue +getActionValue +triggerHapticPulse +triggerHapticPulseOnDevice +triggerShortHapticPulse +triggerShortHapticPulseOnDevice +getViewportDimensions +getRecommendedHUDRect +setVPadEnabled +setVPadHidden +setVPadExtraBottomMargin +startInputRecording +stopInputRecording +saveInputRecording +getInputRecorderSaveDirectory +loadInputRecording +startInputPlayback +stopInputPlayback +Entities.callEntityMethod +MyAvatar.sessionUUID +Controller.Actions RouteObject keyboardMouse.json standard.json +Controller.Hardware RouteObject +Controller.Standard RouteObject leapmotion.json vive.json +findAction +Entities.mousePressOnEntity +Entities.mouseDoublePressOnEntity KeyEvent +Controller.Hardware.Keyboard +Controller.Hardware.Keyboard +Controller.Hardware.Touchscreen +Controller.Hardware.TouchscreenVirtualPad +Controller.Hardware.Keyboard +Controller.Actions +Controller.Actions +Controller.Actions +Controller.Actions +Controller.Actions Controller +Controller.Actions +Controller.Actions +Controller.Standard +Controller.Hardware +Controller.Hardware +Controller.Hardware Controller +Controller.Hardware +Controller.Hardware Pose +Controller.Standard +Controller.Hardware Pose Pose Pose Rect Rect +Controller.Standard +Controller.Standard Controller +Controller.Standard +Controller.Standard +Controller.Standard +Controller.Hardware Vec2 Vec2 +Controller.Standard KeyEvent KeyEvent MappingObject +MappingJSON +enableMapping +MappingJSON MappingObject MouseEvent MouseEvent @@ -97,14 +215,47 @@ Controller: MappingObject MappingObject RouteObject +enableMapping +Uuid.generate MappingObject MappingObject +MappingJSON +enableMapping +MappingJSON MappingObject +captureActionEvents +Entities.mousePressOnEntity +Entities.mouseDoublePressOnEntity +captureEntityClickEvents +captureJoystick +captureKeyEvents KeyEvent Controller.Hardware.Keyboard +captureMouseEvents +Controller.Hardware.Keyboard +Controller.Hardware.Touchscreen +Controller.Hardware.TouchscreenVirtualPad +captureTouchEvents +Controller.Hardware.Keyboard +captureWheelEvents +startInputRecording +stopInputRecording +loadInputRecording +getInputRecorderSaveDirectory +setVPadHidden +startInputRecording +stopInputRecording +loadInputRecording +stopInputPlayback +startInputPlayback +startInputRecording TouchEvent TouchEvent TouchEvent +Controller.Hand +Controller.Hand +Controller.Hand +Controller.Hand WheelEvent MappingObject Pose @@ -176,12 +327,16 @@ Controller: Pose Pose RouteObject +Controller.Standard +MappingJSON https://github.com/highfidelity/hifi/tree/master/interface/resources/controllers +Controller.Actions Controller.Hardware-Application Controller.Hardware-Keyboard Controller.Hardware-OculusTouch Controller.Hardware-Vive RouteObject +RouteObject#when RouteObject RouteObject Pose @@ -213,7 +368,21 @@ Controller: Pose MappingObject https://github.com/highfidelity/hifi/tree/master/interface/resources/controllers +Controller.MappingJSONRoute +Controller.MappingJSONRoute +Controller.Hardware +Controller.MappingJSONRoute RouteObject +Controller.MappingJSON +Controller.MappingJSONAxis +Controller.Hardware +RouteObject#peek +RouteObject#debug +Controller.Hardware +Controller.MappingJSONFilter +Controller.MappingJSONFilter +Controller.Actions +Controller.Standard RouteObject Pose leapmotion.json @@ -295,20 +464,27 @@ DebugDraw: Vec4 Entities: Uuid +Web Uuid.NULL Vec3 Vec3 Vec3 Vec3 Uuid +Entities.ActionType +Uuid +Entities.ActionArguments Uuid Uuid -Uuid +Entities.EntityProperties Uuid.NULL Uuid Uuid +Line Uuid +Line Vec3 +Line Uuid Uuid Uuid @@ -326,8 +502,11 @@ Entities: Uuid Uuid Uuid +Entities.EntityProperties Uuid +Web Uuid +Web Uuid Uuid Vec3 @@ -339,6 +518,7 @@ Entities: Vec3 Uuid Uuid +Entities.EntityType Vec3 Uuid Uuid @@ -348,22 +528,40 @@ Entities: Uuid ViewFrustum Uuid +Entities.RayToEntityIntersectionResult PickRay +setLightsArePickable +setZonesArePickable PickRay Uuid Uuid +visible +collisionless +Entities.RayToEntityIntersectionResult PickRay +setLightsArePickable +setZonesArePickable +findRayIntersection PickRay Uuid Uuid +findRayIntersection Quat +Model Uuid +Model Quat.IDENTITY Quat Vec3 +Model Uuid +Model Vec3.ZERO Vec3 +Entities.ActionArguments +Uuid +Uuid +Entities.ActionArguments Uuid Uuid Uuid @@ -373,24 +571,45 @@ Entities: Uuid Uuid Uuid +Zone +Zone Uuid +Entities.EntityProperties Uuid +Entities.EntityProperties Uuid +Model Uuid +Model +getJointNames +Model Uuid +Model +Model +getJointIndex Uuid +Web +Web Uuid -Uuid -Uuid +Light +findRayIntersection +findRayIntersectionBlocking Picks +Light Quat +Model Uuid +Model Quat.IDENTITY Quat Vec3 +Model Uuid +Model Vec3.ZERO Vec3 +Model +PolyVox Uuid Entities~getMeshesCallback Graphics @@ -398,7 +617,11 @@ Entities: Uuid Entities~getServerScriptStatusCallback Uuid +Zone +findRayIntersection +findRayIntersectionBlocking Picks +Zone Uuid PointerEvent Uuid @@ -411,8 +634,11 @@ Entities: Uuid Uuid Vec3 +PolyVox Uuid +PolyVox Vec3 +PolyVox Vec3.ZERO Vec3 PointerEvent @@ -431,76 +657,142 @@ Entities: Uuid Entities~queryPropertyMetadataCallback Uuid +clickDownOnEntity Uuid PointerEvent +clickReleaseOnEntity Uuid PointerEvent +holdingClickOnEntity Uuid PointerEvent +hoverEnterEntity Uuid PointerEvent +hoverLeaveEntity Uuid PointerEvent +hoverOverEntity Uuid PointerEvent +mouseMoveOnEntity Uuid PointerEvent +mousePressOnEntity Uuid PointerEvent +mouseReleaseOnEntity Uuid PointerEvent +Model Uuid Quat +Model +Model Uuid Vec3 +Model +Line Uuid +Line Vec3 +Line +PolyVox Uuid +PolyVox +Zone +Zone +Web Uuid +Web Uuid.NULL +Light +findRayIntersection +findRayIntersectionBlocking Picks +Light +Model Uuid Quat +Model +Model Uuid Quat +Model +Model +setLocalJointRotations +setLocalJointTranslations Uuid Quat Vec3 +Model +Model Uuid Vec3 +Model +Model Uuid Vec3 +Model +PolyVox Uuid +PolyVox Vec3 +PolyVox Uuid +PolyVox Vec3 Vec3 +PolyVox Uuid +PolyVox Vec3 Vec3 +PolyVox Uuid +PolyVox Vec3 +Zone +findRayIntersection +findRayIntersectionBlocking Picks +Zone Uuid Uuid +Entities.ActionArguments Uuid Vec3 +PolyVox Uuid +PolyVox Vec3 +PolyVox Vec3.ZERO Vec3 Vec3 +PolyVox Uuid +PolyVox Vec3 +PolyVox Vec3.ZERO Vec3 +Web +Shape Uuid +Web Uuid Vec3 +PolyVox Uuid +PolyVox Vec3 +PolyVox Vec3.ZERO Vec3 +ActionType +Entities.ActionType +Entities.PhysicsMotionType ActionArguments-FarGrab ActionArguments-Hold ActionArguments-Offset @@ -510,34 +802,52 @@ Entities: ActionArguments-Slider ActionArguments-ConeTwist ActionArguments-BallSocket +ActionType +ActionArguments Vec3 Uuid Vec3 +ActionType +ActionArguments Vec3 Vec3 Uuid Vec3 Vec3 +ActionType +ActionArguments Vec3 Quat Uuid +ActionType +ActionArguments Vec3 Vec3 Uuid Vec3 Vec3 +ActionType +ActionArguments Uuid Vec3 Vec3 +ActionType +ActionArguments Vec3 +ActionType +ActionArguments Vec3 Vec3 Uuid Vec3 Vec3 +ActionType +ActionArguments Vec3 Quat Uuid +ActionType +ActionArguments Vec3 Entities.ActionArguments-FarGrab Entities.ActionArguments-Hold @@ -548,14 +858,21 @@ Entities: ActionArguments-Slider Entities.ActionArguments-ConeTwist Entities.ActionArguments-BallSocket +Skybox Vec3 Vec3 Vec3 Vec3 +EntityType Uuid +Entities.EntityType +Entities.addEntity Uuid Uuid.NULL Uuid +Model +Shape +Zone keyLight Vec3 Quat @@ -574,6 +891,7 @@ Entities: Vec3.ZERO Vec3 Vec3.ZERO +Entities.CollisionMask SoundCache Uuid Uuid.NULL @@ -582,7 +900,9 @@ Entities: Vec3 Vec3 Vec3 +Entities.BoundingBox AACube +Entities.RenderInfo EntityProperties-Box EntityProperties-Light EntityProperties-Line @@ -596,22 +916,46 @@ Entities: EntityProperties-Text EntityProperties-Web EntityProperties-Zone +EntityType +EntityType +EntityType +EntityProperties Vec3 Color +EntityType +EntityProperties Vec3 Vec3 Color +EntityType +Model +Shape +model overlays +EntityProperties +Entities.addEntity MaterialResource MaterialResource MaterialResource Vec2 Vec2 MaterialResource +EntityType +EntityProperties Vec3 +naturalDimensions Color ShapeType +Entities.AnimationProperties Quat +getJointIndex +setLocalJointRotation +getJointIndex Vec3 +getJointIndex +setLocalJointTranslation +getJointIndex +EntityType +EntityProperties Vec3 Quat Color @@ -619,15 +963,20 @@ Entities: Color Color ShapeType +EntityType +EntityProperties Vec3 Vec3 Vec3 Vec3 Color +EntityType +EntityProperties Volumes of Fun library documentation Vec3 Vec3 +Entities.PolyVoxSurfaceStyle Uuid Uuid.NULL Uuid @@ -640,17 +989,34 @@ Entities: Uuid.NULL Uuid Uuid.NULL +EntityType +EntityProperties +Entities.Shape Vec3 Color +EntityType +EntityType +EntityType +EntityProperties Vec3 Color Color +EntityType +EntityProperties Vec3 +EntityType +Entities.enterEntity +EntityProperties Vec3 ShapeType +Entities.KeyLight +Entities.AmbientLight +Entities.Skybox +Entities.Haze EntityProperties-Box EntityProperties-Light EntityProperties-Line +model overlays EntityProperties-Material EntityProperties-Model EntityProperties-ParticleEffect @@ -665,17 +1031,27 @@ Entities: Color Color Vec3 +Model +Shape +canCastShadows PickRay +findRayIntersection +findRayIntersectionBlocking PickRay Uuid PickRay Vec3 Vec3 BoxFace +EntityType Color +Entities.getMeshes MeshProxy MeshProxy +Entities.getMeshes Graphics +Entities.getServerScriptStatus +Entities.queryPropertyMetadata Global: ContactEventType Uuid @@ -684,6 +1060,7 @@ Global: Vec3 Vec3 http://doc.qt.io/qt-5/qt#Key-enum +Material Vec3Color RGBS Vec3Color @@ -692,6 +1069,7 @@ Global: RGBS Vec3Color RGBS +Material Material Material Vec3 @@ -715,12 +1093,20 @@ Global: Vec3 Quat Graphics: - Vec3 + Graphics.Model +Graphics.Model +Graphics.Mesh +Graphics.IFSData +Graphics.Mesh +Vec3 Vec3 Vec3 Vec2 Material +Graphics.MeshPart Uuid +Graphics.Mesh +Graphics.MaterialLayer HMD: Vec3 Vec3.ZERO @@ -741,6 +1127,10 @@ HMD: Vec2 Vec2 Vec2 +requestShowHandControllers +requestHideHandControllers +requestShowHandControllers +requestHideHandControllers Vec2 Vec2 Vec2 @@ -751,6 +1141,10 @@ location: Uuid Uuid.NULL Uuid +goBack +goForward +location.LookupTrigger +location.LookupTrigger Vec3 Quat Quat.IDENTITY @@ -758,43 +1152,85 @@ location: Uuid Uuid Settings +goBack +goForward MappingObject: Controller +Controller.Standard +Controller.Actions +Controller.Hardware +Controller.Standard +Controller.Actions +Controller.newMapping +from +makeAxis RouteObject +Controller.parseMapping +Controller.loadMapping +Controller.MappingJSON +enable +Controller.enableMapping +RouteObject#peek +MappingObject +Controller.disableMapping MappingObject MappingObject -MappingObject +Controller.enableMapping MappingObject RouteObject RouteObject +Controller.Standard +Controller.Hardware Pose RouteObject RouteObject RouteObject RouteObject +from +Controller.Standard +Controller.Hardware Pose RouteObject RouteObject RouteObject RouteObject +Controller.Hardware +Controller.Hardware +Controller.Hardware RouteObject RouteObject RouteObject RouteObject +Controller.Hardware +makeAxis +Controller.Hardware +Controller.Hardware RouteObject RouteObject Menu: - KeyEvent + Menu.MenuItemProperties +Menu.MenuItemProperties +Menu.addMenuItem +Menu.MenuItemProperties +Menu.triggerOption +Menu.addMenuItem +KeyEvent KeyEvent MeshProxy: - Graphics + Entities.getMeshes +Graphics Graphics Vec3 Graphics Vec3 Messages: - Uuid + Entities.callEntityClientMethod +Entities.callEntityMethod +Entities.callEntityServerMethod +Script.callEntityScriptMethod Uuid +Uuid +sendMessage ModelCache: Resource Resource @@ -828,6 +1264,7 @@ MyAvatar: Uuid Vec3 Entities +MyAvatar.getJointNames Vec3 Quat Uuid @@ -842,6 +1279,8 @@ MyAvatar: Vec3 Vec3 Vec3 +MyAvatar.AttachmentData +MyAvatar.AttachmentData Vec3 Vec3 Quat @@ -852,6 +1291,7 @@ MyAvatar: Vec3 Vec3 Vec3 +MyAvatar.getJointNames Vec3 Vec3 Vec3 @@ -863,6 +1303,7 @@ MyAvatar: Avatar Standards Quat Quat +MyAvatar.getJointNames Quat Vec3 Avatar Standards @@ -906,6 +1347,8 @@ MyAvatar: Vec3 Vec3 Vec3 +MyAvatar.SkeletonJoint +MyAvatar.SkeletonJoint Vec3 Vec3 Vec3 @@ -923,13 +1366,17 @@ MyAvatar: Quat Quat Quat +MyAvatar.restoreAnimation Avatar Standards +MyAvatar.restoreRoleAnimation Avatar Standards Vec3 Quat Vec3 Quat Vec3 +MyAvatar.getAttachmentData +MyAvatar.AttachmentData Quat Vec3 Quat @@ -937,6 +1384,7 @@ MyAvatar: Quat Quat Quat +MyAvatar.getJointNames Vec3 Vec3 Vec3 @@ -960,8 +1408,11 @@ MyAvatar: Vec3 Overlays: Uuid +web3d Uuid.NULL Uuid +Overlays.OverlayType +Overlays.OverlayProperties Uuid.NULL Uuid Uuid @@ -970,40 +1421,60 @@ Overlays: Uuid Uuid Uuid +Overlays.OverlayProperties Uuid +Overlays.OverlayProperties +OverlayProperties Uuid Vec3 Uuid +Overlays.RayToOverlayIntersectionResult PickRay PickRay Uuid Uuid +Overlays.RayToOverlayIntersectionResult Uuid +web3d Uuid Uuid Vec2 Uuid Uuid Uuid +Overlays.OverlayProperties Uuid +OverlayProperties Uuid +Overlays.OverlayProperties +Overlays.OverlayType Uuid +Overlays.OverlayType +Overlays.OverlayProperties Uuid +Overlays.OverlayProperties Uuid +OverlayType +sendHoverEnterOverlay Uuid PointerEvent +sendHoverLeaveOverlay Uuid PointerEvent +sendHoverOverOverlay Uuid PointerEvent Uuid Uuid Uuid PointerEvent +sendMouseMoveOnOverlay Uuid PointerEvent +sendMousePressOnOverlay Uuid PointerEvent +sendMouseReleaseOnOverlay Uuid PointerEvent Uuid @@ -1020,14 +1491,17 @@ Overlays: Uuid PointerEvent Uuid +web3d Uuid.NULL Size Uuid Size +OverlayType Vec3 Vec3 Quat Quat +findRayIntersection Uuid Vec2 Color @@ -1041,47 +1515,58 @@ Overlays: Color Color Color +OverlayType Color Vec3 Vec3 Quat Quat +findRayIntersection Uuid Vec3 +OverlayType Color Vec3 Vec3 Quat Quat +findRayIntersection Uuid Vec2 +OverlayType Color Vec3 Vec3 Quat Quat +findRayIntersection Uuid Vec2 Rect +OverlayType Rect Vec2 Color +OverlayType Color Vec3 Vec3 Quat Quat +findRayIntersection Uuid Uuid Vec3 Vec3 Vec3 Vec3 +OverlayType Color Vec3 Vec3 Quat Quat +findRayIntersection Uuid Vec3 Vec3 @@ -1089,57 +1574,107 @@ Overlays: Vec3 Quat Vec3 +OverlayType +Circle3DProperties +CubeProperties +GridProperties +ImageProperties +Image3DProperties +Line3DProperties +ModelProperties +RectangleProperties +Rectangle3DProperties +ShapeProperties +SphereProperties +TextProperties +Text3DProperties +Web3DProperties +OverlayProperties PickRay +findRayIntersection PickRay Uuid PickRay Vec3 Vec3 +OverlayType Color Vec3 Vec3 Quat Quat +findRayIntersection Uuid Vec2 +OverlayType Rect Color Color +OverlayType +OverlayType Color Vec3 Vec3 Quat Quat +findRayIntersection Uuid Vec3 +Overlays.Shape +OverlayType Color Vec3 Vec3 Quat Quat +findRayIntersection Uuid Vec3 +OverlayType Color Vec3 Vec3 Quat Quat +findRayIntersection Uuid Vec2 Color +OverlayType Rect Color Color +OverlayType Color Vec3 Vec3 Quat Quat +findRayIntersection Uuid Vec2 +Paths: + Script.resolvePath +Script.resourcesPath Picks: - Uuid + Picks.PickType +Picks.PickProperties +Picks.createPick +Picks.createPick +Picks.createPick +Picks.RayPickResult +Picks.StylusPickResult +Picks.createPick +Picks.createPick +Picks.createPick +Picks.createPick +Picks.createPick Uuid +Picks.createPick +Uuid +Picks.createPick +Picks.createPick +Picks.PickType Vec3 Vec3 Vec3 @@ -1153,13 +1688,44 @@ Picks: Vec3 StylusTip Pointers: - Uuid + Picks.PickType +Pointers.PointerProperties +Picks.PickProperties +Pointers.createPointer +Pointers.createPointer +Pointers.RayPointerRenderState +Pointers.createPointer +Pointers.createPointer +Picks.RayPickResult +Picks.StylusPickResult +Pointers.createPointer +Pointers.createPointer +Pointers.createPointer +Pointers.createPointer +Pointers.createPointer Uuid +Pointers.createPointer +Uuid +Pointers.createPointer +Pointers.createPointer +Pointers.createPointer +Pointers.RayPointerRenderState +Pointers.createPointer +Pointers.RayPointerRenderState +Pointers.createPointer +Picks.PickProperties +Pointers.RayPointerRenderState +Pointers.DefaultRayPointerRenderState +Pointers.Trigger +Pointers.setRenderState +Pointers.editRenderState Quat: Quat Quat -Quat -Vec3 +Quat.angleAxis +Quat +Vec3 +Quat.angle Quat Vec3 Quat @@ -1171,10 +1737,12 @@ Quat: Quat Quat Quat +Quat.inverse Quat Quat Quat Quat +Quat.dot Quat Quat Quat @@ -1190,9 +1758,11 @@ Quat: Vec3 Quat Vec3 +Quat.getFront Quat Vec3 Vec3 +Quat.getForward Quat Vec3 Vec3 @@ -1202,6 +1772,7 @@ Quat: Quat Vec3 Quat +Quat.conjugate Quat Quat Quat @@ -1214,6 +1785,7 @@ Quat: Vec3 Quat Quat +Quat.slerp Quat Quat Quat @@ -1234,6 +1806,7 @@ Quat: Vec3 Vec3 Quat +Quat.mix Quat Quat Quat @@ -1245,6 +1818,10 @@ Quat: Quat Recording: Recording~loadRecordingCallback +Recording.loadRecording +Resource: + Resource.State +Resource.State Reticle: Vec2 Vec2 @@ -1257,6 +1834,7 @@ RouteObject: MappingObject Controller MappingObject +RouteObject#to Pose RouteObject RouteObject @@ -1295,6 +1873,10 @@ RouteObject: RouteObject Pose RouteObject +Controller.Standard +Controller.Actions +Controller.Standard +Controller.Actions RouteObject Pose RouteObject @@ -1303,8 +1885,12 @@ RouteObject: Vec3 RouteObject RouteObject +Controller.Hardware +Controller.Hardware RouteObject RouteObject +Controller.Hardware +Controller.Hardware RouteObject Scene: Scene.Stage @@ -1325,12 +1911,16 @@ Script: PointerEvent Uuid Uuid +setInterval +setTimeout Uuid Uuid Uuid Uuid Uuid Uuid +Script.clearInterval +Script.clearTimeout Uuid ScriptDiscoveryService: ScriptsModel @@ -1342,7 +1932,16 @@ ScriptsModelFilter: ScriptDiscoveryService http://doc.qt.io/qt-5/qsortfilterproxymodel Selection: - Uuid + Selection.ItemType +Uuid +Selection.disableListToScene +Selection.enableListToScene +Selection.HighlightStyle +Selection.HighlightStyle +Selection.HighlightStyle +Selection.SelectedItemsList +Selection.SelectedItemsList +Selection.ItemType Uuid Color Color @@ -1359,10 +1958,16 @@ SoundCache: Tablet: TabletProxy TabletProxy +Tablet.AudioEvents TabletButtonProxy: Uuid +TabletButtonProxy.ButtonProperties +TabletButtonProxy.ButtonProperties +TabletButtonProxy.ButtonProperties +TabletButtonProxy.ButtonProperties TabletProxy: - TabletButtonProxy + TabletProxy#ButtonList +TabletButtonProxy TabletButtonProxy TabletButtonProxy TextureCache: @@ -1423,6 +2028,7 @@ Vec3: Vec3 Vec3 Vec3 +withinEpsilon Vec3 Vec3 Vec3 @@ -1473,12 +2079,54 @@ Vec3: Vec3 Vec3 Vec3 +equal Vec3 Vec3 Window: location +displayAnnouncement +browseAssetsAsync +assetsDirChanged +browseChanged +browseAsync +browseDirChanged +browseDirAsync +openMessageBox +announcement +Window.ConnectionRefusedReason Rect Vec2 Vec2 Vec2 -Camera.mode \ No newline at end of file +connectionAdded +connectionError +connectionAdded +connectionError +openMessageBox +updateMessageBox +closeMessageBox +Window.MessageBoxButton +Window.MessageBoxButton +takeSnapshot +takeSnapshot +promptTextChanged +promptAsync +raise +saveFileChanged +saveAsync +Camera.setCameraEntity +Camera.mode +Window.DisplayTexture +snapshotShared +shareSnapshot +takeSnapshot +takeSecondaryCameraSnapshot +takeSnapshot +stillSnapshotTaken +processingGifStarted +processingGifCompleted +stillSnapshotTaken +openMessageBox +Window.MessageBoxButton +Window.MessageBoxButton +openMessageBox \ No newline at end of file diff --git a/tools/jsdoc/gravPrep.js b/tools/jsdoc/gravPrep.js index 0193f781ae..0e3d38da6d 100644 --- a/tools/jsdoc/gravPrep.js +++ b/tools/jsdoc/gravPrep.js @@ -115,10 +115,14 @@ function modifyClassLinks(match, p1,p2,p3,p4){ let matchedp = [p2,p3].join(""); if(!isMultipleDots(matchedp)){ - return; + console.log("not multiple"); + console.log("matchedp:", matchedp) + return match; } p2 = p2.split('.')[1].toLowerCase(); - return [p1,p2,p3,p4].join(""); + let newString = [p1,p2,p3,p4].join(""); + // console.log("new String:", newString); + return newString; } function lowerCaseGeneralLinks(match, p1, p2, p3, p4){ @@ -136,7 +140,7 @@ } if (!linksNoHashes){ return content; - } + } for(var i = linksNoHashes.length-1; i > -1; i--){ if (linksNoHashes[i][0].indexOf("http") > -1){ continue; @@ -149,7 +153,8 @@ } let group3 = linksNoHashes[i][3]; let index = linksNoHashes[i][4]; - let newString = `${group1}/api-reference/${returnRightGroup(group2)}/${group2.toLowerCase()}${group3}`; + let newString = `${group1}/api-reference/${returnRightGroup(group2)}/${group2.toLowerCase()}${group3}`; + // console.log("newString", newString); content = [content.slice(0,index), newString, content.slice(index+linkLength)].join(""); } return content; @@ -161,6 +166,8 @@ for (i = 0; i < groupNameMemberMap[key].length; i++ ){ if (methodToCheck.toLowerCase() === groupNameMemberMap[key][i].toLowerCase()){ return key.toLowerCase(); + } else { + // console.log("Couldn't find group: ", methodToCheck); } } } diff --git a/tools/jsdoc/package.json b/tools/jsdoc/package.json index f30fa707ab..4bbb2ad4f2 100644 --- a/tools/jsdoc/package.json +++ b/tools/jsdoc/package.json @@ -1,6 +1,7 @@ { "name": "hifiJSDoc", "dependencies": { + "axios": "^0.18.0", "cheerio": "^1.0.0-rc.2", "dedent-js": "^1.0.1", "htmlclean": "^3.0.8", From f72e7d8c012fac31b2b6b8f01fa86b8133bda982 Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Tue, 8 May 2018 13:09:41 -0700 Subject: [PATCH 09/10] updating for workPC --- tools/jsdoc/gravPrep.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/jsdoc/gravPrep.js b/tools/jsdoc/gravPrep.js index 0e3d38da6d..e6002571ac 100644 --- a/tools/jsdoc/gravPrep.js +++ b/tools/jsdoc/gravPrep.js @@ -249,6 +249,8 @@ category: - docs visible: true + highlight: + enabled: false --- ` ) From c822e836bc538c60cd29c929e55c1826fdd43900 Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Tue, 8 May 2018 21:48:57 -0700 Subject: [PATCH 10/10] general format work --- tools/jsdoc/gravPrep.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/jsdoc/gravPrep.js b/tools/jsdoc/gravPrep.js index e6002571ac..105444a841 100644 --- a/tools/jsdoc/gravPrep.js +++ b/tools/jsdoc/gravPrep.js @@ -66,10 +66,12 @@ const html_reg_propertiesHeaderEdit_Replace = '

Properties

'; const html_reg_typeEdit = /(
Returns[\s\S]*?Type)(<\/dt[\s\S]*?type">)(.*?)(<\/span><\/dd>[\s\S]*?<\/dl>)/g; const html_reg_typeEdit_replace = '$1: $3' - const html_reg_methodSize = /()(<\/h4>)/g; + const html_reg_methodSize = /()(<\/h4>)/g; const html_reg_methodSize_replace = ''; const html_reg_typeDefSize = /()/g; const html_reg_typeDefSize_replace = ''; + const html_reg_typeReturnSize = /
Type:\<\/h5>/g; + const html_reg_typeReturnSize_replace = '
Type:
'; const html_reg_returnSize = /
Returns:<\/h5>/g; const html_reg_returnSize_replace = '
Returns:<\/h6>'; const html_reg_findByName = '
)/g; const html_reg_findClassLinks = /([\s\S]+?<\/a>)/g; - + const html_reg_pretty = /(
)([\s\S]*?)(<\/pre>)/g;
+    const html_reg_pretty_replace = "
$2<\/pre>";
+    const html_reg_code = /()([\s\S]*?)(<\/code>)/g;
+    const html_reg_code_replace = "$1$2$3";
 
 // Mapping for GroupNames and Members
     let groupNameMemberMap = {
@@ -281,9 +286,11 @@
             {% endblock %}
             
             {% block content %}
-                
-

{{ page.title }}

- ${contentHtml} +
+
+

{{ page.title }}

+ ${contentHtml} +
{% endblock %} ` @@ -525,6 +532,9 @@ .replace(html_reg_findGlobalLinks, html_reg_findGlobalLinks_replace) .replace(html_reg_findGeneralLinks, lowerCaseGeneralLinks) .replace(html_reg_findClassLinks, modifyClassLinks) + .replace(html_reg_typeReturnSize, html_reg_typeReturnSize_replace) + .replace(html_reg_code, html_reg_code_replace) + .replace(html_reg_pretty, html_reg_pretty_replace) .replace(html_reg_findByMethod, ""); // Fix for namespace and object links