Skip to content

Commit

Permalink
chore: rebase documentation and markdown classes from docs (#7172)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Jun 17, 2021
1 parent 2e251d9 commit 36c5395
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion utils/doclint/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -314,7 +319,8 @@ Documentation.Member = class {
this.args.set(arg.name, arg);
arg.enclosingMethod = this;
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);
}
}
}
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 4 additions & 3 deletions utils/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
};

Expand Down Expand Up @@ -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, '');
Expand Down

0 comments on commit 36c5395

Please sign in to comment.