Skip to content

Commit

Permalink
tools: fix tools/addon-verify.js
Browse files Browse the repository at this point in the history
The current implementation of addon-verify.js is including the code
for the "Function arguments" section in test/addons/01_callbacks and
there is no directory generated or the "Function arguments section".
This continues and leads to the last section, "AtExit", code to be
excluded. There is an test/addons/07_atexit_hooks but it contains code
from the "Passing wrapped objects around" section.

This commit modifies addon-verify to associate headers with code and
then iterates over the set and generates the files as a separate step.

PR-URL: #14048
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
danbev authored and addaleax committed Aug 10, 2017
1 parent 06ba2da commit a0e05e8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion doc/api/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ Test in JavaScript by running:
```js
// test.js
const addon = require('./build/Release/addon');
require('./build/Release/addon');
```

[Embedder's Guide]: https://github.com/v8/v8/wiki/Embedder's%20Guide
Expand Down
36 changes: 18 additions & 18 deletions tools/doc/addon-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ const verifyDir = path.resolve(rootDir, 'test', 'addons');
const contents = fs.readFileSync(doc).toString();

const tokens = marked.lexer(contents);
let files = null;
let id = 0;

// Just to make sure that all examples will be processed
tokens.push({ type: 'heading' });

for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
let currentHeader;
const addons = {};
tokens.forEach((token) => {
if (token.type === 'heading' && token.text) {
const blockName = token.text;
if (files && Object.keys(files).length !== 0) {
verifyFiles(files,
blockName,
console.log.bind(null, 'wrote'),
function(err) { if (err) throw err; });
}
files = {};
} else if (token.type === 'code') {
currentHeader = token.text;
addons[currentHeader] = {
files: {}
};
}
if (token.type === 'code') {
var match = token.text.match(/^\/\/\s+(.*\.(?:cc|h|js))[\r\n]/);
if (match === null)
continue;
files[match[1]] = token.text;
if (match !== null) {
addons[currentHeader].files[match[1]] = token.text;
}
}
});
for (var header in addons) {
verifyFiles(addons[header].files,
header,
console.log.bind(null, 'wrote'),
function(err) { if (err) throw err; });
}

function once(fn) {
Expand Down

0 comments on commit a0e05e8

Please sign in to comment.