Skip to content

Commit

Permalink
tools: avoid pending deprecation in doc generator
Browse files Browse the repository at this point in the history
`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 <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
  • Loading branch information
targos committed May 1, 2021
1 parent 4cdd9b6 commit 2ba6db3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 86 deletions.
9 changes: 7 additions & 2 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
const common = require('./common.js');
const fs = require('fs');
const unified = require('unified');
const find = require('unist-util-find');
const visit = require('unist-util-visit');
const markdown = require('remark-parse');
const gfm = require('remark-gfm');
Expand Down Expand Up @@ -97,7 +96,13 @@ function toHTML({ input, content, filename, nodeVersion, versions }) {
// Set the section name based on the first header. Default to 'Index'.
function firstHeader() {
return (tree, file) => {
const heading = find(tree, { type: 'heading' });
let heading;
visit(tree, (node) => {
if (node.type === 'heading') {
heading = node;
return false;
}
});

if (heading && heading.children.length) {
const recursiveTextContent = (node) =>
Expand Down
83 changes: 0 additions & 83 deletions tools/doc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tools/doc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"remark-rehype": "8.0.0",
"to-vfile": "6.1.0",
"unified": "9.2.0",
"unist-util-find": "^1.0.2",
"unist-util-select": "3.0.4",
"unist-util-visit": "2.0.3"
},
Expand Down

0 comments on commit 2ba6db3

Please sign in to comment.