[ADF-1769] Updates to prop table script (#2829)

* [ADF-1769] Fixed prop table tool formatting

* [ADF-1769] Added code style to event type column
This commit is contained in:
Andy Stark
2018-01-16 00:10:02 +00:00
committed by Eugenio Romano
parent e757378e9b
commit 3bee9a70f5
5 changed files with 135 additions and 97 deletions

View File

@@ -2,7 +2,6 @@
exports.__esModule = true;
var ts = require("typescript");
var path = require("path");
var program = require("commander");
var heading = require("mdast-util-heading-range");
var unist = require("../unistHelpers");
function initPhase(aggData) {
@@ -27,19 +26,18 @@ function updatePhase(tree, pathname, aggData) {
var inTable_1 = buildInputsTable(inputs);
var outTable_1 = buildOutputsTable(outputs);
if (inTable_1) {
console.log("Made a props table");
heading(tree, "Properties", function (before, section, after) {
return [before, inTable_1, after];
});
}
if (outTable_1) {
console.log("Made an events table");
heading(tree, "Events", function (before, section, after) {
return [before, outTable_1, after];
});
}
}
}
return true;
}
exports.updatePhase = updatePhase;
function initialCap(str) {
@@ -61,7 +59,7 @@ function fixCompodocFilename(rawName) {
return finalName;
}
function getPropDocData(srcPath, docClassName, inputs, outputs) {
var prog = ts.createProgram(program.args, {
var prog = ts.createProgram([srcPath], {
target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS
});
var sourceFiles = prog.getSourceFiles();
@@ -97,7 +95,8 @@ function getPropDataFromClass(checker, classDec, inputs, outputs) {
if (prop.initializer) {
initializer = prop.initializer.getText(sourceFile);
}
var doc = ts.displayPartsToString(memSymbol.getDocumentationComment());
var doc = ts.displayPartsToString(memSymbol.getDocumentationComment(checker));
doc = doc.replace(/\r\n/g, " ");
var propType = checker.typeToString(checker.getTypeOfSymbolAtLocation(memSymbol, memSymbol.valueDeclaration));
var dec = prop.decorators[0].getText(sourceFile);
if (dec.match(/@Input/)) {
@@ -127,23 +126,30 @@ function buildInputsTable(inputs) {
unist.makeTableRow([
unist.makeTableCell([unist.makeText("Name")]),
unist.makeTableCell([unist.makeText("Type")]),
unist.makeTableCell([unist.makeText("Default value")]),
// unist.makeTableCell([unist.makeText("Default value")]),
unist.makeTableCell([unist.makeText("Description")])
])
];
for (var i = 0; i < inputs.length; i++) {
var pName = inputs[i].name;
var pType = inputs[i].type;
var pDefault = inputs[i].defaultValue || "";
var pDesc = inputs[i].description || "";
var pDefault = inputs[i].init || "";
var pDesc = inputs[i].docText || "";
if (pDesc) {
pDesc = pDesc.trim().replace(/[\n\r]+/, " ");
//pDesc = pDesc.trim().replace(/[\n\r]+/, " ");
pDesc = pDesc.replace(/[\n\r]+/, " ");
}
var descCellContent = [unist.makeText(pDesc)];
if (pDefault) {
descCellContent.push(unist.makeHTML("<br/>"));
descCellContent.push(unist.makeText(" Default value: "));
descCellContent.push(unist.makeInlineCode(pDefault));
}
var cells = [
unist.makeTableCell([unist.makeText(pName)]),
unist.makeTableCell([unist.makeText(pType)]),
unist.makeTableCell([unist.makeText(pDefault)]),
unist.makeTableCell([unist.makeText(pDesc)])
unist.makeTableCell([unist.makeInlineCode(pType)]),
//unist.makeTableCell([unist.makeText(pDefault)]),
unist.makeTableCell(descCellContent)
];
rows.push(unist.makeTableRow(cells));
}
@@ -163,13 +169,13 @@ function buildOutputsTable(outputs) {
for (var i = 0; i < outputs.length; i++) {
var eName = outputs[i].name;
var eType = outputs[i].type;
var eDesc = outputs[i].description || "";
var eDesc = outputs[i].docText || "";
if (eDesc) {
eDesc = eDesc.trim().replace(/[\n\r]+/, ' ');
}
var cells = [
unist.makeTableCell([unist.makeText(eName)]),
unist.makeTableCell([unist.makeText(eType)]),
unist.makeTableCell([unist.makeInlineCode(eType)]),
unist.makeTableCell([unist.makeText(eDesc)])
];
rows.push(unist.makeTableRow(cells));