[ADF-2596] Fixed inputs with incorrect names (#3166)

* [ADF-2596] Updated prop script to handle names from input decorators

* [ADF-2596] Fixed inputs with accessors

* [ADF-2596] Fixed remaining inputs with wrong names

* [ADF-2596] Updated prop script to handle names from input decorators

* [ADF-2596] Fixed inputs with accessors

* [ADF-2596] Fixed remaining inputs with wrong names
This commit is contained in:
Andy Stark
2018-04-10 17:19:15 +01:00
committed by Eugenio Romano
parent a32b1b7359
commit 2a5fe7ad28
25 changed files with 386 additions and 222 deletions

View File

@@ -60,7 +60,7 @@ function updatePhase(filenames, aggData) {
});
if (modified)
fs.writeFileSync(filenames[i], remark().use(frontMatter, {type: 'yaml', fence: '---'}).data("settings", {paddedTable: false}).stringify(tree));
fs.writeFileSync(filenames[i], remark().use(frontMatter, {type: 'yaml', fence: '---'}).data("settings", {paddedTable: false, gfm: false}).stringify(tree));
//console.log(JSON.stringify(tree));
}

View File

@@ -5,7 +5,7 @@
| -- | -- | -- | -- |
{% each properties as prop %}
{% if prop.isInput %}
| {{prop.name}} | `{{{prop.type}}}` | {{{prop.defaultValue}}} | {{{prop.docText}}} |
| {{{prop.name}}} | `{{{prop.type}}}` | {{{prop.defaultValue}}} | {{{prop.docText}}} |
{% endif %}
{% endeach %}
{% endif %}

View File

@@ -1 +1,23 @@
{% include 'component' %}
{% if hasInputs %}
### Properties
| Name | Type | Default value | Description |
| -- | -- | -- | -- |
{% each properties as prop %}
{% if prop.isInput %}
| {{{prop.name}}} | `{{{prop.type}}}` | {{{prop.defaultValue}}} | {{{prop.docText}}} |
{% endif %}
{% endeach %}
{% endif %}
{% if hasOutputs%}
### Events
| Name | Type | Description |
| -- | -- | -- |
{% each properties as prop %}
{% if prop.isOutput %}
| {{prop.name}} | `{{{prop.type}}}` | {{{prop.docText}}} |
{% endif %}
{% endeach %}
{% endif %}

View File

@@ -13,7 +13,8 @@ var excludePatterns = [
];
var nameExceptions = {
"datatable.component": "DataTableComponent",
"tasklist.service": "TaskListService"
"tasklist.service": "TaskListService",
"text-mask.component": "InputMaskDirective"
};
var PropInfo = /** @class */ (function () {
function PropInfo(rawProp) {
@@ -30,12 +31,14 @@ var PropInfo = /** @class */ (function () {
}
if (rawProp.decorators) {
rawProp.decorators.forEach(function (dec) {
//console.log(dec);
if (dec.name === "Input") {
_this.isInput = true;
if (dec.arguments) {
var bindingName = dec["bindingPropertyName"];
var bindingName = dec.arguments["bindingPropertyName"];
//console.log(JSON.stringify(dec.arguments));
if (bindingName && (bindingName !== ""))
_this.name = bindingName;
_this.name = bindingName.replace(/['"]/g, "");
}
if (!_this.docText && !_this.isDeprecated)
console.log("Warning: Input \"" + rawProp.getFullName() + "\" has no doc text.");
@@ -106,7 +109,8 @@ var ComponentInfo = /** @class */ (function () {
function ComponentInfo(classRef) {
var _this = this;
var props = classRef.getChildrenByKind(typedoc_1.ReflectionKind.Property);
this.properties = props.map(function (item) {
var accessors = classRef.getChildrenByKind(typedoc_1.ReflectionKind.Accessor);
this.properties = props.concat(accessors).map(function (item) {
return new PropInfo(item);
});
var methods = classRef.getChildrenByKind(typedoc_1.ReflectionKind.Method);
@@ -131,7 +135,9 @@ var ComponentInfo = /** @class */ (function () {
function initPhase(aggData) {
var app = new typedoc_1.Application({
exclude: excludePatterns,
ignoreCompilerErrors: true
ignoreCompilerErrors: true,
experimentalDecorators: true,
tsconfig: "tsconfig.json"
});
var sources = app.expandInputFiles(libFolders);
aggData.projData = app.convert(sources);
@@ -158,7 +164,8 @@ function updatePhase(tree, pathname, aggData) {
var templateSource = fs.readFileSync(templateName, "utf8");
var template = combyne(templateSource);
var mdText = template.render(compData);
var newSection_1 = remark().parse(mdText.trim()).children;
mdText = mdText.replace(/^ +\|/mg, "|");
var newSection_1 = remark().data("settings", { paddedTable: false, gfm: false }).parse(mdText.trim()).children;
replaceSection(tree, "Class members", function (before, section, after) {
newSection_1.unshift(before);
newSection_1.push(after);
@@ -185,13 +192,17 @@ function updatePhase(tree, pathname, aggData) {
return true;
}
exports.updatePhase = updatePhase;
function renderInputs(comp) {
/*
function renderInputs(comp: ComponentInfo): string {
var result = "";
comp.properties.forEach(function (prop) {
result += "| " + prop.name + " | `" + prop.type + "` | " + prop.defaultValue + " | " + prop.docText + " |\n";
comp.properties.forEach(prop => {
result += `| ${prop.name} | \`${prop.type}\` | ${prop.defaultValue} | ${prop.docText} |\n`;
});
return result;
}
*/
function initialCap(str) {
return str[0].toUpperCase() + str.substr(1);
}

View File

@@ -3,6 +3,7 @@ import * as path from "path";
import * as replaceSection from "mdast-util-heading-range";
import * as remark from "remark";
import * as stringify from "remark-stringify";
import * as frontMatter from "remark-frontmatter";
import * as combyne from "combyne";
@@ -31,7 +32,8 @@ let excludePatterns = [
let nameExceptions = {
"datatable.component": "DataTableComponent",
"tasklist.service": "TaskListService"
"tasklist.service": "TaskListService",
"text-mask.component": "InputMaskDirective"
}
@@ -61,20 +63,18 @@ class PropInfo {
if (rawProp.decorators) {
rawProp.decorators.forEach(dec => {
//console.log(dec);
if (dec.name === "Input") {
this.isInput = true;
/*
if (dec.arguments) {
let bindingName = dec.arguments["bindingPropertyName"];
console.log(JSON.stringify(dec.arguments));
//console.log(JSON.stringify(dec.arguments));
if (bindingName && (bindingName !== ""))
this.name = bindingName;
this.name = bindingName.replace(/['"]/g, "");
}
*/
if (!this.docText && !this.isDeprecated)
console.log(`Warning: Input "${rawProp.getFullName()}" has no doc text.`);
}
@@ -181,8 +181,9 @@ class ComponentInfo {
constructor(classRef: DeclarationReflection) {
let props = classRef.getChildrenByKind(ReflectionKind.Property);
this.properties = props.map(item => {
let accessors = classRef.getChildrenByKind(ReflectionKind.Accessor);
this.properties = [...props, ...accessors].map(item => {
return new PropInfo(item);
});
@@ -214,11 +215,14 @@ class ComponentInfo {
export function initPhase(aggData) {
let app = new Application({
exclude: excludePatterns,
ignoreCompilerErrors: true
ignoreCompilerErrors: true,
experimentalDecorators: true,
tsconfig: "tsconfig.json"
});
let sources = app.expandInputFiles(libFolders);
aggData.projData = app.convert(sources);
/*
aggData.liq = liquid({
root: templateFolder
@@ -247,7 +251,9 @@ export function updatePhase(tree, pathname, aggData) {
let template = combyne(templateSource);
let mdText = template.render(compData);
let newSection = remark().parse(mdText.trim()).children;
mdText = mdText.replace(/^ +\|/mg, "|");
let newSection = remark().data("settings", {paddedTable: false, gfm: false}).parse(mdText.trim()).children;
replaceSection(tree, "Class members", (before, section, after) => {
newSection.unshift(before);
@@ -276,7 +282,7 @@ export function updatePhase(tree, pathname, aggData) {
return true;
}
/*
function renderInputs(comp: ComponentInfo): string {
var result = "";
@@ -286,6 +292,7 @@ function renderInputs(comp: ComponentInfo): string {
return result;
}
*/
function initialCap(str: string) {
return str[0].toUpperCase() + str.substr(1);