mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-11 20:53:51 +02:00
fixed undefined errors
This commit is contained in:
parent
22065ad611
commit
6cb4901bae
4 changed files with 710 additions and 50 deletions
|
@ -1,18 +1,20 @@
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var request = require('request');
|
||||
var axios = require('axios');
|
||||
|
||||
var badLinks = [];
|
||||
var baseLink = `http://localhost:8000/api-reference/`;
|
||||
// var baseLink = `http://localhost:8000/api-reference/`;
|
||||
var baseLink = `https://docs.highfidelity.com`;
|
||||
var linkList = fs.readFileSync(__dirname + '/Links-Untouched','utf8').split('\n');
|
||||
console.log("link list", linkList);
|
||||
// console.log("link list", linkList);
|
||||
// console.log("filtered List", JSON.stringify(filteredList));
|
||||
var linkHash = {};
|
||||
|
||||
var currentGroup;
|
||||
linkList.forEach( link => {
|
||||
link = link.trim()
|
||||
console.log("link", link)
|
||||
// console.log("link", link)
|
||||
if (link.slice(-1) === ':'){
|
||||
currentGroup = link.slice(0, link.length-1);
|
||||
// console.log("current Group: ", currentGroup);
|
||||
|
@ -35,37 +37,39 @@ var keys = Object.keys(linkHash);
|
|||
keys.forEach( key => {
|
||||
for (var linkKey in linkHash[key]){
|
||||
var link = linkHash[key][linkKey];
|
||||
console.log("link", link);
|
||||
// console.log("link", link);
|
||||
var extractLink = link.split(`"`)[1];
|
||||
console.log("extractLink", extractLink)
|
||||
if (!extractLink.indexOf('http') > -1){
|
||||
extractLink = baseLink + extractLink;
|
||||
}
|
||||
console.log("about to make a request for", extractLink)
|
||||
setTimeout(function(){
|
||||
request.get(extractLink)
|
||||
.on('response', response => {
|
||||
if (response.statusCode(404)){
|
||||
console.log("found bad link")
|
||||
console.log(JSON.stringify({file: key, link: extractLink}))
|
||||
|
||||
// badLinks.push({file: key, link: link})
|
||||
stream.write(JSON.stringify({file: key, link: extractLink}));
|
||||
}
|
||||
}, 4000)
|
||||
})
|
||||
|
||||
}
|
||||
if (!(extractLink.indexOf(':') > -1)){
|
||||
console.log(" adding link")
|
||||
extractLink = baseLink + extractLink;
|
||||
} else {
|
||||
// console.log("found https")
|
||||
}
|
||||
console.log("extractLink", extractLink)
|
||||
|
||||
})
|
||||
// console.log("about to make a request for", extractLink)
|
||||
axios.get(extractLink)
|
||||
.then( response => {
|
||||
console.log("response")
|
||||
if (response.status === 404){
|
||||
console.log("found bad link")
|
||||
// console.log(JSON.stringify({file: key, link: extractLink}))
|
||||
// stream.write(JSON.stringify({file: key, link: extractLink}));
|
||||
}
|
||||
})
|
||||
.catch( error => {
|
||||
console.log("error")
|
||||
// console.log(error);
|
||||
// if (error.response.status === 404){
|
||||
// console.log("found bad link")
|
||||
// console.log(JSON.stringify({file: key, link: extractLink}))
|
||||
// stream.write(JSON.stringify({file: key, link: extractLink}));
|
||||
// }
|
||||
})
|
||||
}
|
||||
})
|
||||
stream.end();
|
||||
// */
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function endsWith(path, exts) {
|
||||
var result = false;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -115,10 +115,14 @@
|
|||
function modifyClassLinks(match, p1,p2,p3,p4){
|
||||
let matchedp = [p2,p3].join("");
|
||||
if(!isMultipleDots(matchedp)){
|
||||
return;
|
||||
console.log("not multiple");
|
||||
console.log("matchedp:", matchedp)
|
||||
return match;
|
||||
}
|
||||
p2 = p2.split('.')[1].toLowerCase();
|
||||
return [p1,p2,p3,p4].join("");
|
||||
let newString = [p1,p2,p3,p4].join("");
|
||||
// console.log("new String:", newString);
|
||||
return newString;
|
||||
}
|
||||
|
||||
function lowerCaseGeneralLinks(match, p1, p2, p3, p4){
|
||||
|
@ -136,7 +140,7 @@
|
|||
}
|
||||
if (!linksNoHashes){
|
||||
return content;
|
||||
}
|
||||
}
|
||||
for(var i = linksNoHashes.length-1; i > -1; i--){
|
||||
if (linksNoHashes[i][0].indexOf("http") > -1){
|
||||
continue;
|
||||
|
@ -149,7 +153,8 @@
|
|||
}
|
||||
let group3 = linksNoHashes[i][3];
|
||||
let index = linksNoHashes[i][4];
|
||||
let newString = `${group1}/api-reference/${returnRightGroup(group2)}/${group2.toLowerCase()}${group3}`;
|
||||
let newString = `${group1}/api-reference/${returnRightGroup(group2)}/${group2.toLowerCase()}${group3}`;
|
||||
// console.log("newString", newString);
|
||||
content = [content.slice(0,index), newString, content.slice(index+linkLength)].join("");
|
||||
}
|
||||
return content;
|
||||
|
@ -161,6 +166,8 @@
|
|||
for (i = 0; i < groupNameMemberMap[key].length; i++ ){
|
||||
if (methodToCheck.toLowerCase() === groupNameMemberMap[key][i].toLowerCase()){
|
||||
return key.toLowerCase();
|
||||
} else {
|
||||
// console.log("Couldn't find group: ", methodToCheck);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "hifiJSDoc",
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"cheerio": "^1.0.0-rc.2",
|
||||
"dedent-js": "^1.0.1",
|
||||
"htmlclean": "^3.0.8",
|
||||
|
|
Loading…
Reference in a new issue