[ADF-3265] Updated index script to remove brief desc links (#3520)

This commit is contained in:
Andy Stark
2018-06-22 21:47:27 +01:00
committed by Eugenio Romano
parent 5a3ce3d299
commit a746a3e3d4
6 changed files with 84 additions and 79 deletions

View File

@@ -75,6 +75,20 @@ var MDNav = /** @class */ (function () {
return h.type === "html" && test(h);
}, index);
};
MDNav.prototype.link = function (test, index) {
if (test === void 0) { test = function () { return true; }; }
if (index === void 0) { index = 0; }
return this.find(function (h) {
return h.type === "link" && test(h);
}, index);
};
MDNav.prototype.links = function (test, index) {
if (test === void 0) { test = function () { return true; }; }
if (index === void 0) { index = 0; }
return this.findAll(function (h) {
return h.type === "link" && test(h);
}, index);
};
MDNav.prototype.list = function (test, index) {
if (test === void 0) { test = function () { return true; }; }
if (index === void 0) { index = 0; }

View File

@@ -78,7 +78,18 @@ export class MDNav {
}, index);
}
link(test: (element: any) => boolean = () => true, index: number = 0): MDNav {
return this.find((h) => {
return h.type === "link" && test(h);
}, index);
}
links(test: (element: any) => boolean = () => true, index: number = 0): MDNav[] {
return this.findAll((h) => {
return h.type === "link" && test(h);
}, index);
}
list(test: (element: any) => boolean = () => true, index: number = 0): MDNav {
return this.find((h) => {
return h.type === "list" && test(h);

View File

@@ -9,6 +9,7 @@ var yaml = require("js-yaml");
var unist = require("../unistHelpers");
var ngHelpers = require("../ngHelpers");
var searchLibraryRecursive = require("../libsearch");
var mdNav = require("../mdNav");
module.exports = {
"initPhase": initPhase,
@@ -31,12 +32,6 @@ var maxBriefDescLength = 180;
var adfLibNames = ["core", "content-services", "insights", "process-services"];
/*
var deprecatedIconURL = "docassets/images/DeprecatedIcon.png";
var experimentalIconURL = "docassets/images/ExperimentalIcon.png";
var internalIconURL = "docassets/images/InternalIcon.png"
*/
var statusIcons;
function initPhase(aggData) {
@@ -47,8 +42,6 @@ function initPhase(aggData) {
aggData.mdFileStatus = [];
aggData.mdFilePath = [];
searchLibraryRecursive(aggData.srcData, path.resolve(rootFolder));
//console.log(JSON.stringify(aggData.srcData));
}
@@ -94,7 +87,6 @@ function readPhase(tree, pathname, aggData) {
function aggPhase(aggData) {
var sections = prepareIndexSections(aggData);
//console.log(JSON.stringify(sections));
var indexFileText = fs.readFileSync(indexMdFilePath, "utf8");
var indexFileTree = remark().parse(indexFileText);
@@ -112,7 +104,7 @@ function aggPhase(aggData) {
return md;
});
md = makeLibSectionMD(libSection, true);
var md = makeLibSectionMD(libSection, true);
var subIndexFilePath = path.resolve(docsFolderPath, libName, "README.md");
var subIndexText = fs.readFileSync(subIndexFilePath, "utf8");
@@ -257,7 +249,6 @@ function buildMDDocumentedTable(docItems, forSubFolder) {
}
return rows;
//return unist.makeTable([null, null, null, null], rows);
}
@@ -271,7 +262,6 @@ function buildMDUndocumentedTable(docItems, forSubFolder) {
}
return rows;
//return unist.makeTable([null, null, null, null], rows);
}
@@ -293,38 +283,18 @@ function makeMDDocumentedTableRow(docItem, forSubFolder) {
var srcFileLink = unist.makeLink(unist.makeText("Source"), srcPath);
var desc = docItem.briefDesc;
removeBriefDescLinks(desc);
var linkCellItems = [mdFileLink];
/*
var finalDepIconURL = deprecatedIconURL;
var finalExIconURL = experimentalIconURL;
var finalIntIconURL = internalIconURL;
if (forSubFolder) {
finalDepIconURL = "../" + finalDepIconURL;
finalExIconURL = "../" + finalExIconURL;
}
*/
var pathPrefix = "";
if (forSubFolder) {
pathPrefix = "../";
}
if (docItem.status) {
/*
if (docItem.status === "Deprecated") {
linkCellItems.push(unist.makeText(" "));
linkCellItems.push(unist.makeImage(finalDepIconURL, "Deprecated"));
} else if (docItem.status === "Experimental") {
linkCellItems.push(unist.makeText(" "));
linkCellItems.push(unist.makeImage(finalExIconURL, "Experimental"));
} else if (docItem.status === "Internal") {
linkCellItems.push(unist.makeText(" "));
linkCellItems.push(unist.makeImage(finalIntIconURL, "Internal"));
}
*/
if (statusIcons[docItem.status]) {
linkCellItems.push(unist.makeText(" "));
@@ -386,12 +356,10 @@ function makeLibSectionMD(libSection, forSubFolder){
];
if (classSection.documented.length > 0) {
//md.push(buildMDDocumentedSection(classSection.documented));
tableRows = tableRows.concat(buildMDDocumentedTable(classSection.documented, forSubFolder));
}
if (classSection.undocumented.length > 0) {
// md.push(buildMDUndocumentedSection(classSection.undocumented));
tableRows = tableRows.concat(buildMDUndocumentedTable(classSection.undocumented, forSubFolder));
}
@@ -423,3 +391,15 @@ function buildGuideSection(guideJsonFilename, forSubFolder) {
return unist.makeListUnordered(listItems);
}
function removeBriefDescLinks(desc) {
var nav = new mdNav.MDNav(desc);
var links = nav.links();
links.forEach(link => {
link.item.type = "text";
link.item.value = link.item.children[0].value;
});
}