[ADF-3792] Added metadata to README files (#4034)

* [ADF-3792] Added title and publishing metadata to README files

* [ADF-3792] Fixed index tool bugs and rebuilt index pages
This commit is contained in:
Andy Stark
2018-11-29 14:56:07 +00:00
committed by Eugenio Romano
parent 2f0f33643b
commit ca5543c48d
14 changed files with 146 additions and 118 deletions

View File

@@ -3,6 +3,7 @@ var path = require("path");
var remark = require("remark");
var stringify = require("remark-stringify");
var frontMatter = require("remark-frontmatter");
var zone = require("mdast-zone");
var yaml = require("js-yaml");
@@ -103,7 +104,7 @@ function aggPhase(aggData) {
var sections = prepareIndexSections(aggData);
var indexFileText = fs.readFileSync(indexMdFilePath, "utf8");
var indexFileTree = remark().parse(indexFileText);
var indexFileTree = remark().use(frontMatter, ["yaml"]).parse(indexFileText);
for (var l = 0; l < adfLibNames.length; l++) {
@@ -122,7 +123,7 @@ function aggPhase(aggData) {
var subIndexFilePath = path.resolve(docsFolderPath, libName, "README.md");
var subIndexText = fs.readFileSync(subIndexFilePath, "utf8");
var subIndexTree = remark().parse(subIndexText);
var subIndexTree = remark().use(frontMatter, ["yaml"]).parse(subIndexText);
zone(subIndexTree, libName, (startComment, oldSection, endComment) => {
md.unshift(startComment);
@@ -130,7 +131,7 @@ function aggPhase(aggData) {
return md;
});
subIndexText = remark().data("settings", {paddedTable: false}).stringify(subIndexTree);
subIndexText = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false}).stringify(subIndexTree);
fs.writeFileSync(subIndexFilePath, subIndexText);
}
@@ -142,13 +143,13 @@ function aggPhase(aggData) {
]
});
fs.writeFileSync(path.resolve("docs", "README.md"), remark().data("settings", {paddedTable: false}).stringify(indexFileTree));
fs.writeFileSync(path.resolve("docs", "README.md"), remark().use(frontMatter, ["yaml"]).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);
subIndexTree = remark().use(frontMatter, ["yaml"]).parse(subIndexText);
zone(subIndexTree, "guide", (startComment, oldSection, endComment) => {
return [
@@ -156,7 +157,7 @@ function aggPhase(aggData) {
]
});
subIndexText = remark().data("settings", {paddedTable: false}).stringify(subIndexTree);
subIndexText = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false}).stringify(subIndexTree);
fs.writeFileSync(subIndexFilePath, subIndexText);
//fs.writeFileSync(indexMdFilePath, remark().stringify(indexFileTree));

View File

@@ -22,10 +22,10 @@ function aggPhase(aggData) {
var template = ejs.compile(templateSource);
var mdText = template(indexDocData);
mdText = mdText.replace(/^ +\|/mg, "|");
var newSection = remark().data("settings", { paddedTable: false, gfm: false }).parse(mdText.trim()).children;
var newSection = remark().use(frontMatter, ["yaml"]).data("settings", { paddedTable: false, gfm: false }).parse(mdText.trim()).children;
var tutIndexFile = path.resolve(tutFolder, "README.md");
var tutIndexText = fs.readFileSync(tutIndexFile, "utf8");
var tutIndexMD = remark().data("settings", { paddedTable: false, gfm: false }).parse(tutIndexText);
var tutIndexMD = remark().use(frontMatter, ["yaml"]).data("settings", { paddedTable: false, gfm: false }).parse(tutIndexText);
replaceSection(tutIndexMD, "Tutorials", function (before, section, after) {
newSection.unshift(before);
newSection.push(after);

View File

@@ -30,11 +30,11 @@ function aggPhase(aggData) {
let mdText = template(indexDocData);
mdText = mdText.replace(/^ +\|/mg, "|");
let newSection = remark().data("settings", {paddedTable: false, gfm: false}).parse(mdText.trim()).children;
let newSection = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false, gfm: false}).parse(mdText.trim()).children;
let tutIndexFile = path.resolve(tutFolder, "README.md");
let tutIndexText = fs.readFileSync(tutIndexFile, "utf8");
let tutIndexMD = remark().data("settings", {paddedTable: false, gfm: false}).parse(tutIndexText);
let tutIndexMD = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false, gfm: false}).parse(tutIndexText);
replaceSection(tutIndexMD, "Tutorials", (before, section, after) => {
newSection.unshift(before);

View File

@@ -79,7 +79,7 @@ function getFileData(tree, pathname, aggData) {
function aggPhase(aggData) {
var histFileText = fs.readFileSync(histFilePath, "utf8");
var histFileTree = remark().data("settings", {paddedTable: false, gfm: false}).parse(histFileText);
var histFileTree = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false, gfm: false}).parse(histFileText);
var keys = Object.keys(aggData.versions);
keys.sort((a, b) => {
@@ -122,7 +122,7 @@ function aggPhase(aggData) {
var mdText = template(versionTemplateData);
mdText = mdText.replace(/^ +-/mg, "-");
var newSection = remark().data("settings", {paddedTable: false, gfm: false}).parse(mdText.trim()).children;
var newSection = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false, gfm: false}).parse(mdText.trim()).children;
var versSectionName = version.replace(/\./g, "");;