summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/api/addons.md2
-rw-r--r--tools/doc/addon-verify.js36
2 files changed, 19 insertions, 19 deletions
diff --git a/doc/api/addons.md b/doc/api/addons.md
index e973ec4111..c44d31dc1b 100644
--- a/doc/api/addons.md
+++ b/doc/api/addons.md
@@ -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
diff --git a/tools/doc/addon-verify.js b/tools/doc/addon-verify.js
index 9af040b339..2e72abb77f 100644
--- a/tools/doc/addon-verify.js
+++ b/tools/doc/addon-verify.js
@@ -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) {