chore: rebase documentation and markdown classes from docs (#7172)
This commit is contained in:
parent
2e251d9d5d
commit
36c5395d2d
|
|
@ -304,6 +304,11 @@ Documentation.Member = class {
|
||||||
};
|
};
|
||||||
this.async = false;
|
this.async = false;
|
||||||
this.alias = name;
|
this.alias = name;
|
||||||
|
/**
|
||||||
|
* Param is true and option false
|
||||||
|
* @type {Boolean}
|
||||||
|
*/
|
||||||
|
this.paramOrOption = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
index() {
|
index() {
|
||||||
|
|
@ -314,7 +319,8 @@ Documentation.Member = class {
|
||||||
this.args.set(arg.name, arg);
|
this.args.set(arg.name, arg);
|
||||||
arg.enclosingMethod = this;
|
arg.enclosingMethod = this;
|
||||||
if (arg.name === 'options') {
|
if (arg.name === 'options') {
|
||||||
arg.type.properties.forEach(p => p.enclosingMethod = this );
|
arg.type.properties.sort((p1, p2) => p1.name.localeCompare(p2.name));
|
||||||
|
arg.type.properties.forEach(p => p.enclosingMethod = this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -344,6 +350,7 @@ Documentation.Member = class {
|
||||||
clone() {
|
clone() {
|
||||||
const result = new Documentation.Member(this.kind, this.langs, this.name, this.type, this.argsArray, this.spec, this.required);
|
const result = new Documentation.Member(this.kind, this.langs, this.name, this.type, this.argsArray, this.spec, this.required);
|
||||||
result.async = this.async;
|
result.async = this.async;
|
||||||
|
result.paramOrOption = this.paramOrOption;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ function render(nodes, maxColumns) {
|
||||||
*/
|
*/
|
||||||
function innerRenderMdNode(indent, node, lastNode, result, maxColumns) {
|
function innerRenderMdNode(indent, node, lastNode, result, maxColumns) {
|
||||||
const newLine = () => {
|
const newLine = () => {
|
||||||
if (result.length && result[result.length - 1] !== '')
|
if (result[result.length - 1] !== '')
|
||||||
result.push('');
|
result.push('');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -370,12 +370,13 @@ function visit(node, visitor, depth = 0) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {MarkdownNode[]} nodes
|
* @param {MarkdownNode[]} nodes
|
||||||
|
* @param {boolean=} h3
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function generateToc(nodes) {
|
function generateToc(nodes, h3) {
|
||||||
const result = [];
|
const result = [];
|
||||||
visitAll(nodes, (node, depth) => {
|
visitAll(nodes, (node, depth) => {
|
||||||
if (node.type === 'h1' || node.type === 'h2') {
|
if (node.type === 'h1' || node.type === 'h2' || (h3 && node.type === 'h3')) {
|
||||||
let link = node.text.toLowerCase();
|
let link = node.text.toLowerCase();
|
||||||
link = link.replace(/[ ]+/g, '-');
|
link = link.replace(/[ ]+/g, '-');
|
||||||
link = link.replace(/[^\w-_]/g, '');
|
link = link.replace(/[^\w-_]/g, '');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue