[ADF-2456] Fixed property table formatting (#3051)

This commit is contained in:
Andy Stark
2018-03-08 19:41:38 +00:00
committed by Eugenio Romano
parent 8a70e026cd
commit 606009cac2
5 changed files with 38 additions and 21 deletions

View File

@@ -1,7 +1,6 @@
import * as ts from "typescript";
import * as fs from "fs";
import * as path from "path";
import * as program from "commander";
import * as heading from "mdast-util-heading-range";
import * as remark from "remark";
@@ -9,6 +8,10 @@ import * as remark from "remark";
import * as unist from "../unistHelpers";
import { JsxEmit, isClassDeclaration, PropertyDeclaration } from "typescript";
// Max number of characters in the text for the default value column.
const maxDefaultTextLength = 20;
export function initPhase(aggData) {
}
@@ -397,7 +400,6 @@ function buildPropsTable(props: PropData[], includeInitializer: boolean = true)
for (var i = 0; i < props.length; i++) {
var pName = props[i].name;
var pType = props[i].type;
var pDefault = props[i].initializer || "";
var pDesc = props[i].docText || "";
if (pDesc) {
@@ -406,10 +408,16 @@ function buildPropsTable(props: PropData[], includeInitializer: boolean = true)
var descCellContent = remark().parse(pDesc).children;
var pDefault = props[i].initializer || "";
var defaultCellContent;
if (pDefault) {
defaultCellContent = unist.makeInlineCode(pDefault);
if (pDefault.length > maxDefaultTextLength) {
defaultCellContent = unist.makeText("See description");
console.log(`Warning: property "${pName}" default value substituted (> ${maxDefaultTextLength} chars)`);
} else
defaultCellContent = unist.makeInlineCode(pDefault);
} else {
defaultCellContent = unist.makeText("");
}