[ADF-2557] Updated doc files with new script and fixed script bugs (#3135)

This commit is contained in:
Andy Stark
2018-03-29 17:02:40 +01:00
committed by Eugenio Romano
parent 9401e77e0c
commit 717dbfb388
19 changed files with 306 additions and 164 deletions

View File

@@ -4,8 +4,7 @@ var fs = require("fs");
var path = require("path");
var replaceSection = require("mdast-util-heading-range");
var remark = require("remark");
var frontMatter = require("remark-frontmatter");
var liquid = require("liquidjs");
var combyne = require("combyne");
var typedoc_1 = require("typedoc");
var libFolders = ["core", "content-services", "process-services", "insights"];
var templateFolder = path.resolve(".", "config", "DocProcessor", "templates");
@@ -25,21 +24,29 @@ var PropInfo = /** @class */ (function () {
this.defaultValue = rawProp.defaultValue || "";
this.defaultValue = this.defaultValue.replace(/\|/, "\\|");
this.type = rawProp.type ? rawProp.type.toString() : "";
this.isDeprecated = rawProp.comment && rawProp.comment.hasTag("deprecated");
if (this.isDeprecated) {
this.docText = "**Deprecated:** " + rawProp.comment.getTag("deprecated").text.replace(/[\n\r]+/g, " ").trim();
}
if (rawProp.decorators) {
rawProp.decorators.forEach(function (dec) {
if (dec.name === "Input") {
_this.isInput = true;
if (!_this.docText)
if (dec.arguments) {
var bindingName = dec["bindingPropertyName"];
if (bindingName && (bindingName !== ""))
_this.name = bindingName;
}
if (!_this.docText && !_this.isDeprecated)
console.log("Warning: Input \"" + rawProp.getFullName() + "\" has no doc text.");
}
if (dec.name === "Output") {
_this.isOutput = true;
if (!_this.docText)
if (!_this.docText && !_this.isDeprecated)
console.log("Warning: Output \"" + rawProp.getFullName() + "\" has no doc text.");
}
});
}
this.isDeprecated = rawProp.comment && rawProp.comment.hasTag("deprecated");
}
return PropInfo;
}());
@@ -66,6 +73,7 @@ var MethodSigInfo = /** @class */ (function () {
var _this = this;
this.name = rawSig.name;
this.returnType = rawSig.type ? rawSig.type.toString() : "";
this.returnsSomething = this.returnType != "void";
if (rawSig.hasComment()) {
this.docText = rawSig.comment.shortText + rawSig.comment.text;
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
@@ -73,7 +81,9 @@ var MethodSigInfo = /** @class */ (function () {
console.log("Warning: method \"" + rawSig.name + "\" has no doc text.");
this.returnDocText = rawSig.comment.returns;
this.returnDocText = this.returnDocText ? this.returnDocText.replace(/[\n\r]+/g, " ").trim() : "";
if (!this.returnDocText)
if (this.returnDocText.toLowerCase() === "nothing")
this.returnsSomething = false;
if (this.returnsSomething && !this.returnDocText)
console.log("Warning: Return value of method \"" + rawSig.name + "\" has no doc text.");
this.isDeprecated = rawSig.comment.hasTag("deprecated");
}
@@ -125,9 +135,11 @@ function initPhase(aggData) {
});
var sources = app.expandInputFiles(libFolders);
aggData.projData = app.convert(sources);
/*
aggData.liq = liquid({
root: templateFolder
});
*/
}
exports.initPhase = initPhase;
function readPhase(tree, pathname, aggData) {
@@ -142,22 +154,44 @@ function updatePhase(tree, pathname, aggData) {
var compData = new ComponentInfo(classRef);
var classType = compName.match(/component|directive|service/i);
if (classType) {
var templateName = classType[0] + ".liquid";
var templateName = path.resolve(templateFolder, classType + ".combyne");
var templateSource = fs.readFileSync(templateName, "utf8");
var template = combyne(templateSource);
var mdText = template.render(compData);
var newSection_1 = remark().parse(mdText.trim()).children;
replaceSection(tree, "Class members", function (before, section, after) {
newSection_1.unshift(before);
newSection_1.push(after);
return newSection_1;
});
/*
let templateName = classType[0] + ".liquid";
aggData.liq
.renderFile(templateName, compData)
.then(function (mdText) {
var newSection = remark().parse(mdText).children;
replaceSection(tree, "Class members", function (before, section, after) {
.renderFile(templateName, compData)
.then(mdText => {
let newSection = remark().parse(mdText).children;
replaceSection(tree, "Class members", (before, section, after) => {
newSection.unshift(before);
newSection.push(after);
return newSection;
});
fs.writeFileSync(pathname, remark().use(frontMatter, { type: 'yaml', fence: '---' }).data("settings", { paddedTable: false }).stringify(tree));
fs.writeFileSync(pathname, remark().use(frontMatter, {type: 'yaml', fence: '---'}).data("settings", {paddedTable: false}).stringify(tree));
});
*/
}
return false;
return true;
}
exports.updatePhase = updatePhase;
function renderInputs(comp) {
var result = "";
comp.properties.forEach(function (prop) {
result += "| " + prop.name + " | `" + prop.type + "` | " + prop.defaultValue + " | " + prop.docText + " |\n";
});
return result;
}
function initialCap(str) {
return str[0].toUpperCase() + str.substr(1);
}