[ADF-3323] Updated doc tools to use DocFX intermediate files (#3601)

* [ADF-3323] Moved source file parsing to main doc tool

* [ADF-3323] Moved source info classes

* [ADF-3323] Added doc YAML generator tool

* [ADF-3323] Added doc YAML/JSON source paths to gitignore

* [ADF-3323] Completed templates and template context code

* [ADF-3323] Added source paths and updated type linker

* [ADF-3323] Final fixes to templates and type linking

* [ADF-3323] Fixed filter for private and protected methods

* [ADF-3323] Content services docs after check and rebuild

* [ADF-3323] Updated docbuild script in package.json
This commit is contained in:
Andy Stark
2018-08-14 15:42:25 +01:00
committed by Eugenio Romano
parent 54380fd693
commit 69d8ff147e
61 changed files with 1437 additions and 731 deletions
+340
View File
@@ -0,0 +1,340 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var undocMethodNames = {
"ngOnChanges": 1
};
var PropInfo = /** @class */ (function () {
/*
constructor(rawProp: DeclarationReflection) {
this.errorMessages = [];
this.name = rawProp.name;
this.docText = rawProp.comment ? rawProp.comment.shortText : "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
this.defaultValue = rawProp.defaultValue || "";
this.defaultValue = this.defaultValue.replace(/\|/, "\\|");
this.type = rawProp.type ? rawProp.type.toString().replace(/\s/g, "") : "";
this.type = this.type.replace(/\|/, "\\|");
this.isDeprecated = rawProp.comment && rawProp.comment.hasTag("deprecated");
if (this.isDeprecated) {
this.docText = "(**Deprecated:** " + rawProp.comment.getTag("deprecated").text.replace(/[\n\r]+/g, " ").trim() + ") " + this.docText;
}
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"];
if (bindingName && (bindingName !== ""))
this.name = bindingName.replace(/['"]/g, "");
}
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) {
this.errorMessages.push(`Warning: Output "${rawProp.name}" has no doc text.`);
}
}
});
}
}
*/
function PropInfo(sourceData) {
var _this = this;
this.errorMessages = [];
this.name = sourceData.name;
this.docText = sourceData.summary || "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
var tempDefaultVal = sourceData.syntax["return"].defaultValue;
this.defaultValue = tempDefaultVal ? tempDefaultVal.toString() : "";
this.defaultValue = this.defaultValue.replace(/\|/, "\\|");
this.type = sourceData.syntax["return"].type || "";
this.type = this.type.toString().replace(/\|/, "\\|");
if (sourceData.tags) {
var depTag = sourceData.tags.find(function (tag) { return tag.name === "deprecated"; });
if (depTag) {
this.isDeprecated = true;
this.docText = "(**Deprecated:** " + depTag.text.replace(/[\n\r]+/g, " ").trim() + ") " + this.docText;
}
}
this.isInput = false;
this.isOutput = false;
if (sourceData.decorators) {
sourceData.decorators.forEach(function (dec) {
//console.log(dec);
if (dec.name === "Input") {
_this.isInput = true;
if (dec.arguments) {
var bindingName = dec.arguments["bindingPropertyName"];
if (bindingName && (bindingName !== ""))
_this.name = bindingName.replace(/['"]/g, "");
}
if (!_this.docText && !_this.isDeprecated) {
_this.errorMessages.push("Warning: Input \"" + sourceData.name + "\" has no doc text.");
}
}
if (dec.name === "Output") {
_this.isOutput = true;
if (!_this.docText && !_this.isDeprecated) {
_this.errorMessages.push("Warning: Output \"" + sourceData.name + "\" has no doc text.");
}
}
});
}
}
Object.defineProperty(PropInfo.prototype, "errors", {
get: function () {
return this.errorMessages;
},
enumerable: true,
configurable: true
});
return PropInfo;
}());
exports.PropInfo = PropInfo;
;
var ParamInfo = /** @class */ (function () {
/*
constructor(rawParam: ParameterReflection) {
this.name = rawParam.name;
this.type = rawParam.type.toString().replace(/\s/g, "");
this.defaultValue = rawParam.defaultValue;
this.docText = rawParam.comment ? rawParam.comment.text : "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
this.isOptional = rawParam.flags.isOptional;
this.combined = this.name;
if (this.isOptional)
this.combined += "?";
this.combined += `: \`${this.type}\``;
if (this.defaultValue !== "")
this.combined += ` = \`${this.defaultValue}\``;
}
*/
function ParamInfo(sourceData) {
this.name = sourceData.id;
this.type = sourceData.type.toString().replace(/\s/g, "");
this.defaultValue = sourceData.defaultValue;
this.docText = sourceData.description.replace(/[\n\r]+/g, " ").trim();
this.isOptional = false;
if (sourceData.flags) {
var flag = sourceData.flags.find(function (flag) { return flag.name === "isOptional"; });
if (flag) {
this.isOptional = true;
}
}
this.combined = this.name;
if (this.isOptional)
this.combined += "?";
this.combined += ": `" + this.type + "`";
if (this.defaultValue !== "")
this.combined += " = `" + this.defaultValue + "`";
}
return ParamInfo;
}());
exports.ParamInfo = ParamInfo;
var MethodSigInfo = /** @class */ (function () {
/*
constructor(rawSig: SignatureReflection) {
this.errorMessages = [];
this.name = rawSig.name;
this.returnType = rawSig.type ? rawSig.type.toString().replace(/\s/g, "") : "";
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) {
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") {
this.returnsSomething = false;
}
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 = [];
let paramStrings = [];
if (rawSig.parameters) {
rawSig.parameters.forEach(rawParam => {
if (!rawParam.comment || !rawParam.comment.text) {
this.errorMessages.push(`Warning: parameter "${rawParam.name}" of method "${rawSig.name}" has no doc text.`);
}
let param = new ParamInfo(rawParam);
this.params.push(param);
paramStrings.push(param.combined);
});
}
this.signature = "(" + paramStrings.join(", ") + ")";
}
*/
function MethodSigInfo(sourceData) {
var _this = this;
this.errorMessages = [];
this.name = sourceData.name;
this.docText = sourceData.summary || "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
if (!this.docText) {
this.errorMessages.push("Warning: method \"" + sourceData.name + "\" has no doc text.");
}
this.returnType = sourceData.syntax["return"].type || "";
this.returnType = this.returnType.toString().replace(/\s/g, "");
this.returnsSomething = this.returnType && (this.returnType !== "void");
this.returnDocText = sourceData.syntax["return"].summary || "";
if (this.returnDocText.toLowerCase() === "nothing") {
this.returnsSomething = false;
}
if (this.returnsSomething && !this.returnDocText) {
this.errorMessages.push("Warning: Return value of method \"" + sourceData.name + "\" has no doc text.");
}
this.isDeprecated = false;
if (sourceData.tags) {
var depTag = sourceData.tags.find(function (tag) { return tag.name === "deprecated"; });
if (depTag) {
this.isDeprecated = true;
this.docText = "(**Deprecated:** " + depTag.text.replace(/[\n\r]+/g, " ").trim() + ") " + this.docText;
}
}
this.params = [];
var paramStrings = [];
if (sourceData.syntax.parameters) {
sourceData.syntax.parameters.forEach(function (rawParam) {
if (!rawParam.description) {
_this.errorMessages.push("Warning: parameter \"" + rawParam.name + "\" of method \"" + sourceData.name + "\" has no doc text.");
}
var param = new ParamInfo(rawParam);
_this.params.push(param);
paramStrings.push(param.combined);
});
}
this.signature = "(" + paramStrings.join(", ") + ")";
}
Object.defineProperty(MethodSigInfo.prototype, "errors", {
get: function () {
return this.errorMessages;
},
enumerable: true,
configurable: true
});
return MethodSigInfo;
}());
exports.MethodSigInfo = MethodSigInfo;
var ComponentInfo = /** @class */ (function () {
/*
constructor(classRef: DeclarationReflection) {
let props = classRef.getChildrenByKind(ReflectionKind.Property);
let accessors = classRef.getChildrenByKind(ReflectionKind.Accessor);
this.properties = [...props, ...accessors].map(item => {
return new PropInfo(item);
});
let methods = classRef.getChildrenByKind(ReflectionKind.Method);
this.methods = [];
methods.forEach(method =>{
if (!(method.flags.isPrivate || method.flags.isProtected || undocMethodNames[method.name])) {
method.signatures.forEach(sig => {
this.methods.push(new MethodSigInfo(sig));
});
}
});
this.hasInputs = false;
this.hasOutputs = false;
this.properties.forEach(prop => {
if (prop.isInput)
this.hasInputs = true;
if (prop.isOutput)
this.hasOutputs = true;
});
this.hasMethods = methods.length > 0;
}
*/
function ComponentInfo(sourceData) {
var _this = this;
this.hasInputs = false;
this.hasOutputs = false;
this.hasMethods = false;
this.sourcePath = sourceData.items[0].source.path;
this.sourceLine = sourceData.items[0].source.line;
this.properties = [];
this.methods = [];
sourceData.items.forEach(function (item) {
switch (item.type) {
case "property":
var prop = new PropInfo(item);
_this.properties.push(prop);
if (prop.isInput) {
_this.hasInputs = true;
}
if (prop.isOutput) {
_this.hasOutputs = true;
}
break;
case "method":
if (item.flags && (item.flags.length > 0) &&
!item.flags.find(function (flag) { return flag.name === "isPrivate"; }) &&
!item.flags.find(function (flag) { return flag.name === "isProtected"; }) &&
!undocMethodNames[item.name]) {
_this.methods.push(new MethodSigInfo(item));
_this.hasMethods = true;
}
break;
default:
break;
}
});
}
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;
}());
exports.ComponentInfo = ComponentInfo;
+420
View File
@@ -0,0 +1,420 @@
import {
DeclarationReflection,
SignatureReflection,
ParameterReflection,
ReflectionKind,
} from "typedoc";
import { find } from "shelljs";
import { isUndefined } from "util";
let undocMethodNames = {
"ngOnChanges": 1
};
export class PropInfo {
name: string;
type: string;
typeLink: string;
defaultValue: string;
docText: string;
isInput: boolean;
isOutput: boolean;
isDeprecated: boolean;
errorMessages: string[];
/*
constructor(rawProp: DeclarationReflection) {
this.errorMessages = [];
this.name = rawProp.name;
this.docText = rawProp.comment ? rawProp.comment.shortText : "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
this.defaultValue = rawProp.defaultValue || "";
this.defaultValue = this.defaultValue.replace(/\|/, "\\|");
this.type = rawProp.type ? rawProp.type.toString().replace(/\s/g, "") : "";
this.type = this.type.replace(/\|/, "\\|");
this.isDeprecated = rawProp.comment && rawProp.comment.hasTag("deprecated");
if (this.isDeprecated) {
this.docText = "(**Deprecated:** " + rawProp.comment.getTag("deprecated").text.replace(/[\n\r]+/g, " ").trim() + ") " + this.docText;
}
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"];
if (bindingName && (bindingName !== ""))
this.name = bindingName.replace(/['"]/g, "");
}
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) {
this.errorMessages.push(`Warning: Output "${rawProp.name}" has no doc text.`);
}
}
});
}
}
*/
constructor(sourceData) {
this.errorMessages = [];
this.name = sourceData.name;
this.docText = sourceData.summary || "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
let tempDefaultVal = sourceData.syntax["return"].defaultValue;
this.defaultValue = tempDefaultVal ? tempDefaultVal.toString() : "";
this.defaultValue = this.defaultValue.replace(/\|/, "\\|");
this.type = sourceData.syntax["return"].type || "";
this.type = this.type.toString().replace(/\|/, "\\|");
if (sourceData.tags) {
let depTag = sourceData.tags.find(tag => tag.name === "deprecated");
if (depTag) {
this.isDeprecated = true;
this.docText = "(**Deprecated:** " + depTag.text.replace(/[\n\r]+/g, " ").trim() + ") " + this.docText;
}
}
this.isInput = false;
this.isOutput = false;
if (sourceData.decorators) {
sourceData.decorators.forEach(dec => {
//console.log(dec);
if (dec.name === "Input") {
this.isInput = true;
if (dec.arguments) {
let bindingName = dec.arguments["bindingPropertyName"];
if (bindingName && (bindingName !== ""))
this.name = bindingName.replace(/['"]/g, "");
}
if (!this.docText && !this.isDeprecated) {
this.errorMessages.push(`Warning: Input "${sourceData.name}" has no doc text.`);
}
}
if (dec.name === "Output") {
this.isOutput = true;
if (!this.docText && !this.isDeprecated) {
this.errorMessages.push(`Warning: Output "${sourceData.name}" has no doc text.`);
}
}
});
}
}
get errors() {
return this.errorMessages;
}
};
export class ParamInfo {
name: string;
type: string;
defaultValue: string;
docText: string;
combined: string;
isOptional: boolean;
/*
constructor(rawParam: ParameterReflection) {
this.name = rawParam.name;
this.type = rawParam.type.toString().replace(/\s/g, "");
this.defaultValue = rawParam.defaultValue;
this.docText = rawParam.comment ? rawParam.comment.text : "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
this.isOptional = rawParam.flags.isOptional;
this.combined = this.name;
if (this.isOptional)
this.combined += "?";
this.combined += `: \`${this.type}\``;
if (this.defaultValue !== "")
this.combined += ` = \`${this.defaultValue}\``;
}
*/
constructor(sourceData) {
this.name = sourceData.id;
this.type = sourceData.type.toString().replace(/\s/g, "");
this.defaultValue = sourceData.defaultValue;
this.docText = sourceData.description.replace(/[\n\r]+/g, " ").trim();
this.isOptional = false;
if (sourceData.flags) {
let flag = sourceData.flags.find(flag => flag.name === "isOptional");
if (flag) {
this.isOptional = true;
}
}
this.combined = this.name;
if (this.isOptional)
this.combined += "?";
this.combined += `: \`${this.type}\``;
if (this.defaultValue !== "")
this.combined += ` = \`${this.defaultValue}\``;
}
}
export class MethodSigInfo {
name: string;
docText: string;
returnType: string;
returnDocText: string;
returnsSomething: boolean;
signature: string;
params: ParamInfo[];
isDeprecated: boolean;
errorMessages: string[];
/*
constructor(rawSig: SignatureReflection) {
this.errorMessages = [];
this.name = rawSig.name;
this.returnType = rawSig.type ? rawSig.type.toString().replace(/\s/g, "") : "";
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) {
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") {
this.returnsSomething = false;
}
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 = [];
let paramStrings = [];
if (rawSig.parameters) {
rawSig.parameters.forEach(rawParam => {
if (!rawParam.comment || !rawParam.comment.text) {
this.errorMessages.push(`Warning: parameter "${rawParam.name}" of method "${rawSig.name}" has no doc text.`);
}
let param = new ParamInfo(rawParam);
this.params.push(param);
paramStrings.push(param.combined);
});
}
this.signature = "(" + paramStrings.join(", ") + ")";
}
*/
constructor(sourceData) {
this.errorMessages = [];
this.name = sourceData.name;
this.docText = sourceData.summary || "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
if (!this.docText) {
this.errorMessages.push(`Warning: method "${sourceData.name}" has no doc text.`);
}
this.returnType = sourceData.syntax["return"].type || "";
this.returnType = this.returnType.toString().replace(/\s/g, "");
this.returnsSomething = this.returnType && (this.returnType !== "void");
this.returnDocText = sourceData.syntax["return"].summary || "";
if (this.returnDocText.toLowerCase() === "nothing") {
this.returnsSomething = false;
}
if (this.returnsSomething && !this.returnDocText) {
this.errorMessages.push(`Warning: Return value of method "${sourceData.name}" has no doc text.`);
}
this.isDeprecated = false;
if (sourceData.tags) {
let depTag = sourceData.tags.find(tag => tag.name === "deprecated");
if (depTag) {
this.isDeprecated = true;
this.docText = "(**Deprecated:** " + depTag.text.replace(/[\n\r]+/g, " ").trim() + ") " + this.docText;
}
}
this.params = [];
let paramStrings = [];
if (sourceData.syntax.parameters) {
sourceData.syntax.parameters.forEach(rawParam => {
if (!rawParam.description) {
this.errorMessages.push(`Warning: parameter "${rawParam.name}" of method "${sourceData.name}" has no doc text.`);
}
let param = new ParamInfo(rawParam);
this.params.push(param);
paramStrings.push(param.combined);
});
}
this.signature = "(" + paramStrings.join(", ") + ")";
}
get errors() {
return this.errorMessages;
}
}
export class ComponentInfo {
properties: PropInfo[];
methods: MethodSigInfo[];
hasInputs: boolean;
hasOutputs: boolean;
hasMethods: boolean;
sourcePath: string;
sourceLine: number;
/*
constructor(classRef: DeclarationReflection) {
let props = classRef.getChildrenByKind(ReflectionKind.Property);
let accessors = classRef.getChildrenByKind(ReflectionKind.Accessor);
this.properties = [...props, ...accessors].map(item => {
return new PropInfo(item);
});
let methods = classRef.getChildrenByKind(ReflectionKind.Method);
this.methods = [];
methods.forEach(method =>{
if (!(method.flags.isPrivate || method.flags.isProtected || undocMethodNames[method.name])) {
method.signatures.forEach(sig => {
this.methods.push(new MethodSigInfo(sig));
});
}
});
this.hasInputs = false;
this.hasOutputs = false;
this.properties.forEach(prop => {
if (prop.isInput)
this.hasInputs = true;
if (prop.isOutput)
this.hasOutputs = true;
});
this.hasMethods = methods.length > 0;
}
*/
constructor(sourceData) {
this.hasInputs = false;
this.hasOutputs = false;
this.hasMethods = false;
this.sourcePath = sourceData.items[0].source.path;
this.sourceLine = sourceData.items[0].source.line;
this.properties = [];
this.methods = [];
sourceData.items.forEach(item => {
switch(item.type) {
case "property":
var prop = new PropInfo(item);
this.properties.push(prop);
if (prop.isInput) {
this.hasInputs = true;
}
if (prop.isOutput) {
this.hasOutputs = true;
}
break;
case "method":
if (item.flags && (item.flags.length > 0) &&
!item.flags.find(flag => flag.name === "isPrivate") &&
!item.flags.find(flag => flag.name === "isProtected") &&
!undocMethodNames[item.name]
) {
this.methods.push(new MethodSigInfo(item));
this.hasMethods = true;
}
break;
default:
break;
}
});
}
get errors() {
let combinedErrors = [];
this.methods.forEach(method => {
method.errors.forEach(err => {
combinedErrors.push(err);
})
});
this.properties.forEach(prop => {
prop.errors.forEach(err => {
combinedErrors.push(err);
});
});
return combinedErrors;
}
}
+54
View File
@@ -0,0 +1,54 @@
var fs = require("fs");
var path = require("path");
var ejs = require("ejs");
var templateFolder = path.resolve("tools", "doc", "yamlTemplates");
var outputFolder = path.resolve("docs", "sourceinfo");
if (process.argv.length < 3) {
console.log("Error: Source filename required");
process.exit();
}
console.log(`Processing ${process.argv[2]}`);
if (!fs.existsSync(outputFolder)) {
fs.mkdirSync(outputFolder);
}
var docData = JSON.parse(fs.readFileSync(path.resolve(process.argv[2]), "utf8"));
var tempFilename = path.resolve(templateFolder, "template.ejs");
var tempSource = fs.readFileSync(tempFilename, "utf8");
var template = ejs.compile(
tempSource,
{
filename: tempFilename,
cache: true
}
);
searchItemsRecursively(docData);
function searchItemsRecursively(item) {
if (interestedIn(item.kind)) {
processItem(item);
} else if (item.children) {
item.children.forEach(child => {
searchItemsRecursively(child);
});
}
}
function interestedIn(itemKind) {
return itemKind === 128;
}
function processItem(item) {
//console.log(`Generating ${item.name}`);
var docText = template(item);
fs.writeFileSync(path.resolve(outputFolder, item.name + ".yml"), docText);
}
+92 -20
View File
@@ -1,7 +1,9 @@
var fs = require("fs");
var path = require("path");
var program = require("commander");
var lodash = require("lodash");
var jsyaml = require("js-yaml");
var remark = require("remark");
var parse = require("remark-parse");
@@ -9,6 +11,10 @@ var stringify = require("remark-stringify");
var frontMatter = require("remark-frontmatter");
var mdCompact = require("mdast-util-compact");
var tdoc = require("typedoc");
var ngHelpers = require("./ngHelpers");
var si = require("./SourceInfoClasses");
// "Aggregate" data collected over the whole file set.
var aggData = {};
@@ -16,30 +22,15 @@ var aggData = {};
var toolsFolderName = "tools";
var configFileName = "doctool.config.json";
var defaultFolder = path.resolve("docs");
var sourceInfoFolder = path.resolve("docs", "sourceinfo");
var libFolders = ["core", "content-services", "process-services", "insights"];
/*
function initPhase(aggData) {
toolList.forEach(toolName => {
toolModules[toolName].initPhase(aggData);
});
}
var excludePatterns = [
"**/*.spec.ts"
];
function readPhase(mdCache, aggData) {
toolList.forEach(toolName => {
toolModules[toolName].readPhase(mdCache, aggData);
});
}
function aggPhase(aggData) {
toolList.forEach(toolName => {
toolModules[toolName].aggPhase(aggData);
});
}
*/
function updatePhase(mdCache, aggData) {
var errorMessages;
@@ -149,6 +140,82 @@ function initMdCache(filenames) {
}
function getSourceInfo(infoFolder) {
var sourceInfo = {};
var yamlFiles = fs.readdirSync(infoFolder);
yamlFiles.forEach(file => {
var yamlText = fs.readFileSync(path.resolve(infoFolder, file), "utf8");
var yaml = jsyaml.safeLoad(yamlText);
sou
});
}
function initSourceInfo(aggData, mdCache) {
var app = new tdoc.Application({
exclude: excludePatterns,
ignoreCompilerErrors: true,
experimentalDecorators: true,
tsconfig: "tsconfig.json"
});
let sources = app.expandInputFiles(libFolders.map(folder => {
return path.resolve("lib", folder);
}));
aggData.projData = app.convert(sources);
aggData.classInfo = {};
var mdFiles = Object.keys(mdCache);
mdFiles.forEach(mdFile => {
/*
var className = ngHelpers.ngNameToClassName(path.basename(mdFile, ".md"), aggData.config.typeNameExceptions);
var classRef = aggData.projData.findReflectionByName(className);
*/
var className = ngHelpers.ngNameToClassName(path.basename(mdFile, ".md"), aggData.config.typeNameExceptions);
var yamlText = fs.readFileSync(path.resolve(sourceInfoFolder, className + ".yml"), "utf8");
var yaml = jsyaml.safeLoad(yamlText);
if (yaml) {
aggData.classInfo[className] = new si.ComponentInfo(yaml);
}
/*
if (classRef) {
aggData.classInfo[className] = new si.ComponentInfo(classRef);
}
*/
});
}
function initClassInfo(aggData) {
var yamlFilenames = fs.readdirSync(path.resolve(sourceInfoFolder));
aggData.classInfo = {};
yamlFilenames.forEach(yamlFilename => {
var classYamlText = fs.readFileSync(path.resolve(sourceInfoFolder, yamlFilename), "utf8");
var classYaml = jsyaml.safeLoad(classYamlText);
if (program.verbose) {
console.log(classYaml.items[0].name);
}
aggData.classInfo[classYaml.items[0].name] = new si.ComponentInfo(classYaml);
});
}
program
.usage("[options] <source>")
.option("-p, --profile [profileName]", "Select named config profile", "default")
@@ -206,6 +273,11 @@ files = files.filter(filename =>
var mdCache = initMdCache(files);
console.log("Loading source data...");
//initSourceInfo(aggData, mdCache);
initClassInfo(aggData);
/*
console.log("Initialising...");
initPhase(aggData);
+4 -1
View File
@@ -51,7 +51,10 @@
"text-mask.component": "InputMaskDirective",
"card-item-types.service": "CardItemTypeService",
"create-task-attachment.component": "AttachmentComponent",
"process-list.component": "ProcessInstanceListComponent"
"process-list.component": "ProcessInstanceListComponent",
"inherited-button.directive": "InheritPermissionDirective",
"node-share.directive": "NodeSharedDirective",
"sites-dropdown.component": "DropdownSitesComponent"
},
"undocStoplist": [
"model",
+32
View File
@@ -1,5 +1,6 @@
module.exports = {
"ngNameToDisplayName": ngNameToDisplayName,
"ngNameToClassName": ngNameToClassName,
"dekebabifyName": dekebabifyName,
"kebabifyClassName": kebabifyClassName,
"classTypes": ["component", "directive", "model", "pipe", "service", "widget"]
@@ -13,6 +14,37 @@ function ngNameToDisplayName(ngName) {
}
function initialCap(str) {
return str[0].toUpperCase() + str.substr(1);
}
function ngNameToClassName(rawName, nameExceptions) {
if (nameExceptions[rawName])
return nameExceptions[rawName];
var name = rawName.replace(/\]|\(|\)/g, '');
var fileNameSections = name.split('.');
var compNameSections = fileNameSections[0].split('-');
var outCompName = '';
for (var i = 0; i < compNameSections.length; i++) {
outCompName = outCompName + initialCap(compNameSections[i]);
}
var itemTypeIndicator = '';
if (fileNameSections.length > 1) {
itemTypeIndicator = initialCap(fileNameSections[1]);
}
var finalName = outCompName + itemTypeIndicator;
return finalName;
}
function displayNameToNgName(name) {
var noSpaceName = ngName.replace(/ ([a-zA-Z])/, "$1".toUpperCase());
return noSpaceName.substr(0, 1).toUpperCase() + noSpaceName.substr(1);
+29 -170
View File
@@ -9,17 +9,16 @@ var remark = require("remark");
var ejs = require("ejs");
var typedoc_1 = require("typedoc");
var mdNav_1 = require("../mdNav");
var ngHelpers_1 = require("../ngHelpers");
var libFolders = ["core", "content-services", "process-services", "insights"];
var templateFolder = path.resolve("tools", "doc", "templates");
var excludePatterns = [
"**/*.spec.ts"
];
var nameExceptions;
var undocMethodNames = {
"ngOnChanges": 1
};
function processDocs(mdCache, aggData, _errorMessages) {
initPhase(aggData);
//initPhase(aggData);
nameExceptions = aggData.config.typeNameExceptions;
var pathnames = Object.keys(mdCache);
var internalErrors;
pathnames.forEach(function (pathname) {
@@ -38,164 +37,6 @@ function showErrors(filename, errorMessages) {
});
console.log("");
}
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();
this.defaultValue = rawProp.defaultValue || "";
this.defaultValue = this.defaultValue.replace(/\|/, "\\|");
this.type = rawProp.type ? rawProp.type.toString().replace(/\s/g, "") : "";
this.type = this.type.replace(/\|/, "\\|");
this.isDeprecated = rawProp.comment && rawProp.comment.hasTag("deprecated");
if (this.isDeprecated) {
this.docText = "(**Deprecated:** " + rawProp.comment.getTag("deprecated").text.replace(/[\n\r]+/g, " ").trim() + ") " + this.docText;
}
if (rawProp.decorators) {
rawProp.decorators.forEach(function (dec) {
//console.log(dec);
if (dec.name === "Input") {
_this.isInput = true;
if (dec.arguments) {
var bindingName = dec.arguments["bindingPropertyName"];
if (bindingName && (bindingName !== ""))
_this.name = bindingName.replace(/['"]/g, "");
}
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) {
_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;
}());
;
var ParamInfo = /** @class */ (function () {
function ParamInfo(rawParam) {
this.name = rawParam.name;
this.type = rawParam.type.toString().replace(/\s/g, "");
this.defaultValue = rawParam.defaultValue;
this.docText = rawParam.comment ? rawParam.comment.text : "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
this.isOptional = rawParam.flags.isOptional;
this.combined = this.name;
if (this.isOptional)
this.combined += "?";
this.combined += ": `" + this.type + "`";
if (this.defaultValue !== "")
this.combined += " = `" + this.defaultValue + "`";
}
return ParamInfo;
}());
var MethodSigInfo = /** @class */ (function () {
function MethodSigInfo(rawSig) {
var _this = this;
this.errorMessages = [];
this.name = rawSig.name;
this.returnType = rawSig.type ? rawSig.type.toString().replace(/\s/g, "") : "";
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) {
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") {
this.returnsSomething = false;
}
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) {
_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);
});
}
this.signature = "(" + paramStrings.join(", ") + ")";
}
Object.defineProperty(MethodSigInfo.prototype, "errors", {
get: function () {
return this.errorMessages;
},
enumerable: true,
configurable: true
});
return MethodSigInfo;
}());
var ComponentInfo = /** @class */ (function () {
function ComponentInfo(classRef) {
var _this = this;
var props = classRef.getChildrenByKind(typedoc_1.ReflectionKind.Property);
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);
this.methods = [];
methods.forEach(function (method) {
if (!(method.flags.isPrivate || method.flags.isProtected || undocMethodNames[method.name])) {
method.signatures.forEach(function (sig) {
_this.methods.push(new MethodSigInfo(sig));
});
}
});
this.hasInputs = false;
this.hasOutputs = false;
this.properties.forEach(function (prop) {
if (prop.isInput)
_this.hasInputs = true;
if (prop.isOutput)
_this.hasOutputs = true;
});
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) {
nameExceptions = aggData.config.typeNameExceptions;
var app = new typedoc_1.Application({
@@ -210,15 +51,21 @@ function initPhase(aggData) {
aggData.projData = app.convert(sources);
}
function updateFile(tree, pathname, aggData, errorMessages) {
var compName = angNameToClassName(path.basename(pathname, ".md"));
var classRef = aggData.projData.findReflectionByName(compName);
/*
let compName = angNameToClassName(path.basename(pathname, ".md"));
let classRef = aggData.projData.findReflectionByName(compName);
if (!classRef) {
// A doc file with no corresponding class (eg, Document Library Model).
return false;
}
var compData = new ComponentInfo(classRef);
var classTypeMatch = compName.match(/component|directive|service/i);
if (classTypeMatch) {
let compData = new ComponentInfo(classRef);
*/
var className = ngHelpers_1.ngNameToClassName(path.basename(pathname, ".md"), nameExceptions);
var classTypeMatch = className.match(/component|directive|service/i);
var compData = aggData.classInfo[className];
if (classTypeMatch && compData) {
var classType = classTypeMatch[0].toLowerCase();
// Copy docs back from the .md file when the JSDocs are empty.
var inputMD = getPropDocsFromMD(tree, "Properties", 3);
@@ -245,26 +92,38 @@ function updateFile(tree, pathname, aggData, errorMessages) {
}
return true;
}
function initialCap(str) {
/*
function initialCap(str: string) {
return str[0].toUpperCase() + str.substr(1);
}
function angNameToClassName(rawName) {
function angNameToClassName(rawName: string) {
if (nameExceptions[rawName])
return nameExceptions[rawName];
var name = rawName.replace(/\]|\(|\)/g, '');
var fileNameSections = name.split('.');
var compNameSections = fileNameSections[0].split('-');
var outCompName = '';
for (var i = 0; i < compNameSections.length; i++) {
outCompName = outCompName + initialCap(compNameSections[i]);
}
var itemTypeIndicator = '';
if (fileNameSections.length > 1) {
itemTypeIndicator = initialCap(fileNameSections[1]);
}
var finalName = outCompName + itemTypeIndicator;
return finalName;
}
*/
function getPropDocsFromMD(tree, sectionHeading, docsColumn) {
var result = {};
var nav = new mdNav_1.MDNav(tree);
@@ -358,7 +217,7 @@ function getMDMethodParams(methItem) {
}
var paramDoc = paramListItem.childNav
.paragraph().childNav
.text(function (t) { return true; }, 1).item.value;
.text(function (t) { return true; }, 1).value; //item.value;
result[paramName] = paramDoc.replace(/^[ -]+/, "");
});
return result;
+18 -236
View File
@@ -10,19 +10,14 @@ import * as ejs from "ejs";
import {
Application,
ProjectReflection,
Reflection,
DeclarationReflection,
SignatureReflection,
ParameterReflection,
ReflectionKind,
TraverseProperty,
Decorator
} from "typedoc";
import { CommentTag } from "typedoc/dist/lib/models";
import { MDNav } from "../mdNav";
import * as unist from "../unistHelpers";
import { ngNameToClassName } from "../ngHelpers";
import {
ComponentInfo
} from "../SourceInfoClasses"
let libFolders = ["core", "content-services", "process-services", "insights"];
@@ -35,13 +30,11 @@ let excludePatterns = [
let nameExceptions;
let undocMethodNames = {
"ngOnChanges": 1
};
export function processDocs(mdCache, aggData, _errorMessages) {
initPhase(aggData);
//initPhase(aggData);
nameExceptions = aggData.config.typeNameExceptions;
let pathnames = Object.keys(mdCache);
let internalErrors;
@@ -67,222 +60,6 @@ function showErrors(filename, errorMessages) {
console.log("");
}
class PropInfo {
name: string;
type: string;
typeLink: string;
defaultValue: string;
docText: string;
isInput: boolean;
isOutput: boolean;
isDeprecated: boolean;
errorMessages: string[];
constructor(rawProp: DeclarationReflection) {
this.errorMessages = [];
this.name = rawProp.name;
this.docText = rawProp.comment ? rawProp.comment.shortText : "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
this.defaultValue = rawProp.defaultValue || "";
this.defaultValue = this.defaultValue.replace(/\|/, "\\|");
this.type = rawProp.type ? rawProp.type.toString().replace(/\s/g, "") : "";
this.type = this.type.replace(/\|/, "\\|");
this.isDeprecated = rawProp.comment && rawProp.comment.hasTag("deprecated");
if (this.isDeprecated) {
this.docText = "(**Deprecated:** " + rawProp.comment.getTag("deprecated").text.replace(/[\n\r]+/g, " ").trim() + ") " + this.docText;
}
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"];
if (bindingName && (bindingName !== ""))
this.name = bindingName.replace(/['"]/g, "");
}
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) {
this.errorMessages.push(`Warning: Output "${rawProp.name}" has no doc text.`);
}
}
});
}
}
get errors() {
return this.errorMessages;
}
};
class ParamInfo {
name: string;
type: string;
defaultValue: string;
docText: string;
combined: string;
isOptional: boolean;
constructor(rawParam: ParameterReflection) {
this.name = rawParam.name;
this.type = rawParam.type.toString().replace(/\s/g, "");
this.defaultValue = rawParam.defaultValue;
this.docText = rawParam.comment ? rawParam.comment.text : "";
this.docText = this.docText.replace(/[\n\r]+/g, " ").trim();
this.isOptional = rawParam.flags.isOptional;
this.combined = this.name;
if (this.isOptional)
this.combined += "?";
this.combined += `: \`${this.type}\``;
if (this.defaultValue !== "")
this.combined += ` = \`${this.defaultValue}\``;
}
}
class MethodSigInfo {
name: string;
docText: string;
returnType: string;
returnDocText: string;
returnsSomething: boolean;
signature: string;
params: ParamInfo[];
isDeprecated: boolean;
errorMessages: string[];
constructor(rawSig: SignatureReflection) {
this.errorMessages = [];
this.name = rawSig.name;
this.returnType = rawSig.type ? rawSig.type.toString().replace(/\s/g, "") : "";
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) {
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") {
this.returnsSomething = false;
}
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 = [];
let paramStrings = [];
if (rawSig.parameters) {
rawSig.parameters.forEach(rawParam => {
if (!rawParam.comment || !rawParam.comment.text) {
this.errorMessages.push(`Warning: parameter "${rawParam.name}" of method "${rawSig.name}" has no doc text.`);
}
let param = new ParamInfo(rawParam);
this.params.push(param);
paramStrings.push(param.combined);
});
}
this.signature = "(" + paramStrings.join(", ") + ")";
}
get errors() {
return this.errorMessages;
}
}
class ComponentInfo {
properties: PropInfo[];
methods: MethodSigInfo[];
hasInputs: boolean;
hasOutputs: boolean;
hasMethods: boolean;
constructor(classRef: DeclarationReflection) {
let props = classRef.getChildrenByKind(ReflectionKind.Property);
let accessors = classRef.getChildrenByKind(ReflectionKind.Accessor);
this.properties = [...props, ...accessors].map(item => {
return new PropInfo(item);
});
let methods = classRef.getChildrenByKind(ReflectionKind.Method);
this.methods = [];
methods.forEach(method =>{
if (!(method.flags.isPrivate || method.flags.isProtected || undocMethodNames[method.name])) {
method.signatures.forEach(sig => {
this.methods.push(new MethodSigInfo(sig));
});
}
});
this.hasInputs = false;
this.hasOutputs = false;
this.properties.forEach(prop => {
if (prop.isInput)
this.hasInputs = true;
if (prop.isOutput)
this.hasOutputs = true;
});
this.hasMethods = methods.length > 0;
}
get errors() {
let combinedErrors = [];
this.methods.forEach(method => {
method.errors.forEach(err => {
combinedErrors.push(err);
})
});
this.properties.forEach(prop => {
prop.errors.forEach(err => {
combinedErrors.push(err);
});
});
return combinedErrors;
}
}
function initPhase(aggData) {
@@ -306,6 +83,7 @@ function initPhase(aggData) {
function updateFile(tree, pathname, aggData, errorMessages) {
/*
let compName = angNameToClassName(path.basename(pathname, ".md"));
let classRef = aggData.projData.findReflectionByName(compName);
@@ -315,9 +93,13 @@ function updateFile(tree, pathname, aggData, errorMessages) {
}
let compData = new ComponentInfo(classRef);
let classTypeMatch = compName.match(/component|directive|service/i);
*/
if (classTypeMatch) {
let className = ngNameToClassName(path.basename(pathname, ".md"), nameExceptions);
let classTypeMatch = className.match(/component|directive|service/i);
let compData = aggData.classInfo[className];
if (classTypeMatch && compData) {
let classType = classTypeMatch[0].toLowerCase();
// Copy docs back from the .md file when the JSDocs are empty.
@@ -353,7 +135,7 @@ function updateFile(tree, pathname, aggData, errorMessages) {
return true;
}
/*
function initialCap(str: string) {
return str[0].toUpperCase() + str.substr(1);
}
@@ -384,7 +166,7 @@ function angNameToClassName(rawName: string) {
return finalName;
}
*/
function getPropDocsFromMD(tree, sectionHeading, docsColumn) {
let result = {}
@@ -512,7 +294,7 @@ function getMDMethodParams(methItem: MDNav) {
let paramDoc = paramListItem.childNav
.paragraph().childNav
.text(t=>true, 1).item.value;
.text(t=>true, 1).value; //item.value;
result[paramName] = paramDoc.replace(/^[ -]+/, "");
});
+41 -12
View File
@@ -2,7 +2,20 @@
Object.defineProperty(exports, "__esModule", { value: true });
var path = require("path");
var fs = require("fs");
var typedoc_1 = require("typedoc");
/*
import {
Application,
ProjectReflection,
Reflection,
DeclarationReflection,
SignatureReflection,
ParameterReflection,
ReflectionKind,
TraverseProperty,
Decorator
} from "typedoc";
import { CommentTag } from "typedoc/dist/lib/models";
*/
var ProgressBar = require("progress");
var unist = require("../unistHelpers");
var ngHelpers = require("../ngHelpers");
@@ -44,15 +57,24 @@ function initPhase(aggData) {
}
});
});
var classes = aggData.projData.getReflectionsByKind(typedoc_1.ReflectionKind.Class);
classes.forEach(function (currClass) {
/*
let classes = aggData.projData.getReflectionsByKind(ReflectionKind.Class);
classes.forEach(currClass => {
if (currClass.name.match(/(Component|Directive|Interface|Model|Pipe|Service|Widget)$/)) {
aggData.nameLookup.addName(currClass.name);
}
});
*/
var classNames = Object.keys(aggData.classInfo);
classNames.forEach(function (currClassName) {
if (currClassName.match(/(Component|Directive|Interface|Model|Pipe|Service|Widget)$/)) {
aggData.nameLookup.addName(currClassName);
}
});
//console.log(JSON.stringify(aggData.nameLookup));
}
function updateFile(tree, pathname, aggData, errorMessages) {
function updateFile(tree, pathname, aggData, _errorMessages) {
traverseMDTree(tree);
return true;
function traverseMDTree(node) {
@@ -290,11 +312,16 @@ function resolveTypeLink(aggData, text) {
if (possTypeName === 'constructor') {
return "";
}
var ref = aggData.projData.findReflectionByName(possTypeName);
if (ref && isLinkable(ref.kind)) {
/*
let ref: Reflection = aggData.projData.findReflectionByName(possTypeName);
*/
var classInfo = aggData.classInfo[possTypeName];
//if (ref && isLinkable(ref.kind)) {
if (classInfo) {
var kebabName = ngHelpers.kebabifyClassName(possTypeName);
var possDocFile = aggData.docFiles[kebabName];
var url = "../../lib/" + ref.sources[0].fileName;
//let url = "../../lib/" + ref.sources[0].fileName;
var url = classInfo.sourcePath; //"../../lib/" + classInfo.items[0].source.path;
if (possDocFile) {
url = "../" + possDocFile;
}
@@ -316,12 +343,14 @@ function cleanTypeName(text) {
return text.replace(/\[\]$/, "");
}
}
function isLinkable(kind) {
return (kind === typedoc_1.ReflectionKind.Class) ||
(kind === typedoc_1.ReflectionKind.Interface) ||
(kind === typedoc_1.ReflectionKind.Enum) ||
(kind === typedoc_1.ReflectionKind.TypeAlias);
/*
function isLinkable(kind: ReflectionKind) {
return (kind === ReflectionKind.Class) ||
(kind === ReflectionKind.Interface) ||
(kind === ReflectionKind.Enum) ||
(kind === ReflectionKind.TypeAlias);
}
*/
function convertNodeToTypeLink(node, text, url, title) {
if (title === void 0) { title = null; }
var linkDisplayText = unist.makeInlineCode(text);
+24 -5
View File
@@ -1,10 +1,12 @@
import * as path from "path";
import * as fs from "fs";
import * as remark from "remark";
import * as stringify from "remark-stringify";
import * as frontMatter from "remark-frontmatter";
/*
import {
Application,
ProjectReflection,
@@ -17,6 +19,7 @@ import {
Decorator
} from "typedoc";
import { CommentTag } from "typedoc/dist/lib/models";
*/
import * as ProgressBar from "progress";
@@ -74,6 +77,7 @@ function initPhase(aggData) {
});
});
/*
let classes = aggData.projData.getReflectionsByKind(ReflectionKind.Class);
classes.forEach(currClass => {
@@ -81,14 +85,22 @@ function initPhase(aggData) {
aggData.nameLookup.addName(currClass.name);
}
});
*/
let classNames = Object.keys(aggData.classInfo);
classNames.forEach(currClassName => {
if (currClassName.match(/(Component|Directive|Interface|Model|Pipe|Service|Widget)$/)) {
aggData.nameLookup.addName(currClassName);
}
});
//console.log(JSON.stringify(aggData.nameLookup));
}
function updateFile(tree, pathname, aggData, errorMessages) {
function updateFile(tree, pathname, aggData, _errorMessages) {
traverseMDTree(tree);
return true;
@@ -363,13 +375,19 @@ function resolveTypeLink(aggData, text): string {
return "";
}
/*
let ref: Reflection = aggData.projData.findReflectionByName(possTypeName);
*/
let classInfo = aggData.classInfo[possTypeName];
if (ref && isLinkable(ref.kind)) {
//if (ref && isLinkable(ref.kind)) {
if (classInfo) {
let kebabName = ngHelpers.kebabifyClassName(possTypeName);
let possDocFile = aggData.docFiles[kebabName];
let url = "../../lib/" + ref.sources[0].fileName;
//let url = "../../lib/" + ref.sources[0].fileName;
let url = classInfo.sourcePath; //"../../lib/" + classInfo.items[0].source.path;
if (possDocFile) {
url = "../" + possDocFile;
}
@@ -393,13 +411,14 @@ function cleanTypeName(text) {
}
}
/*
function isLinkable(kind: ReflectionKind) {
return (kind === ReflectionKind.Class) ||
(kind === ReflectionKind.Interface) ||
(kind === ReflectionKind.Enum) ||
(kind === ReflectionKind.TypeAlias);
}
*/
function convertNodeToTypeLink(node, text, url, title = null) {
let linkDisplayText = unist.makeInlineCode(text);
+35
View File
@@ -0,0 +1,35 @@
summary: >-
<%- ((typeof sig.comment !== "undefined") && (typeof sig.comment.shortText !== "undefined")) ? (sig.comment.shortText || "").replace(/[\n\r]+/g, " ").trim() : "" %>
tags:
<% if ((typeof sig.comment !== "undefined") && (typeof sig.comment.tags !== "undefined")) { -%>
<% sig.comment.tags.forEach(tag => { -%>
- name: <%= tag.tag %>
text: >-
<%= (tag.text || "").replace(/[\n\r]+/g, " ").trim() %>
<% }) -%>
<% } -%>
syntax:
parameters:
<% if ((typeof sig.parameters !== "undefined") && (sig.parameters.length > 0)) { -%>
<% sig.parameters.forEach((param) => { -%>
- id: <%= param.name %>
type: >-
<%- include("type", {type: param.type}).trim() %>
description: >-
<%- param.comment ? (param.comment.text || "").replace(/[\n\r]+/g, " ").trim() : "" %>
defaultValue: >-
<%- (typeof param.defaultValue !== "undefined") ? param.defaultValue : "" %>
flags:
<%_ if (typeof param.flags !== "undefined") { -%>
<%_ Object.keys(param.flags).forEach(flagName => { -%>
- name: <%= flagName %>
value: <%- param.flags[flagName] %>
<% }) -%>
<% } -%>
<% }) -%>
<% } -%>
return:
type: >-
<%- include("type", {type: sig.type}).trim() %>
summary: >-
<%- ((typeof sig.comment !== "undefined") && (typeof sig.comment.returns !== "undefined")) ? (sig.comment.returns || "").replace(/[\n\r]+/g, " ").trim() : "" %>
+27
View File
@@ -0,0 +1,27 @@
summary: >-
<%- (typeof child.comment !== "undefined") ? (child.comment.shortText || "").replace(/[\n\r]+/g, " ").trim() : "" %>
tags:
<%_ if ((typeof child.comment !== "undefined") && (typeof child.comment.tags !== "undefined")) { -%>
<% child.comment.tags.forEach(tag => { -%>
- name: <%= tag.tag %>
text: >-
<%- (tag.text || "").replace(/[\n\r]+/g, " ").trim() %>
<%_ }) -%>
<% } -%>
decorators:
<%_ if (typeof child.decorators !== "undefined") { -%>
<% child.decorators.forEach(dec => { -%>
- name: <%= dec.name %>
arguments:
<% Object.keys(dec.arguments).forEach(argName => { -%>
- id: <%= argName %>
value: <%- dec.arguments[argName] %>
<% }) %>
<%_ }) -%>
<% } -%>
syntax:
return:
type: >-
<%- include("type", {type: child.type}).trim() %>
defaultValue: >-
<%- (child.defaultValue || "").length < 20 ? child.defaultValue : "" %>
+44
View File
@@ -0,0 +1,44 @@
items:
- uid: <%= name %>
name: <%= name %>
fullName: <%= name %>
source:
path: <%= sources[0].fileName %>
startLine: <%= sources[0].line %>
children:
<%_ if (typeof children !== "undefined") { -%>
<%_ children.forEach((child) => { -%>
- <%= name %>.<%= child.name %>
<% }) -%>
<% } -%>
langs: typeScript
type: <%= kindString.toLowerCase() %>
<%_ if (typeof children !== "undefined") { -%>
<%_ children.forEach((child) => { -%>
<%_ if ((child.kindString === "Constructor") || (child.kindString === "Method")) { -%>
<%_ child.signatures.forEach((sig) => { -%>
- uid: <%= name %>.<%= child.name %>
name: <%= child.name %>
type: <%= child.kindString.toLowerCase() %>
flags:
<%_ if (typeof child.flags !== "undefined") { -%>
<%_ Object.keys(child.flags).forEach(flagName => { -%>
- name: <%= flagName %>
value: <%= child.flags[flagName] %>
<% }) -%>
<% } -%>
<%- include("methodSig", {sig: sig}); -%>
<% }); %>
<% } else if (child.kindString === "Property") { -%>
- uid: <%= name %>.<%= child.name %>
name: <%= child.name %>
type: <%= child.kindString.toLowerCase() %>
<%- include("property", {child: child}); -%>
<% } else if ((child.kindString === "Accessor") && (typeof child.getSignature !== "undefined")) { -%>
- uid: <%= name %>.<%= child.name %>
name: <%= child.name %>
type: <%= child.kindString.toLowerCase() %>
<%- include("property", {child: child.getSignature}); -%>
<% } -%>
<% }) -%>
<% } -%>
+20
View File
@@ -0,0 +1,20 @@
<%_ if ((type.type === "intrinsic") || (type.type === "reference")) { _%>
<%= type.name _%>
<%_ if (typeof type.typeArguments !== "undefined") { _%>
<<%_ type.typeArguments.forEach((arg, index) => { _%>
<%= index === 0 ? "" : ", " _%>
<%- include("type", {type: arg}).trim() _%>
<%_ }) _%>>
<%_ } _%>
<%_ } else if (type.type === "stringLiteral") { _%>
"<%= type.value _%>"
<%_ } else if (type.type === "reflection") { _%>
Function
<%_ } else if (type.type === "array") { _%>
<%- include("type", {type: type.elementType}).trim() _%>[]
<%_ } else if (type.type === "union") { _%>
<%_ type.types.forEach((unionItem, index) => { _%>
<%= index === 0 ? "" : " | " _%>
<%- include("type", {type: unionItem}).trim() _%>
<%_ }) _%>
<%_ } _%>