mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:24:36 +02:00
Links fixed
This commit is contained in:
parent
b32039f895
commit
22065ad611
7 changed files with 2144 additions and 447 deletions
|
@ -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){
|
||||
|
|
1484
tools/jsdoc/Links-Untouched
Normal file
1484
tools/jsdoc/Links-Untouched
Normal file
File diff suppressed because it is too large
Load diff
0
tools/jsdoc/badLinks
Normal file
0
tools/jsdoc/badLinks
Normal file
|
@ -72,6 +72,8 @@
|
|||
const html_reg_findByArticleClose = `</article>`
|
||||
const html_reg_signalTitle = `<h4 class="subsection-title">Signals</h4>`;
|
||||
const html_reg_typeDefinitonsTitle = `<h4 class="subsection-title">Type Definitions</h4>`;
|
||||
const html_reg_firstTableClose = `</table>`;
|
||||
|
||||
|
||||
// Mapping for GroupNames and Members
|
||||
let groupNameMemberMap = {
|
||||
|
@ -252,12 +254,19 @@
|
|||
|
||||
// Handle Class TOCS
|
||||
function makeClassTOC(group){
|
||||
console.log("group", group)
|
||||
let linkArray = []
|
||||
group.forEach( item => {
|
||||
linkArray.push(`<div><h5>${item.type}</h5></div>`)
|
||||
item.array.forEach( link => {
|
||||
linkArray.push(`<div><a href="#.${link.slice(1)}">${link.slice(1)}</a></div>`)
|
||||
if ( link.indexOf('.') > -1 ){
|
||||
linkArray.push(`<div><a href="#.${link}">${link.slice(1)}</a></div>`);
|
||||
} else {
|
||||
linkArray.push(`<div><a href="#${link}">${link}</a></div>`);
|
||||
}
|
||||
|
||||
})
|
||||
linkArray.push("<br>");
|
||||
})
|
||||
return linkArray.join("\n");
|
||||
}
|
||||
|
@ -280,8 +289,7 @@
|
|||
}
|
||||
|
||||
// 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: "<code>", distance: "3"}
|
||||
// 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 = [];
|
||||
|
@ -308,27 +316,34 @@
|
|||
return [content, foundArray];
|
||||
}
|
||||
|
||||
// Split the signals, methods, and typeDefs [Might make this more generic]
|
||||
// Split the signals and methods [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];
|
||||
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(method);
|
||||
// console.log("Found signal")
|
||||
signalArray.push(content);
|
||||
} else if (firstLine.indexOf("span") > -1) {
|
||||
// console.log("Found method")
|
||||
methodArray.push(method);
|
||||
if (content.indexOf("Available") > -1){
|
||||
console.log("found Available");
|
||||
description = content;
|
||||
} else {
|
||||
methodArray.push(content);
|
||||
}
|
||||
} else {
|
||||
// console.log("Found typeDef")
|
||||
|
||||
typeDefArray.push(method);
|
||||
if(firstLine.trim() !== ""){
|
||||
typeDefArray.push(content);
|
||||
}
|
||||
}
|
||||
})
|
||||
return [methodArray, signalArray, typeDefArray];
|
||||
return [methodArray, signalArray, typeDefArray, description];
|
||||
}
|
||||
|
||||
// Helper to append
|
||||
|
@ -375,7 +390,7 @@
|
|||
})
|
||||
|
||||
// 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);
|
||||
|
@ -402,45 +417,58 @@
|
|||
.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_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 splitMethodsSignalsAndTypeDefs = splitMethodsSignalsAndTypeDefs(contentSplitArray[1]);
|
||||
let splitMethods = splitMethodsSignalsAndTypeDefs[0];
|
||||
let splitSignals = splitMethodsSignalsAndTypeDefs[1];
|
||||
let splitTypeDefintions = splitMethodsSignalsAndTypeDefs[2];
|
||||
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 classTOC = makeClassTOC([
|
||||
{type: "Methods", array: splitMethodIDS},
|
||||
{type: "Signals", array: splitSignalIDS},
|
||||
{type: "Type Definitions", array: splitTypeDefinitionIDS}
|
||||
]);
|
||||
let arrayToPassToClassToc = [];
|
||||
|
||||
// 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 (!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);
|
||||
|
||||
// Final Pretty Content
|
||||
currentContent = htmlclean(currentContent);
|
||||
currentContent = pretty(currentContent);
|
||||
|
||||
// Handle Unique Categories
|
||||
switch(groupName){
|
||||
case "Namespace":
|
||||
|
@ -463,24 +491,3 @@ 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);
|
||||
}
|
||||
|
|
|
@ -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.+?\>.+?\<\/h1\>/g;
|
||||
const html_reg_htmlExt = /\.html/g;
|
||||
const html_reg_objectHeader = /<header>[\s\S]+?<\/header>/;
|
||||
const html_reg_objectSpanNew = /<h4 class="name"[\s\S]+?<\/span><\/h4>/;
|
||||
const html_reg_objectSpanNew = /<h5 class="name"[\s\S]+?<\/span><\/h5>/;
|
||||
const html_reg_brRemove = /<br>[\s\S]+?<br>/;
|
||||
const html_reg_subsectionEdit = /(<h. class="subsection-title">)([\s\S]*?)(<\/h.>)/g;
|
||||
const html_reg_subsectionEdit_replace = '<h4 class="subsection-title">$2</h4>';
|
||||
|
@ -69,10 +75,20 @@
|
|||
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_containerOverview = `<div class="container-overview">`
|
||||
const html_reg_findByArticleOpen = `<article>`
|
||||
const html_reg_findByArticleClose = `</article>`
|
||||
const html_reg_signalTitle = `<h4 class="subsection-title">Signals</h4>`;
|
||||
const html_reg_typeDefinitonsTitle = `<h4 class="subsection-title">Type Definitions</h4>`;
|
||||
const html_reg_firstTableClose = `</table>`;
|
||||
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_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_findGeneralLinks = /(<a href=")([A-Z])([\s\S]*?)("[\s\S]*?<\/a>)/g;
|
||||
const html_reg_findClassLinks = /(<a href=")([\.|\w]+?)(#[\.|\w]+?)(">[\s\S]+?<\/a>)/g;
|
||||
|
||||
|
||||
// Mapping for GroupNames and Members
|
||||
|
@ -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(`<div><h5>${item.type}</h5></div>`)
|
||||
item.array.forEach( link => {
|
||||
linkArray.push(`<div><a href="#.${link.slice(1)}">${link.slice(1)}</a></div>`)
|
||||
if ( link.indexOf('.') > -1 ){
|
||||
linkArray.push(`<div><a href="#${link}">${link.slice(1)}</a></div>`);
|
||||
} else {
|
||||
linkArray.push(`<div><a href="#${link}">${link}</a></div>`);
|
||||
|
||||
}
|
||||
})
|
||||
linkArray.push("<br>");
|
||||
})
|
||||
|
@ -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,7 +461,29 @@
|
|||
})
|
||||
|
||||
// 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") {
|
||||
|
@ -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_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);
|
||||
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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
0
tools/jsdoc/warningLog
Normal file
0
tools/jsdoc/warningLog
Normal file
Loading…
Reference in a new issue