[ADF-2463] Added index pages to doc subfolders (#3091)

This commit is contained in:
Andy Stark
2018-03-19 14:37:08 +00:00
committed by Eugenio Romano
parent 6427139b21
commit 9d578bbd55
6 changed files with 365 additions and 61 deletions

View File

@@ -100,16 +100,31 @@ function aggPhase(aggData) {
var libName = adfLibNames[l];
var libSection = sections[libName];
var md = makeLibSectionMD(libSection);
var md = makeLibSectionMD(libSection, false);
zone(indexFileTree, libName, (startComment, oldSection, endComment) => {
md.unshift(startComment);
md.push(endComment);
return md;
});
md = makeLibSectionMD(libSection, true);
var subIndexFilePath = path.resolve(docsFolderPath, libName, "README.md");
var subIndexText = fs.readFileSync(subIndexFilePath, "utf8");
var subIndexTree = remark().parse(subIndexText);
zone(subIndexTree, libName, (startComment, oldSection, endComment) => {
md.unshift(startComment);
md.push(endComment);
return md;
});
subIndexText = remark().data("settings", {paddedTable: false}).stringify(subIndexTree);
fs.writeFileSync(subIndexFilePath, subIndexText);
}
var guideSection = buildGuideSection(guideSummaryFileName);
var guideSection = buildGuideSection(guideSummaryFileName, false);
zone(indexFileTree, "guide", (startComment, oldSection, endComment) => {
return [
@@ -118,8 +133,23 @@ function aggPhase(aggData) {
});
fs.writeFileSync(path.resolve("..", "docs", "README.md"), remark().data("settings", {paddedTable: false}).stringify(indexFileTree));
guideSection = buildGuideSection(guideSummaryFileName, true);
subIndexFilePath = path.resolve(docsFolderPath, "user-guide", "README.md");
subIndexText = fs.readFileSync(subIndexFilePath, "utf8");
subIndexTree = remark().parse(subIndexText);
zone(subIndexTree, "guide", (startComment, oldSection, endComment) => {
return [
startComment, guideSection, endComment
]
});
subIndexText = remark().data("settings", {paddedTable: false}).stringify(subIndexTree);
fs.writeFileSync(subIndexFilePath, subIndexText);
//fs.writeFileSync(indexMdFilePath, remark().stringify(indexFileTree));
//fs.writeFileSync(path.resolve(".", "testJson.md"), JSON.stringify(indexFileTree));
}
@@ -212,35 +242,13 @@ function initEmptySections() {
}
function buildMDDocumentedSection(docItems) {
var listItems = [];
for (var i = 0; i < docItems.length; i++) {
listItems.push(makeMDDocumentedListItem(docItems[i]));
}
return unist.makeListUnordered(listItems);
}
function buildMDUndocumentedSection(docItems) {
var listItems = [];
for (var i = 0; i < docItems.length; i++) {
listItems.push(makeMDUndocumentedListItem(docItems[i]));
}
return unist.makeListUnordered(listItems);
}
function buildMDDocumentedTable(docItems) {
function buildMDDocumentedTable(docItems, forSubFolder) {
var rows = [
];
for (var i = 0; i < docItems.length; i++) {
rows.push(makeMDDocumentedTableRow(docItems[i]));
rows.push(makeMDDocumentedTableRow(docItems[i], forSubFolder));
}
return rows;
@@ -248,13 +256,13 @@ function buildMDDocumentedTable(docItems) {
}
function buildMDUndocumentedTable(docItems) {
function buildMDUndocumentedTable(docItems, forSubFolder) {
var rows = [
];
for (var i = 0; i < docItems.length; i++) {
rows.push(makeMDUndocumentedTableRow(docItems[i]));
rows.push(makeMDUndocumentedTableRow(docItems[i], forSubFolder));
}
return rows;
@@ -262,45 +270,41 @@ function buildMDUndocumentedTable(docItems) {
}
function makeMDDocumentedListItem(docItem) {
var mdFileLink = unist.makeLink(unist.makeText(docItem.displayName), docItem.mdName);
var srcFileLink = unist.makeLink(unist.makeText("Source"), "../lib/" + docItem.srcPath);
var desc = docItem.briefDesc;
function makeMDDocumentedTableRow(docItem, forSubFolder) {
var mdPath = docItem.mdPath;
var para = unist.makeParagraph([
mdFileLink, unist.makeText(" ("), srcFileLink, unist.makeText(") "), desc
]);
if (forSubFolder) {
mdPath = path.basename(mdPath);
}
return unist.makeListItem(para);
}
var mdFileLink = unist.makeLink(unist.makeText(docItem.displayName), mdPath);
var srcPath = "../lib/" + docItem.srcPath;
function makeMDUndocumentedListItem(docItem) {
var itemName = unist.makeText(docItem.displayName);
var srcFileLink = unist.makeLink(unist.makeText("Source"), "../lib/" + docItem.srcPath);
if (forSubFolder) {
srcPath = "../" + srcPath;
}
var para = unist.makeParagraph([
unist.makeText("* "), itemName, unist.makeText(" ("), srcFileLink, unist.makeText(")")
]);
return unist.makeListItem(para);
}
function makeMDDocumentedTableRow(docItem) {
var mdFileLink = unist.makeLink(unist.makeText(docItem.displayName), docItem.mdPath);
var srcFileLink = unist.makeLink(unist.makeText("Source"), "../lib/" + docItem.srcPath);
var srcFileLink = unist.makeLink(unist.makeText("Source"), srcPath);
var desc = docItem.briefDesc;
var linkCellItems = [mdFileLink];
var finalDepIconURL = deprecatedIconURL;
var finalExIconURL = experimentalIconURL;
if (forSubFolder) {
finalDepIconURL = "../" + finalDepIconURL;
finalExIconURL = "../" + finalExIconURL;
}
if (docItem.status) {
if (docItem.status === "Deprecated") {
linkCellItems.push(unist.makeText(" "));
linkCellItems.push(unist.makeImage(deprecatedIconURL, "Deprecated"));
linkCellItems.push(unist.makeImage(finalDepIconURL, "Deprecated"));
} else if (docItem.status === "Experimental") {
linkCellItems.push(unist.makeText(" "));
linkCellItems.push(unist.makeImage(experimentalIconURL, "Experimental"));
linkCellItems.push(unist.makeImage(finalExIconURL, "Experimental"));
}
}
@@ -312,9 +316,15 @@ function makeMDDocumentedTableRow(docItem) {
}
function makeMDUndocumentedTableRow(docItem) {
function makeMDUndocumentedTableRow(docItem, forSubFolder) {
var itemName = unist.makeText(docItem.displayName);
var srcFileLink = unist.makeLink(unist.makeText("Source"), "../lib/" + docItem.srcPath);
var srcPath = "../lib/" + docItem.srcPath;
if (forSubFolder) {
srcPath = "../" + srcPath;
}
var srcFileLink = unist.makeLink(unist.makeText("Source"), srcPath);
return unist.makeTableRow([
unist.makeTableCell([unist.makeEmphasis([itemName])]),
@@ -324,7 +334,7 @@ function makeMDUndocumentedTableRow(docItem) {
}
function makeLibSectionMD(libSection){
function makeLibSectionMD(libSection, forSubFolder){
var md = [];
var libClassTypes = Object.keys(libSection);
@@ -353,12 +363,12 @@ function makeLibSectionMD(libSection){
if (classSection.documented.length > 0) {
//md.push(buildMDDocumentedSection(classSection.documented));
tableRows = tableRows.concat(buildMDDocumentedTable(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));
tableRows = tableRows.concat(buildMDUndocumentedTable(classSection.undocumented, forSubFolder));
}
md.push(unist.makeTable([null, null, null, null], tableRows));
@@ -369,13 +379,19 @@ function makeLibSectionMD(libSection){
}
function buildGuideSection(guideJsonFilename) {
function buildGuideSection(guideJsonFilename, forSubFolder) {
var summary = JSON.parse(fs.readFileSync(guideJsonFilename, "utf8"));
var listItems = [];
for (var i = 0; i < summary.length; i++) {
var link = unist.makeLink(unist.makeText(summary[i].title), guideFolderName + "/" + summary[i].file);
var filePath = summary[i].file;
if (!forSubFolder) {
filePath = guideFolderName + "/" + filePath;
}
var link = unist.makeLink(unist.makeText(summary[i].title), filePath);
listItems.push(unist.makeListItem(link));
}