Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a8c99d9

Browse filesBrowse files
targosBethGriggs
authored andcommitted
tools: update doc generator dependencies
PR-URL: #40042 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 98d42fa commit a8c99d9
Copy full SHA for a8c99d9

File tree

Expand file treeCollapse file tree

10 files changed

+1612
-1060
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

10 files changed

+1612
-1060
lines changed
Open diff view settings
Collapse file

‎test/doctool/test-doctool-html.mjs‎

Copy file name to clipboardExpand all lines: test/doctool/test-doctool-html.mjs
+11-12Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ import * as fixtures from '../common/fixtures.mjs';
33

44
import assert from 'assert';
55
import { readFileSync } from 'fs';
6-
import { createRequire } from 'module';
76

87
import * as html from '../../tools/doc/html.mjs';
98
import { replaceLinks } from '../../tools/doc/markdown.mjs';
10-
11-
const require = createRequire(new URL('../../tools/doc/', import.meta.url));
12-
const unified = require('unified');
13-
const markdown = require('remark-parse');
14-
const remark2rehype = require('remark-rehype');
15-
const raw = require('rehype-raw');
16-
const htmlStringify = require('rehype-stringify');
9+
import {
10+
rehypeRaw,
11+
rehypeStringify,
12+
remarkParse,
13+
remarkRehype,
14+
unified,
15+
} from '../../tools/doc/deps.mjs';
1716

1817
// Test links mapper is an object of the following structure:
1918
// {
@@ -31,14 +30,14 @@ const testLinksMapper = {
3130
function toHTML({ input, filename, nodeVersion, versions }) {
3231
const content = unified()
3332
.use(replaceLinks, { filename, linksMapper: testLinksMapper })
34-
.use(markdown)
33+
.use(remarkParse)
3534
.use(html.firstHeader)
3635
.use(html.preprocessText, { nodeVersion })
3736
.use(html.preprocessElements, { filename })
3837
.use(html.buildToc, { filename, apilinks: {} })
39-
.use(remark2rehype, { allowDangerousHtml: true })
40-
.use(raw)
41-
.use(htmlStringify)
38+
.use(remarkRehype, { allowDangerousHtml: true })
39+
.use(rehypeRaw)
40+
.use(rehypeStringify)
4241
.processSync(input);
4342

4443
return html.toHTML({ input, content, filename, nodeVersion, versions });
Collapse file

‎test/doctool/test-doctool-json.mjs‎

Copy file name to clipboardExpand all lines: test/doctool/test-doctool-json.mjs
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ import * as fixtures from '../common/fixtures.mjs';
33

44
import assert from 'assert';
55
import fs from 'fs';
6-
import { createRequire } from 'module';
76

87
import * as json from '../../tools/doc/json.mjs';
9-
10-
const require = createRequire(new URL('../../tools/doc/', import.meta.url));
11-
const unified = require('unified');
12-
const markdown = require('remark-parse');
8+
import {
9+
remarkParse,
10+
unified,
11+
} from '../../tools/doc/deps.mjs';
1312

1413
function toJSON(input, filename, cb) {
1514
function nullCompiler() {
1615
this.Compiler = (tree) => tree;
1716
}
1817

1918
unified()
20-
.use(markdown)
19+
.use(remarkParse)
2120
.use(json.jsonAPI, { filename })
2221
.use(nullCompiler)
2322
.process(input, cb);
Collapse file

‎tools/doc/addon-verify.mjs‎

Copy file name to clipboardExpand all lines: tools/doc/addon-verify.mjs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { mkdir, writeFile } from 'fs/promises';
99
import gfm from 'remark-gfm';
1010
import remarkParse from 'remark-parse';
1111
import { toVFile } from 'to-vfile';
12-
import unified from 'unified';
12+
import { unified } from 'unified';
1313

1414
const rootDir = new URL('../../', import.meta.url);
1515
const doc = new URL('./doc/api/addons.md', rootDir);
Collapse file

‎tools/doc/deps.mjs‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Re-exporting dependencies for tests in test/doctool.
2+
3+
export { default as rehypeRaw } from 'rehype-raw';
4+
export { default as rehypeStringify } from 'rehype-stringify';
5+
export { default as remarkParse } from 'remark-parse';
6+
export { default as remarkRehype } from 'remark-rehype';
7+
export { unified } from 'unified';
Collapse file

‎tools/doc/generate.mjs‎

Copy file name to clipboardExpand all lines: tools/doc/generate.mjs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import gfm from 'remark-gfm';
2828
import markdown from 'remark-parse';
2929
import remark2rehype from 'remark-rehype';
3030
import frontmatter from 'remark-frontmatter';
31-
import unified from 'unified';
31+
import { unified } from 'unified';
3232

3333
import * as html from './html.mjs';
3434
import * as json from './json.mjs';
Collapse file

‎tools/doc/html.mjs‎

Copy file name to clipboardExpand all lines: tools/doc/html.mjs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import htmlStringify from 'rehype-stringify';
2828
import gfm from 'remark-gfm';
2929
import markdown from 'remark-parse';
3030
import remark2rehype from 'remark-rehype';
31-
import unified from 'unified';
31+
import { unified } from 'unified';
3232
import { visit } from 'unist-util-visit';
3333

3434
import * as common from './common.mjs';
@@ -395,7 +395,7 @@ export function buildToc({ filename, apilinks }) {
395395

396396
depth = node.depth;
397397
const realFilename = path.basename(filename, '.md');
398-
const headingText = file.contents.slice(
398+
const headingText = file.value.slice(
399399
node.children[0].position.start.offset,
400400
node.position.end.offset).trim();
401401
const id = getId(`${realFilename}_${headingText}`, idCounters);
Collapse file

‎tools/doc/json.mjs‎

Copy file name to clipboardExpand all lines: tools/doc/json.mjs
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
import html from 'remark-html';
23-
import unified from 'unified';
23+
import { unified } from 'unified';
2424
import { selectAll } from 'unist-util-select';
2525

2626
import * as common from './common.mjs';
@@ -376,7 +376,7 @@ function parseListItem(item, file) {
376376

377377
current.textRaw = item.children.filter((node) => node.type !== 'list')
378378
.map((node) => (
379-
file.contents.slice(node.position.start.offset, node.position.end.offset))
379+
file.value.slice(node.position.start.offset, node.position.end.offset))
380380
)
381381
.join('').replace(/\s+/g, ' ').replace(/<!--.*?-->/sg, '');
382382
let text = current.textRaw;
@@ -491,8 +491,8 @@ function newSection(header, file) {
491491
function textJoin(nodes, file) {
492492
return nodes.map((node) => {
493493
if (node.type === 'linkReference') {
494-
return file.contents.slice(node.position.start.offset,
495-
node.position.end.offset);
494+
return file.value.slice(node.position.start.offset,
495+
node.position.end.offset);
496496
} else if (node.type === 'inlineCode') {
497497
return `\`${node.value}\``;
498498
} else if (node.type === 'strong') {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.