mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
* [ADF-4249] Fixed issues with anchors in contents sections * [ADF-4249] Removed redundant copy of edit proc filter cloud docs * [ADF-4249] Fixed YAML template generation for accessor props * [ADF-4249] Fixed ToC link generation * [ADF-4249] Fixed type alias links in component docs
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
var fs = require("fs");
|
|
var path = require("path");
|
|
var ejs = require("ejs");
|
|
|
|
|
|
var templateFolder = path.resolve("tools", "doc", "yamlTemplates");
|
|
var outputFolder = path.resolve("docs", "sourceinfo");
|
|
|
|
if (process.argv.length < 3) {
|
|
console.log("Error: Source filename required");
|
|
process.exit();
|
|
}
|
|
|
|
console.log(`Processing ${process.argv[2]}`);
|
|
|
|
if (!fs.existsSync(outputFolder)) {
|
|
fs.mkdirSync(outputFolder);
|
|
}
|
|
|
|
var docData = JSON.parse(fs.readFileSync(path.resolve(process.argv[2]), "utf8"));
|
|
var tempFilename = path.resolve(templateFolder, "template.ejs");
|
|
var tempSource = fs.readFileSync(tempFilename, "utf8");
|
|
var template = ejs.compile(
|
|
tempSource,
|
|
{
|
|
filename: tempFilename,
|
|
cache: true
|
|
}
|
|
);
|
|
|
|
searchItemsRecursively(docData);
|
|
|
|
|
|
function searchItemsRecursively(item) {
|
|
if (interestedIn(item.kind)) {
|
|
processItem(item);
|
|
} else if (item.children) {
|
|
item.children.forEach(child => {
|
|
searchItemsRecursively(child);
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
function interestedIn(itemKind) {
|
|
return (itemKind === 128) || (itemKind === 256) || (itemKind === 4194304);
|
|
}
|
|
|
|
|
|
function processItem(item) {
|
|
//console.log(`Generating ${item.name}`);
|
|
var docText = template(item);
|
|
fs.writeFileSync(path.resolve(outputFolder, item.name + ".yml"), docText);
|
|
} |