[ADF-2334] Added status icons and version index based on metadata (#2987)

* [ADF-2334] Added status icons to index page

* [ADF-2334] Improved status icons

* [ADF-2334] Added version index page

* [ADF-2334] Fixed bad anchors in version index
This commit is contained in:
Andy Stark
2018-02-23 09:35:16 +00:00
committed by Eugenio Romano
parent c915a79342
commit ad3dbd4d0b
8 changed files with 369 additions and 40 deletions

View File

@@ -4,6 +4,7 @@ var path = require("path");
var remark = require("remark");
var stringify = require("remark-stringify");
var zone = require("mdast-zone");
var yaml = require("js-yaml");
var unist = require("../unistHelpers");
var ngHelpers = require("../ngHelpers");
@@ -29,11 +30,15 @@ var maxBriefDescLength = 180;
var adfLibNames = ["core", "content-services", "insights", "process-services"];
var deprecatedIconURL = "docassets/images/DeprecatedIcon.png";
var experimentalIconURL = "docassets/images/ExperimentalIcon.png";
function initPhase(aggData) {
aggData.stoplist = makeStoplist(undocStoplistFileName);
aggData.srcData = {};
aggData.mdFileDesc = [];
aggData.mdFileStatus = [];
searchLibraryRecursive(aggData.srcData, path.resolve(rootFolder));
@@ -49,8 +54,12 @@ function readPhase(tree, pathname, aggData) {
var s;
var briefDesc;
for (
if (tree.children[0].type == "yaml")
s = 1;
else
s = 0;
for (;
(s < tree.children.length) && !unist.isParagraph(tree.children[s]);
s++
);
@@ -60,6 +69,17 @@ function readPhase(tree, pathname, aggData) {
}
aggData.mdFileDesc[itemName] = briefDesc;
if (tree.children[0].type == "yaml") {
var metadata = yaml.load(tree.children[0].value);
var status = metadata["Status"];
if (status) {
var compName = path.basename(pathname, ".md");
aggData.mdFileStatus[compName] = status;
}
}
}
function aggPhase(aggData) {
@@ -165,12 +185,18 @@ function prepareIndexSections(aggData) {
var displayName = ngHelpers.ngNameToDisplayName(itemName);
var status = "";
if (aggData.mdFileStatus[itemName])
status = aggData.mdFileStatus[itemName];
if (briefDesc) {
sections[libName][srcData.type].documented.push({
"displayName": displayName,
"mdName": itemName + ".md",
"srcPath": srcData.path,
"briefDesc": briefDesc
"briefDesc": briefDesc,
"status": status
});
} else if (!rejectItemViaStoplist(aggData.stoplist, itemName)) {
sections[libName][srcData.type].undocumented.push({
@@ -283,8 +309,20 @@ function makeMDDocumentedTableRow(docItem) {
var srcFileLink = unist.makeLink(unist.makeText("Source"), "../lib/" + docItem.srcPath);
var desc = docItem.briefDesc;
var linkCellItems = [mdFileLink];
if (docItem.status) {
if (docItem.status === "Deprecated") {
linkCellItems.push(unist.makeText(" "));
linkCellItems.push(unist.makeImage(deprecatedIconURL, "Deprecated"));
} else if (docItem.status === "Experimental") {
linkCellItems.push(unist.makeText(" "));
linkCellItems.push(unist.makeImage(experimentalIconURL, "Experimental"));
}
}
return unist.makeTableRow([
unist.makeTableCell([mdFileLink]),
unist.makeTableCell(linkCellItems),
unist.makeTableCell([desc]),
unist.makeTableCell([srcFileLink])
]);