tools: fix stability index generation

PR-URL: https://github.com/nodejs/node/pull/45346
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
This commit is contained in:
Antoine du Hamel 2022-11-06 20:25:44 -05:00 committed by GitHub
parent 7903f944ec
commit 7e581c88fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -104,10 +104,10 @@ export function jsonAPI({ filename }) {
nodes.slice(0, i).every((node) => node.type === 'list')
) {
const text = textJoin(node.children[0].children, file);
const stability = text.match(stabilityExpr);
const stability = stabilityExpr.exec(text);
if (stability) {
current.stability = parseInt(stability[1], 10);
current.stabilityText = stability[2].trim();
current.stabilityText = stability[2].replaceAll('\n', ' ').trim();
delete nodes[i];
}
}

View File

@ -30,12 +30,17 @@ function collectStability(data) {
if (mod.displayName && mod.stability >= 0) {
const link = mod.source.replace('doc/api/', '').replace('.md', '.html');
let { stabilityText } = mod;
if (stabilityText.includes('. ')) {
stabilityText = stabilityText.slice(0, stabilityText.indexOf('.'));
}
stability.push({
api: mod.name,
displayName: mod.textRaw,
link: link,
stability: mod.stability,
stabilityText: `(${mod.stability}) ${mod.stabilityText}`,
stabilityText: `(${mod.stability}) ${stabilityText}`,
});
}
}