chore: rebase documentation and markdown classes from docs (#7172)

This commit is contained in:
Max Schmitt 2021-06-16 23:19:24 -07:00 committed by GitHub
parent 2e251d9d5d
commit 36c5395d2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -304,6 +304,11 @@ Documentation.Member = class {
};
this.async = false;
this.alias = name;
/**
* Param is true and option false
* @type {Boolean}
*/
this.paramOrOption = null;
}
index() {
@ -314,6 +319,7 @@ Documentation.Member = class {
this.args.set(arg.name, arg);
arg.enclosingMethod = this;
if (arg.name === 'options') {
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() {
const result = new Documentation.Member(this.kind, this.langs, this.name, this.type, this.argsArray, this.spec, this.required);
result.async = this.async;
result.paramOrOption = this.paramOrOption;
return result;
}

View file

@ -227,7 +227,7 @@ function render(nodes, maxColumns) {
*/
function innerRenderMdNode(indent, node, lastNode, result, maxColumns) {
const newLine = () => {
if (result.length && result[result.length - 1] !== '')
if (result[result.length - 1] !== '')
result.push('');
};
@ -370,12 +370,13 @@ function visit(node, visitor, depth = 0) {
/**
* @param {MarkdownNode[]} nodes
* @param {boolean=} h3
* @returns {string}
*/
function generateToc(nodes) {
function generateToc(nodes, h3) {
const result = [];
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();
link = link.replace(/[ ]+/g, '-');
link = link.replace(/[^\w-_]/g, '');