GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tools: convert addon-verify to remark · nodejs/node@0c67d32

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • tools/doc
    • addon-verify.js
    • package-lock.json
    • package.json
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tools/doc/addon-verify.js‎

Copy file name to clipboardExpand all lines: tools/doc/addon-verify.js
+20-10Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
'use strict';
22

3-
const { mkdir, readFileSync, writeFile } = require('fs');
3+
// doc/api/addons.md has a bunch of code. Extract it for verification
4+
// that the C++ code compiles and the js code runs.
5+
// Add .gyp files which will be used to compile the C++ code.
6+
// Modify the require paths in the js code to pull from the build tree.
7+
// Triggered from the build-addons target in the Makefile and vcbuild.bat.
8+
9+
const { mkdir, writeFile } = require('fs');
410
const { resolve } = require('path');
5-
const { lexer } = require('marked');
11+
const vfile = require('to-vfile');
12+
const unified = require('unified');
13+
const remarkParse = require('remark-parse');
614

715
const rootDir = resolve(__dirname, '..', '..');
816
const doc = resolve(rootDir, 'doc', 'api', 'addons.md');
917
const verifyDir = resolve(rootDir, 'test', 'addons');
1018

11-
const tokens = lexer(readFileSync(doc, 'utf8'));
19+
const file = vfile.readSync(doc, 'utf8');
20+
const tree = unified().use(remarkParse).parse(file);
1221
const addons = {};
1322
let id = 0;
1423
let currentHeader;
1524

1625
const validNames = /^\/\/\s+(.*\.(?:cc|h|js))[\r\n]/;
17-
tokens.forEach(({ type, text }) => {
18-
if (type === 'heading') {
19-
currentHeader = text;
26+
tree.children.forEach((node) => {
27+
if (node.type === 'heading') {
28+
currentHeader = file.contents.slice(
29+
node.children[0].position.start.offset,
30+
node.position.end.offset);
2031
addons[currentHeader] = { files: {} };
21-
}
22-
if (type === 'code') {
23-
const match = text.match(validNames);
32+
} else if (node.type === 'code') {
33+
const match = node.value.match(validNames);
2434
if (match !== null) {
25-
addons[currentHeader].files[match[1]] = text;
35+
addons[currentHeader].files[match[1]] = node.value;
2636
}
2737
}
2838
});
Collapse file

‎tools/doc/package-lock.json‎

Copy file name to clipboardExpand all lines: tools/doc/package-lock.json
+9-5Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎tools/doc/package.json‎

Copy file name to clipboardExpand all lines: tools/doc/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"node": ">=6"
88
},
99
"dependencies": {
10-
"marked": "^0.4.0",
1110
"rehype-raw": "^2.0.0",
1211
"rehype-stringify": "^3.0.0",
1312
"remark-html": "^7.0.0",
1413
"remark-parse": "^5.0.0",
1514
"remark-rehype": "^3.0.0",
15+
"to-vfile": "^5.0.0",
1616
"unified": "^7.0.0",
1717
"unist-util-find": "^1.0.1",
1818
"unist-util-select": "^1.5.0",

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.