Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: convert addon-verify to remark #21978

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions tools/doc/addon-verify.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
'use strict';

const { mkdir, readFileSync, writeFile } = require('fs');
// doc/api/addons.md has a bunch of code. Extract it for verification
// that the c++ code comples and the js code runs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compiles

// Add .gyp files which will be used to compile the c++ code.
// Modify the require paths in the js code to pull from the build tree.

const { mkdir, writeFile } = require('fs');
const { resolve } = require('path');
const vfile = require('to-vfile');
const unified = require('unified');
Expand All @@ -18,12 +23,12 @@ let currentHeader;

const validNames = /^\/\/\s+(.*\.(?:cc|h|js))[\r\n]/;
tree.children.forEach((node) => {
if (node.type == 'heading') {
if (node.type === 'heading') {
currentHeader = file.contents.slice(
node.children[0].position.start.offset,
node.position.end.offset);
addons[currentHeader] = { files: {} };
} else if (node.type == 'code') {
} else if (node.type === 'code') {
const match = node.value.match(validNames);
if (match !== null) {
addons[currentHeader].files[match[1]] = node.value;
Expand Down