From 22065ad611d38612e0883a4d310087dccb7cab2b Mon Sep 17 00:00:00 2001 From: milad nazeri Date: Sun, 6 May 2018 21:39:37 -0700 Subject: [PATCH] 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