[ADF-2911] Improved error message handling in doc tools (#3267)

This commit is contained in:
Andy Stark
2018-05-03 16:39:04 +01:00
committed by Eugenio Romano
parent 96fddbdc39
commit 8f9cb75120
3 changed files with 142 additions and 30 deletions

View File

@@ -16,9 +16,13 @@ var nameExceptions = {
"tasklist.service": "TaskListService",
"text-mask.component": "InputMaskDirective"
};
var undocMethodNames = {
"ngOnChanges": 1
};
var PropInfo = /** @class */ (function () {
function PropInfo(rawProp) {
var _this = this;
this.errorMessages = [];
this.name = rawProp.name;
this.docText = rawProp.comment ? rawProp.comment.shortText : "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
@@ -36,21 +40,29 @@ var PropInfo = /** @class */ (function () {
_this.isInput = true;
if (dec.arguments) {
var bindingName = dec.arguments["bindingPropertyName"];
//console.log(JSON.stringify(dec.arguments));
if (bindingName && (bindingName !== ""))
_this.name = bindingName.replace(/['"]/g, "");
}
if (!_this.docText && !_this.isDeprecated)
console.log("Warning: Input \"" + rawProp.getFullName() + "\" has no doc text.");
if (!_this.docText && !_this.isDeprecated) {
_this.errorMessages.push("Warning: Input \"" + rawProp.name + "\" has no doc text.");
}
}
if (dec.name === "Output") {
_this.isOutput = true;
if (!_this.docText && !_this.isDeprecated)
console.log("Warning: Output \"" + rawProp.getFullName() + "\" has no doc text.");
if (!_this.docText && !_this.isDeprecated) {
_this.errorMessages.push("Warning: Output \"" + rawProp.name + "\" has no doc text.");
}
}
});
}
}
Object.defineProperty(PropInfo.prototype, "errors", {
get: function () {
return this.errorMessages;
},
enumerable: true,
configurable: true
});
return PropInfo;
}());
;
@@ -74,28 +86,33 @@ var ParamInfo = /** @class */ (function () {
var MethodSigInfo = /** @class */ (function () {
function MethodSigInfo(rawSig) {
var _this = this;
this.errorMessages = [];
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();
if (!this.docText)
console.log("Warning: method \"" + rawSig.name + "\" has no doc text.");
if (!this.docText) {
this.errorMessages.push("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.toLowerCase() === "nothing")
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.");
}
if (this.returnsSomething && !this.returnDocText) {
this.errorMessages.push("Warning: Return value of method \"" + rawSig.name + "\" has no doc text.");
}
this.isDeprecated = rawSig.comment.hasTag("deprecated");
}
this.params = [];
var paramStrings = [];
if (rawSig.parameters) {
rawSig.parameters.forEach(function (rawParam) {
if (!rawParam.comment || !rawParam.comment.text)
console.log("Warning: parameter \"" + rawParam.name + "\" of method \"" + rawSig.name + "\" has no doc text.");
if (!rawParam.comment || !rawParam.comment.text) {
_this.errorMessages.push("Warning: parameter \"" + rawParam.name + "\" of method \"" + rawSig.name + "\" has no doc text.");
}
var param = new ParamInfo(rawParam);
_this.params.push(param);
paramStrings.push(param.combined);
@@ -103,6 +120,13 @@ var MethodSigInfo = /** @class */ (function () {
}
this.signature = "(" + paramStrings.join(", ") + ")";
}
Object.defineProperty(MethodSigInfo.prototype, "errors", {
get: function () {
return this.errorMessages;
},
enumerable: true,
configurable: true
});
return MethodSigInfo;
}());
var ComponentInfo = /** @class */ (function () {
@@ -116,7 +140,7 @@ var ComponentInfo = /** @class */ (function () {
var methods = classRef.getChildrenByKind(typedoc_1.ReflectionKind.Method);
this.methods = [];
methods.forEach(function (method) {
if (!(method.flags.isPrivate || method.flags.isProtected)) {
if (!(method.flags.isPrivate || method.flags.isProtected || undocMethodNames[method.name])) {
method.signatures.forEach(function (sig) {
_this.methods.push(new MethodSigInfo(sig));
});
@@ -130,6 +154,24 @@ var ComponentInfo = /** @class */ (function () {
});
this.hasMethods = methods.length > 0;
}
Object.defineProperty(ComponentInfo.prototype, "errors", {
get: function () {
var combinedErrors = [];
this.methods.forEach(function (method) {
method.errors.forEach(function (err) {
combinedErrors.push(err);
});
});
this.properties.forEach(function (prop) {
prop.errors.forEach(function (err) {
combinedErrors.push(err);
});
});
return combinedErrors;
},
enumerable: true,
configurable: true
});
return ComponentInfo;
}());
function initPhase(aggData) {
@@ -154,7 +196,7 @@ exports.readPhase = readPhase;
function aggPhase(aggData) {
}
exports.aggPhase = aggPhase;
function updatePhase(tree, pathname, aggData) {
function updatePhase(tree, pathname, aggData, errorMessages) {
var compName = angNameToClassName(path.basename(pathname, ".md"));
var classRef = aggData.projData.findReflectionByName(compName);
if (!classRef) {
@@ -175,6 +217,9 @@ function updatePhase(tree, pathname, aggData) {
newSection_1.push(after);
return newSection_1;
});
compData.errors.forEach(function (err) {
errorMessages.push(err);
});
/*
let templateName = classType[0] + ".liquid";