[ADF-3203] Fixed doc tools bugs from Linux run and added verbose option (#3496)

This commit is contained in:
Andy Stark
2018-06-18 10:27:51 +01:00
committed by Eugenio Romano
parent 257e422a1c
commit 5b3fb4856d
5 changed files with 24 additions and 15 deletions

View File

@@ -53,6 +53,10 @@ function updatePhase(filenames, aggData) {
errorMessages = []; errorMessages = [];
var pathname = filenames[i]; // path.resolve(srcFolder, filenames[i]); var pathname = filenames[i]; // path.resolve(srcFolder, filenames[i]);
if (program.verbose) {
console.log(pathname);
}
var src = fs.readFileSync(pathname); var src = fs.readFileSync(pathname);
var tree = remark().use(frontMatter, ["yaml"]).parse(src) var tree = remark().use(frontMatter, ["yaml"]).parse(src)
@@ -132,6 +136,7 @@ program
.usage("[options] <source>") .usage("[options] <source>")
.option("-p, --profile [profileName]", "Select named config profile", "default") .option("-p, --profile [profileName]", "Select named config profile", "default")
.option("-j, --json", "Output JSON data for Markdown syntax tree") .option("-j, --json", "Output JSON data for Markdown syntax tree")
.option("-v, --verbose", "Log doc files as they are processed")
.parse(process.argv); .parse(process.argv);
var sourcePath; var sourcePath;

View File

@@ -165,7 +165,7 @@ var MDNav = /** @class */ (function () {
return this.item.value; return this.item.value;
} }
else { else {
return undefined; return "";
} }
}, },
enumerable: true, enumerable: true,

View File

@@ -157,7 +157,7 @@ export class MDNav {
if (this.item && this.item["value"]) { if (this.item && this.item["value"]) {
return this.item.value; return this.item.value;
} else { } else {
return undefined; return "";
} }
} }
} }

View File

@@ -4,6 +4,8 @@ var fs = require("fs");
var path = require("path"); var path = require("path");
var replaceSection = require("mdast-util-heading-range"); var replaceSection = require("mdast-util-heading-range");
var remark = require("remark"); var remark = require("remark");
// import * as stringify from "remark-stringify";
// import * as frontMatter from "remark-frontmatter";
var ejs = require("ejs"); var ejs = require("ejs");
var typedoc_1 = require("typedoc"); var typedoc_1 = require("typedoc");
var mdNav_1 = require("../mdNav"); var mdNav_1 = require("../mdNav");
@@ -202,8 +204,9 @@ function updatePhase(tree, pathname, aggData, errorMessages) {
return false; return false;
} }
var compData = new ComponentInfo(classRef); var compData = new ComponentInfo(classRef);
var classType = compName.match(/component|directive|service/i); var classTypeMatch = compName.match(/component|directive|service/i);
if (classType) { if (classTypeMatch) {
var classType = classTypeMatch[0].toLowerCase();
// Copy docs back from the .md file when the JSDocs are empty. // Copy docs back from the .md file when the JSDocs are empty.
var inputMD = getPropDocsFromMD(tree, "Properties", 3); var inputMD = getPropDocsFromMD(tree, "Properties", 3);
var outputMD = getPropDocsFromMD(tree, "Events", 2); var outputMD = getPropDocsFromMD(tree, "Events", 2);
@@ -305,7 +308,7 @@ function getMethodDocsFromMD(tree) {
var methDoc = methItem.childNav var methDoc = methItem.childNav
.paragraph().childNav .paragraph().childNav
.html() .html()
.text().item.value; .text().value;
var params = getMDMethodParams(methItem); var params = getMDMethodParams(methItem);
result[methName] = { result[methName] = {
"docText": methDoc.replace(/^\n/, ""), "docText": methDoc.replace(/^\n/, ""),
@@ -368,12 +371,12 @@ function updateMethodDocsFromMD(comp, methodDocs, errorMessages) {
comp.methods.forEach(function (meth) { comp.methods.forEach(function (meth) {
var currMethMD = methodDocs[meth.name]; var currMethMD = methodDocs[meth.name];
// If JSDocs are empty but MD docs aren't then the Markdown is presumably more up-to-date. // If JSDocs are empty but MD docs aren't then the Markdown is presumably more up-to-date.
if (!meth.docText && currMethMD.docText) { if (!meth.docText && currMethMD && currMethMD.docText) {
meth.docText = currMethMD.docText; meth.docText = currMethMD.docText;
errorMessages.push("Warning: empty JSDocs for method sig \"" + meth.name + "\" may need sync with the .md file."); errorMessages.push("Warning: empty JSDocs for method sig \"" + meth.name + "\" may need sync with the .md file.");
} }
meth.params.forEach(function (param) { meth.params.forEach(function (param) {
if (!param.docText && currMethMD.params[param.name]) { if (!param.docText && currMethMD && currMethMD.params[param.name]) {
param.docText = currMethMD.params[param.name]; param.docText = currMethMD.params[param.name];
errorMessages.push("Warning: empty JSDocs for parameter \"" + param.name + " (" + meth.name + ")\" may need sync with the .md file."); errorMessages.push("Warning: empty JSDocs for parameter \"" + param.name + " (" + meth.name + ")\" may need sync with the .md file.");
} }

View File

@@ -3,10 +3,9 @@ import * as path from "path";
import * as replaceSection from "mdast-util-heading-range"; import * as replaceSection from "mdast-util-heading-range";
import * as remark from "remark"; import * as remark from "remark";
import * as stringify from "remark-stringify"; // import * as stringify from "remark-stringify";
import * as frontMatter from "remark-frontmatter"; // import * as frontMatter from "remark-frontmatter";
import * as combyne from "combyne";
import * as ejs from "ejs"; import * as ejs from "ejs";
import { import {
@@ -295,9 +294,11 @@ export function updatePhase(tree, pathname, aggData, errorMessages) {
} }
let compData = new ComponentInfo(classRef); let compData = new ComponentInfo(classRef);
let classType = compName.match(/component|directive|service/i); let classTypeMatch = compName.match(/component|directive|service/i);
if (classTypeMatch) {
let classType = classTypeMatch[0].toLowerCase();
if (classType) {
// Copy docs back from the .md file when the JSDocs are empty. // Copy docs back from the .md file when the JSDocs are empty.
let inputMD = getPropDocsFromMD(tree, "Properties", 3); let inputMD = getPropDocsFromMD(tree, "Properties", 3);
let outputMD = getPropDocsFromMD(tree, "Events", 2); let outputMD = getPropDocsFromMD(tree, "Events", 2);
@@ -440,7 +441,7 @@ function getMethodDocsFromMD(tree) {
let methDoc = methItem.childNav let methDoc = methItem.childNav
.paragraph().childNav .paragraph().childNav
.html() .html()
.text().item.value; .text().value;
let params = getMDMethodParams(methItem); let params = getMDMethodParams(methItem);
@@ -523,13 +524,13 @@ function updateMethodDocsFromMD(comp: ComponentInfo, methodDocs, errorMessages)
let currMethMD = methodDocs[meth.name] let currMethMD = methodDocs[meth.name]
// If JSDocs are empty but MD docs aren't then the Markdown is presumably more up-to-date. // If JSDocs are empty but MD docs aren't then the Markdown is presumably more up-to-date.
if (!meth.docText && currMethMD.docText) { if (!meth.docText && currMethMD && currMethMD.docText) {
meth.docText = currMethMD.docText; meth.docText = currMethMD.docText;
errorMessages.push(`Warning: empty JSDocs for method sig "${meth.name}" may need sync with the .md file.`); errorMessages.push(`Warning: empty JSDocs for method sig "${meth.name}" may need sync with the .md file.`);
} }
meth.params.forEach(param => { meth.params.forEach(param => {
if (!param.docText && currMethMD.params[param.name]) if (!param.docText && currMethMD && currMethMD.params[param.name])
{ {
param.docText = currMethMD.params[param.name]; param.docText = currMethMD.params[param.name];
errorMessages.push(`Warning: empty JSDocs for parameter "${param.name} (${meth.name})" may need sync with the .md file.`); errorMessages.push(`Warning: empty JSDocs for parameter "${param.name} (${meth.name})" may need sync with the .md file.`);