mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2557] Updated doc files with new script and fixed script bugs (#3135)
This commit is contained in:
committed by
Eugenio Romano
parent
9401e77e0c
commit
717dbfb388
23
lib/config/DocProcessor/templates/component.combyne
Normal file
23
lib/config/DocProcessor/templates/component.combyne
Normal file
@@ -0,0 +1,23 @@
|
||||
{% 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 %}
|
@@ -1,17 +0,0 @@
|
||||
{% if hasInputs -%}
|
||||
### Properties
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| -- | -- | -- | -- |
|
||||
{% for prop in properties %}{% if prop.isInput %}| {{prop.name}} | `{{prop.type}}` | {{prop.defaultValue}} | {% if prop.isDeprecated %}(Deprecated) {% endif %}{{prop.docText}} |
|
||||
{% endif %}{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if hasOutputs -%}
|
||||
### Events
|
||||
|
||||
| Name | Type | Description |
|
||||
| -- | -- | -- |
|
||||
{% for prop in properties %}{% if prop.isOutput %}| {{prop.name}} | `{{prop.type}}` | {% if prop.isDeprecated %}(Deprecated) {% endif %}{{prop.docText}} |
|
||||
{% endif %}{% endfor %}
|
||||
{% endif %}
|
14
lib/config/DocProcessor/templates/service.combyne
Normal file
14
lib/config/DocProcessor/templates/service.combyne
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
{% if hasMethods %}
|
||||
### Methods
|
||||
|
||||
{% each methods as meth %}- `{{meth.name}}{{{meth.signature}}{% if meth.returnsSomething %}: {{{meth.returnType}}}{% endif %}`<br/>
|
||||
{{meth.docText}}
|
||||
{% each meth.params as param %}
|
||||
- `{{{param.combined}}}` - {% if param.isOptional %}(Optional){% endif %}{{{param.docText}}}
|
||||
{% endeach %}
|
||||
{% if meth.returnsSomething %}
|
||||
- **Returns** `{{{meth.returnType}}}` - {{{meth.returnDocText}}}
|
||||
{% endif %}
|
||||
{% endeach %}
|
||||
{% endif %}
|
@@ -1,10 +0,0 @@
|
||||
|
||||
{% if hasMethods %}
|
||||
### Methods
|
||||
|
||||
{% for meth in methods %}- `{{meth.name}}{{meth.signature}}: {{meth.returnType}}`<br/>
|
||||
{{meth.docText}}
|
||||
{% for param in meth.params %} - `{{param.combined}}` - {% if param.isOptional %}(Optional){% endif %}{{param.docText}}
|
||||
{% endfor %} - **Returns** `{{meth.returnType}}` - {{meth.returnDocText}}
|
||||
{% endfor %}
|
||||
{% endif %}
|
@@ -4,8 +4,7 @@ var fs = require("fs");
|
||||
var path = require("path");
|
||||
var replaceSection = require("mdast-util-heading-range");
|
||||
var remark = require("remark");
|
||||
var frontMatter = require("remark-frontmatter");
|
||||
var liquid = require("liquidjs");
|
||||
var combyne = require("combyne");
|
||||
var typedoc_1 = require("typedoc");
|
||||
var libFolders = ["core", "content-services", "process-services", "insights"];
|
||||
var templateFolder = path.resolve(".", "config", "DocProcessor", "templates");
|
||||
@@ -25,21 +24,29 @@ var PropInfo = /** @class */ (function () {
|
||||
this.defaultValue = rawProp.defaultValue || "";
|
||||
this.defaultValue = this.defaultValue.replace(/\|/, "\\|");
|
||||
this.type = rawProp.type ? rawProp.type.toString() : "";
|
||||
this.isDeprecated = rawProp.comment && rawProp.comment.hasTag("deprecated");
|
||||
if (this.isDeprecated) {
|
||||
this.docText = "**Deprecated:** " + rawProp.comment.getTag("deprecated").text.replace(/[\n\r]+/g, " ").trim();
|
||||
}
|
||||
if (rawProp.decorators) {
|
||||
rawProp.decorators.forEach(function (dec) {
|
||||
if (dec.name === "Input") {
|
||||
_this.isInput = true;
|
||||
if (!_this.docText)
|
||||
if (dec.arguments) {
|
||||
var bindingName = dec["bindingPropertyName"];
|
||||
if (bindingName && (bindingName !== ""))
|
||||
_this.name = bindingName;
|
||||
}
|
||||
if (!_this.docText && !_this.isDeprecated)
|
||||
console.log("Warning: Input \"" + rawProp.getFullName() + "\" has no doc text.");
|
||||
}
|
||||
if (dec.name === "Output") {
|
||||
_this.isOutput = true;
|
||||
if (!_this.docText)
|
||||
if (!_this.docText && !_this.isDeprecated)
|
||||
console.log("Warning: Output \"" + rawProp.getFullName() + "\" has no doc text.");
|
||||
}
|
||||
});
|
||||
}
|
||||
this.isDeprecated = rawProp.comment && rawProp.comment.hasTag("deprecated");
|
||||
}
|
||||
return PropInfo;
|
||||
}());
|
||||
@@ -66,6 +73,7 @@ var MethodSigInfo = /** @class */ (function () {
|
||||
var _this = this;
|
||||
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();
|
||||
@@ -73,7 +81,9 @@ var MethodSigInfo = /** @class */ (function () {
|
||||
console.log("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)
|
||||
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.");
|
||||
this.isDeprecated = rawSig.comment.hasTag("deprecated");
|
||||
}
|
||||
@@ -125,9 +135,11 @@ function initPhase(aggData) {
|
||||
});
|
||||
var sources = app.expandInputFiles(libFolders);
|
||||
aggData.projData = app.convert(sources);
|
||||
/*
|
||||
aggData.liq = liquid({
|
||||
root: templateFolder
|
||||
});
|
||||
*/
|
||||
}
|
||||
exports.initPhase = initPhase;
|
||||
function readPhase(tree, pathname, aggData) {
|
||||
@@ -142,22 +154,44 @@ function updatePhase(tree, pathname, aggData) {
|
||||
var compData = new ComponentInfo(classRef);
|
||||
var classType = compName.match(/component|directive|service/i);
|
||||
if (classType) {
|
||||
var templateName = classType[0] + ".liquid";
|
||||
var templateName = path.resolve(templateFolder, classType + ".combyne");
|
||||
var templateSource = fs.readFileSync(templateName, "utf8");
|
||||
var template = combyne(templateSource);
|
||||
var mdText = template.render(compData);
|
||||
var newSection_1 = remark().parse(mdText.trim()).children;
|
||||
replaceSection(tree, "Class members", function (before, section, after) {
|
||||
newSection_1.unshift(before);
|
||||
newSection_1.push(after);
|
||||
return newSection_1;
|
||||
});
|
||||
/*
|
||||
let templateName = classType[0] + ".liquid";
|
||||
|
||||
aggData.liq
|
||||
.renderFile(templateName, compData)
|
||||
.then(function (mdText) {
|
||||
var newSection = remark().parse(mdText).children;
|
||||
replaceSection(tree, "Class members", function (before, section, after) {
|
||||
.renderFile(templateName, compData)
|
||||
.then(mdText => {
|
||||
let newSection = remark().parse(mdText).children;
|
||||
replaceSection(tree, "Class members", (before, section, after) => {
|
||||
newSection.unshift(before);
|
||||
newSection.push(after);
|
||||
return newSection;
|
||||
});
|
||||
fs.writeFileSync(pathname, remark().use(frontMatter, { type: 'yaml', fence: '---' }).data("settings", { paddedTable: false }).stringify(tree));
|
||||
|
||||
fs.writeFileSync(pathname, remark().use(frontMatter, {type: 'yaml', fence: '---'}).data("settings", {paddedTable: false}).stringify(tree));
|
||||
|
||||
});
|
||||
*/
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
exports.updatePhase = updatePhase;
|
||||
function renderInputs(comp) {
|
||||
var result = "";
|
||||
comp.properties.forEach(function (prop) {
|
||||
result += "| " + prop.name + " | `" + prop.type + "` | " + prop.defaultValue + " | " + prop.docText + " |\n";
|
||||
});
|
||||
return result;
|
||||
}
|
||||
function initialCap(str) {
|
||||
return str[0].toUpperCase() + str.substr(1);
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import * as replaceSection from "mdast-util-heading-range";
|
||||
import * as remark from "remark";
|
||||
import * as frontMatter from "remark-frontmatter";
|
||||
|
||||
import * as liquid from "liquidjs";
|
||||
import * as combyne from "combyne";
|
||||
|
||||
import {
|
||||
Application,
|
||||
@@ -53,25 +53,40 @@ class PropInfo {
|
||||
this.defaultValue = this.defaultValue.replace(/\|/, "\\|");
|
||||
this.type = rawProp.type ? rawProp.type.toString() : "";
|
||||
|
||||
this.isDeprecated = rawProp.comment && rawProp.comment.hasTag("deprecated");
|
||||
|
||||
if (this.isDeprecated) {
|
||||
this.docText = "**Deprecated:** " + rawProp.comment.getTag("deprecated").text.replace(/[\n\r]+/g, " ").trim();
|
||||
}
|
||||
|
||||
if (rawProp.decorators) {
|
||||
rawProp.decorators.forEach(dec => {
|
||||
if (dec.name === "Input") {
|
||||
this.isInput = true;
|
||||
|
||||
if (!this.docText)
|
||||
/*
|
||||
if (dec.arguments) {
|
||||
let bindingName = dec.arguments["bindingPropertyName"];
|
||||
console.log(JSON.stringify(dec.arguments));
|
||||
|
||||
if (bindingName && (bindingName !== ""))
|
||||
this.name = bindingName;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
if (!this.docText && !this.isDeprecated)
|
||||
console.log(`Warning: Input "${rawProp.getFullName()}" has no doc text.`);
|
||||
}
|
||||
|
||||
if (dec.name === "Output") {
|
||||
this.isOutput = true;
|
||||
|
||||
if (!this.docText)
|
||||
if (!this.docText && !this.isDeprecated)
|
||||
console.log(`Warning: Output "${rawProp.getFullName()}" has no doc text.`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.isDeprecated = rawProp.comment && rawProp.comment.hasTag("deprecated");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -110,6 +125,7 @@ class MethodSigInfo {
|
||||
docText: string;
|
||||
returnType: string;
|
||||
returnDocText: string;
|
||||
returnsSomething: boolean;
|
||||
signature: string;
|
||||
params: ParamInfo[];
|
||||
isDeprecated: boolean;
|
||||
@@ -117,6 +133,7 @@ class MethodSigInfo {
|
||||
constructor(rawSig: SignatureReflection) {
|
||||
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;
|
||||
@@ -128,7 +145,10 @@ class MethodSigInfo {
|
||||
this.returnDocText = rawSig.comment.returns;
|
||||
this.returnDocText = this.returnDocText ? this.returnDocText.replace(/[\n\r]+/g, " ").trim() : "";
|
||||
|
||||
if (!this.returnDocText)
|
||||
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.`);
|
||||
|
||||
this.isDeprecated = rawSig.comment.hasTag("deprecated");
|
||||
@@ -199,9 +219,11 @@ export function initPhase(aggData) {
|
||||
|
||||
let sources = app.expandInputFiles(libFolders);
|
||||
aggData.projData = app.convert(sources);
|
||||
/*
|
||||
aggData.liq = liquid({
|
||||
root: templateFolder
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -220,6 +242,19 @@ export function updatePhase(tree, pathname, aggData) {
|
||||
let classType = compName.match(/component|directive|service/i);
|
||||
|
||||
if (classType) {
|
||||
let templateName = path.resolve(templateFolder, classType + ".combyne");
|
||||
let templateSource = fs.readFileSync(templateName, "utf8");
|
||||
let template = combyne(templateSource);
|
||||
|
||||
let mdText = template.render(compData);
|
||||
let newSection = remark().parse(mdText.trim()).children;
|
||||
|
||||
replaceSection(tree, "Class members", (before, section, after) => {
|
||||
newSection.unshift(before);
|
||||
newSection.push(after);
|
||||
return newSection;
|
||||
});
|
||||
/*
|
||||
let templateName = classType[0] + ".liquid";
|
||||
|
||||
aggData.liq
|
||||
@@ -233,13 +268,25 @@ export function updatePhase(tree, pathname, aggData) {
|
||||
});
|
||||
|
||||
fs.writeFileSync(pathname, remark().use(frontMatter, {type: 'yaml', fence: '---'}).data("settings", {paddedTable: false}).stringify(tree));
|
||||
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function renderInputs(comp: ComponentInfo): string {
|
||||
var result = "";
|
||||
|
||||
comp.properties.forEach(prop => {
|
||||
result += `| ${prop.name} | \`${prop.type}\` | ${prop.defaultValue} | ${prop.docText} |\n`;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function initialCap(str: string) {
|
||||
return str[0].toUpperCase() + str.substr(1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user