mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
doc: refactor deprecation anchors
PR-URL: https://github.com/nodejs/node/pull/34955 Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
44d89a9faa
commit
8c207c67d1
2 files changed
+12
-145
No files matched your search
File diff suppressed because it is too large.
Load diff
+12
-1
@@ -327,6 +327,7 @@ function versionSort(a, b) {
|
||||
return +b.match(numberRe)[0] - +a.match(numberRe)[0];
|
||||
}
|
||||
|
||||
const DEPRECATION_HEADING_PATTERN = /^DEP\d+:/;
|
||||
function buildToc({ filename, apilinks }) {
|
||||
return (tree, file) => {
|
||||
const idCounters = Object.create(null);
|
||||
@@ -349,10 +350,20 @@ function buildToc({ filename, apilinks }) {
|
||||
node.position.end.offset).trim();
|
||||
const id = getId(`${realFilename}_${headingText}`, idCounters);
|
||||
|
||||
const isDeprecationHeading =
|
||||
DEPRECATION_HEADING_PATTERN.test(headingText);
|
||||
if (isDeprecationHeading) {
|
||||
if (!node.data) node.data = {};
|
||||
if (!node.data.hProperties) node.data.hProperties = {};
|
||||
node.data.hProperties.id =
|
||||
headingText.substring(0, headingText.indexOf(':'));
|
||||
}
|
||||
|
||||
const hasStability = node.stability !== undefined;
|
||||
toc += ' '.repeat((depth - 1) * 2) +
|
||||
(hasStability ? `* <span class="stability_${node.stability}">` : '* ') +
|
||||
`<a href="#${id}">${headingText}</a>${hasStability ? '</span>' : ''}\n`;
|
||||
`<a href="#${isDeprecationHeading ? node.data.hProperties.id : id}">` +
|
||||
`${headingText}</a>${hasStability ? '</span>' : ''}\n`;
|
||||
|
||||
let anchor =
|
||||
`<span><a class="mark" href="#${id}" id="${id}">#</a></span>`;
|
||||
|
||||
Reference in new issue
Block a user