[ADF-3514] Added transclusions sections to doc files (#3756)

* [ADF-3514] Added transclusion sections and guide page

* [ADF-3514] Updated tables of contents where needed

* [ADF-3514] Updated index files
This commit is contained in:
Andy Stark
2018-09-10 11:11:25 +01:00
committed by Eugenio Romano
parent 35e1563fde
commit 2c49de6070
35 changed files with 682 additions and 515 deletions

View File

@@ -4,6 +4,7 @@ var fs = require("fs");
var remark = require("remark");
//var tocGenerator = require("mdast-util-toc");
var replaceSection = require("mdast-util-heading-range");
var tostring = require("mdast-util-to-string");
var ejs = require("ejs");
@@ -117,18 +118,26 @@ function makeToc(tree) {
var headings = nav.headings(h =>
(h.depth > 1) &&
(h.depth <= maxTocHeadingDepth) &&
!((h.children[0].type === "text") && (h.children[0].value === "Contents"))
(h.depth <= maxTocHeadingDepth) //&&
//!((h.children[0].type === "text") && (h.children[0].value === "Contents"))
);
var context = {headings: []};
headings.forEach(heading => {
context.headings.push({
"level": heading.item.depth - 2,
"title": heading.textValue,
"anchor": "#" + heading.textValue.toLowerCase().replace(/ /g, "-").replace(/[\.,'"`$]/g ,"")
})
var linkTitle = "";
if (!((heading.item.children[0].type === "text") && (heading.item.children[0].value === "Contents"))) {
linkTitle = tostring(heading.item).trim();
}
if (linkTitle !== "") {
context.headings.push({
"level": heading.item.depth - 2,
"title": linkTitle,
"anchor": "#" + linkTitle.toLowerCase().replace(/ /g, "-").replace(/[\.,'"`$]/g ,"")
})
};
});
var templateName = path.resolve(templateFolder, "toc.ejs");