mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
* [ADF-3323] Moved source file parsing to main doc tool * [ADF-3323] Moved source info classes * [ADF-3323] Added doc YAML generator tool * [ADF-3323] Added doc YAML/JSON source paths to gitignore * [ADF-3323] Completed templates and template context code * [ADF-3323] Added source paths and updated type linker * [ADF-3323] Final fixes to templates and type linking * [ADF-3323] Fixed filter for private and protected methods * [ADF-3323] Content services docs after check and rebuild * [ADF-3323] Updated docbuild script in package.json
54 lines
1.2 KiB
JavaScript
54 lines
1.2 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;
|
|
}
|
|
|
|
|
|
function processItem(item) {
|
|
//console.log(`Generating ${item.name}`);
|
|
var docText = template(item);
|
|
fs.writeFileSync(path.resolve(outputFolder, item.name + ".yml"), docText);
|
|
} |