mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-11 20:53:51 +02:00
gravprep redo for link fixes
This commit is contained in:
parent
46efb2b868
commit
0ccb233724
3 changed files with 154 additions and 2253 deletions
File diff suppressed because it is too large
Load diff
2
tools/jsdoc/grav.sh
Executable file
2
tools/jsdoc/grav.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
!#/bin/bash
|
||||
node gravPrep true "/Users/milad/ROLC/Reference/Programming/R_VR/Hifi/hifi-docs-grav/user/themes/learn2/" "/Users/milad/ROLC/Reference/Programming/R_VR/Hifi/hifi-docs-grav-content"
|
|
@ -10,8 +10,8 @@
|
|||
// Arg Vars
|
||||
const copyLocal = process.argv[2];
|
||||
console.log("copyLocal:", copyLocal);
|
||||
let targetTemplateDirectory = ''
|
||||
let targetMDDirectory = ''
|
||||
let targetTemplateDirectory = '';
|
||||
let targetMDDirectory = '';
|
||||
if (copyLocal){
|
||||
targetTemplateDirectory = process.argv[3];
|
||||
targetMDDirectory = process.argv[4];;
|
||||
|
@ -33,6 +33,9 @@
|
|||
// 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];
|
||||
|
||||
// Base Grouping Directories for MD files
|
||||
let baseMDDirectories = ["API-Reference", "Globals", "Namespaces", "Objects"];
|
||||
|
||||
// Maps for directory names
|
||||
let map_dir_md = {
|
||||
"API-Reference": dir_md,
|
||||
|
@ -43,6 +46,7 @@
|
|||
"Namespace": dir_md_namespaces,
|
||||
"Global": dir_md_globals
|
||||
}
|
||||
|
||||
// Map for Links
|
||||
let map_links = {
|
||||
"Global": "globals",
|
||||
|
@ -50,8 +54,12 @@
|
|||
"Class": "objects"
|
||||
}
|
||||
|
||||
// Base Grouping Directories for MD files
|
||||
let baseMDDirectories = ["API-Reference", "Globals", "Namespaces", "Objects"]
|
||||
// Mapping for GroupNames and Members
|
||||
let groupNameMemberMap = {
|
||||
"Objects": [],
|
||||
"Namespaces": [],
|
||||
"Globals": []
|
||||
}
|
||||
|
||||
// Html variables to be handle regex replacements
|
||||
const html_reg_static = /<span class="type-signature">\(static\)<\/span>/g
|
||||
|
@ -76,7 +84,7 @@
|
|||
const html_reg_returnSize_replace = '<h6>Returns:<\/h6>';
|
||||
const html_reg_findByName = '<h5 class="name"';
|
||||
const html_reg_findByTitle = '<h1>';
|
||||
const html_reg_findByMethod = `<h4 class="subsection-title">Methods</h4>`;
|
||||
const html_reg_findByMethod = /<h4 class="subsection-title"[\s\S]*?>Methods<\/h4>/g;
|
||||
const html_reg_containerOverview = `<div class="container-overview">`
|
||||
const html_reg_findByArticleOpen = `<article>`
|
||||
const html_reg_findByArticleClose = `</article>`
|
||||
|
@ -86,25 +94,21 @@
|
|||
const html_reg_fixLinkHashIssue = /(<a href=")(.*?)(\.)(.*?">)/g;
|
||||
const html_reg_fixLinkHashIssue_replace = "$1$2#$4"
|
||||
const html_reg_findLinks = /(<a href="[\s\S]+?<\/a>)/g;
|
||||
const html_reg_allNonHTML = /(<a href=")(?!http)([\s\S]+?)(">)/g;
|
||||
const html_reg_findLinksNoHashes = /(<a href=")([^#]+?)(">[\s\S]+?<\/a>)/g;
|
||||
const html_reg_findGlobalLinks = /(<a href=")(global)(#[\s\S]+?<\/a>)/g;
|
||||
const html_reg_findGlobalLinks_replace = "$1\/api-reference\/globals$3";
|
||||
// const html_reg_findGlobalLinks = /(<a href=")(global)(#[\s\S]+?<\/a>)/g;
|
||||
// const html_reg_findGlobalLinks_replace = "$1\/api-reference\/globals$3";
|
||||
const html_reg_findGeneralLinks = /(<a href=")([A-Z])([\s\S]*?)("[\s\S]*?<\/a>)/g;
|
||||
const html_reg_findClassLinks = /(<a href=")([\.|\w]+?)(#[\.|\w]+?)(">[\s\S]+?<\/a>)/g;
|
||||
const html_reg_pretty = /(<pre class="prettyprint">)([\s\S]*?)(<\/pre>)/g;
|
||||
const html_reg_pretty_replace = "<pre>$2<\/pre>";
|
||||
const html_reg_code = /(<code>)([\s\S]*?)(<\/code>)/g;
|
||||
const html_reg_code_replace = "$1$2$3";
|
||||
|
||||
// Mapping for GroupNames and Members
|
||||
let groupNameMemberMap = {
|
||||
"Objects": [],
|
||||
"Namespaces": [],
|
||||
"Globals": []
|
||||
}
|
||||
// const html_reg_code = /(<code>)([\s\S]*?)(<\/code>)/g;
|
||||
// const html_reg_code_replace = "$1$2$3";
|
||||
const html_reg_dlClassDetails = /<dl class="details"><\/dl>/g
|
||||
|
||||
// Procedural functions
|
||||
|
||||
// Helper Functions
|
||||
function isMultipleDots(content){
|
||||
let count = 0;
|
||||
let regEx = /\./g
|
||||
|
@ -117,56 +121,81 @@
|
|||
}
|
||||
}
|
||||
|
||||
function modifyClassLinks(match, p1,p2,p3,p4){
|
||||
let matchedp = [p2,p3].join("");
|
||||
if(!isMultipleDots(matchedp)){
|
||||
console.log("not multiple");
|
||||
console.log("matchedp:", matchedp)
|
||||
return match;
|
||||
// function modifyClassLinks(match, p1, p2, p3, p4){
|
||||
// let matchedp = [p2,p3].join("");
|
||||
// if(!isMultipleDots(matchedp)){
|
||||
// console.log("not multiple");
|
||||
// console.log("matchedp:", matchedp)
|
||||
// return match;
|
||||
// }
|
||||
// p2 = p2.split('.')[1].toLowerCase();
|
||||
// let newString = [p1,p2,p3,p4].join("");
|
||||
// // console.log("new String:", newString);
|
||||
// return newString;
|
||||
// }
|
||||
|
||||
function allLinksToLowerCase(match, p1, p2, p3){
|
||||
// split on id # and make sure only the preceding is lower case
|
||||
if (p2.indexOf("#") > -1){
|
||||
p2 = p2.split("#");
|
||||
p2 = [p2[0].toLowerCase(), "#", p2[1]].join("");
|
||||
} else {
|
||||
p2 = p2.toLowerCase();
|
||||
}
|
||||
p2 = p2.split('.')[1].toLowerCase();
|
||||
let newString = [p1,p2,p3,p4].join("");
|
||||
// console.log("new String:", newString);
|
||||
return newString;
|
||||
return [p1,p2,p3].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();
|
||||
function fixLinkGrouping(match, p1, p2, p3){
|
||||
if (p2.indexOf("#") > -1){
|
||||
split = p2.split("#");
|
||||
if (split[0] === "global"){
|
||||
return [p1,"/api-reference/", "globals", "#", split[1], p3].join("");
|
||||
}
|
||||
let group3 = linksNoHashes[i][3];
|
||||
let index = linksNoHashes[i][4];
|
||||
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 [p1,"/api-reference/", returnRightGroup(split[0]), "/", p2, p3].join("");
|
||||
} else {
|
||||
return [p1,"/api-reference/", returnRightGroup(p2), "/", p2, p3].join("");
|
||||
}
|
||||
return content;
|
||||
|
||||
}
|
||||
|
||||
// Create the actual MD file
|
||||
// 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}`;
|
||||
// // console.log("newString", newString);
|
||||
// content = [content.slice(0,index), newString, content.slice(index+linkLength)].join("");
|
||||
// }
|
||||
// return content;
|
||||
// }
|
||||
|
||||
|
||||
function returnRightGroup(methodToCheck){
|
||||
// console.log("methodToCheck", methodToCheck)
|
||||
for ( var key in groupNameMemberMap ){
|
||||
for (i = 0; i < groupNameMemberMap[key].length; i++ ){
|
||||
if (methodToCheck.toLowerCase() === groupNameMemberMap[key][i].toLowerCase()){
|
||||
|
@ -178,6 +207,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Create the actual MD file
|
||||
function createMD(title, directory, needsDir, isGlobal){
|
||||
let mdSource = makeMdSource(title);
|
||||
|
||||
|
@ -479,6 +509,7 @@
|
|||
// 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){
|
||||
|
@ -510,86 +541,86 @@
|
|||
let splitTitle = loadedHtml("title").text().split(": ");
|
||||
let groupName = splitTitle[1];
|
||||
let htmlTitle = splitTitle.pop();
|
||||
console.log("html title", htmlTitle)
|
||||
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, "")
|
||||
.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)
|
||||
let currentContent = mainDiv.html()
|
||||
.replace(html_reg_static,"") // Remove static from the file names
|
||||
.replace(html_reg_title,"") // Remove title
|
||||
.replace(html_reg_objectHeader,"") // Remove extra Object Header
|
||||
.replace(html_reg_htmlExt,"") // Remove the .html extension from all links
|
||||
// .replace(html_reg_typeDefinitonsTitle, "") // Remove Type Definitions Title to be remade later
|
||||
// .replace(html_reg_findByMethod, "") //Remove Method title to be remade later
|
||||
.replace(html_reg_dlClassDetails, "") // Remove unneccsary dlClassDetails Tag
|
||||
.replace(html_reg_allNonHTML, allLinksToLowerCase) // Turn all links into lowercase before ID tags
|
||||
.replace(html_reg_allNonHTML, fixLinkGrouping) // Make sure links refer to correct grouping
|
||||
.replace(html_reg_subsectionEdit, html_reg_subsectionEdit_replace) // Make all subsection titles the same size
|
||||
.replace(html_reg_propertiesHeaderEdit, html_reg_propertiesHeaderEdit_Replace) // Remove : from Properties
|
||||
.replace(html_reg_typeEdit, html_reg_typeEdit_replace) // Put type on the same line
|
||||
.replace(html_reg_returnSize, html_reg_returnSize_replace) // make return size h6 instead of h5
|
||||
.replace(html_reg_methodSize, html_reg_methodSize_replace) // make method size into h5
|
||||
.replace(html_reg_pretty, html_reg_pretty_replace)
|
||||
.replace(html_reg_findByMethod, "");
|
||||
// .replace(html_reg_brRemove, "") // Remove extra Brs
|
||||
// .replace(html_reg_typeDefSize, html_reg_typeDefSize_replace) // make type def header into h5
|
||||
// .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)
|
||||
|
||||
// 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')}`);
|
||||
}
|
||||
// currentContent = contentReplace(currentContent, htmlTitle);
|
||||
|
||||
// Further HTML Manipulation
|
||||
// Split HTML by Each named entry
|
||||
let contentSplitArray = splitBy(mainDivRegexed, html_reg_findByName, html_reg_findByArticleClose);
|
||||
let contentSplitArray = splitBy(currentContent, html_reg_findByName, html_reg_findByArticleClose);
|
||||
|
||||
// Create a reference to the current content after split and the split functions
|
||||
let currentContent = contentSplitArray[0];
|
||||
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 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 = [];
|
||||
|
||||
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
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
// 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
|
||||
// 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) {
|
||||
// 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);
|
||||
if (groupName === "Global"){
|
||||
currentContent = append(currentContent, html_reg_findByTitle, classTOC);
|
||||
} else {
|
||||
currentContent = append(currentContent, html_reg_firstTableClose, classTOC);
|
||||
}
|
||||
// let classTOC = makeClassTOC(arrayToPassToClassToc);
|
||||
// if (groupName === "Global"){
|
||||
// currentContent = append(currentContent, html_reg_findByTitle, classTOC);
|
||||
// } else {
|
||||
// currentContent = append(currentContent, html_reg_firstTableClose, classTOC);
|
||||
// }
|
||||
|
||||
// Final Pretty Content
|
||||
currentContent = htmlclean(currentContent);
|
||||
|
|
Loading…
Reference in a new issue