Skip to content

Commit 1ff375b

Browse files
targosdanielleadams
authored andcommitted
tools: avoid pending deprecation in doc generator
`unist-util-find` depends on `lodash.iteratee` which uses `process.binding()`. Let's remove this dependency which is used in one place to do a very simple thing. PR-URL: #37267 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent d96a97a commit 1ff375b

File tree

3 files changed

+7
-86
lines changed

3 files changed

+7
-86
lines changed

tools/doc/html.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
const common = require('./common.js');
2525
const fs = require('fs');
2626
const unified = require('unified');
27-
const find = require('unist-util-find');
2827
const visit = require('unist-util-visit');
2928
const markdown = require('remark-parse');
3029
const gfm = require('remark-gfm');
@@ -97,7 +96,13 @@ function toHTML({ input, content, filename, nodeVersion, versions }) {
9796
// Set the section name based on the first header. Default to 'Index'.
9897
function firstHeader() {
9998
return (tree, file) => {
100-
const heading = find(tree, { type: 'heading' });
99+
let heading;
100+
visit(tree, (node) => {
101+
if (node.type === 'heading') {
102+
heading = node;
103+
return false;
104+
}
105+
});
101106

102107
if (heading && heading.children.length) {
103108
const recursiveTextContent = (node) =>

tools/doc/package-lock.json

-83
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/doc/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"remark-rehype": "8.0.0",
1818
"to-vfile": "6.1.0",
1919
"unified": "9.2.0",
20-
"unist-util-find": "^1.0.2",
2120
"unist-util-select": "3.0.4",
2221
"unist-util-visit": "2.0.3"
2322
},

0 commit comments

Comments
 (0)