summaryrefslogtreecommitdiff
path: root/tools/doc/apilinks.js
diff options
context:
space:
mode:
authorSam Ruby <rubys@intertwingly.net>2018-09-02 10:23:13 -0400
committerDaniel Bevenius <daniel.bevenius@gmail.com>2018-09-05 12:46:51 +0200
commit441391b9ebb1dda7721c1b0ce6b700b45c598b2b (patch)
treef195847ac70aa324abb6d6b8271ded2138e48b9d /tools/doc/apilinks.js
parentd4cdb2ce662e9521d0671058a0f129ccad3f7e03 (diff)
downloadandroid-node-v8-441391b9ebb1dda7721c1b0ce6b700b45c598b2b.tar.gz
android-node-v8-441391b9ebb1dda7721c1b0ce6b700b45c598b2b.tar.bz2
android-node-v8-441391b9ebb1dda7721c1b0ce6b700b45c598b2b.zip
tools: add [src] links to async_hooks.html
handle ES2015 Class, contructor, and instance methods unrelated: update Makefile so that generated HTML is out of date whenever tools/doc/apilinks.js is updated. PR-URL: https://github.com/nodejs/node/pull/22656 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'tools/doc/apilinks.js')
-rw-r--r--tools/doc/apilinks.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/doc/apilinks.js b/tools/doc/apilinks.js
index 35183912d3..b0a221cf01 100644
--- a/tools/doc/apilinks.js
+++ b/tools/doc/apilinks.js
@@ -107,6 +107,7 @@ process.argv.slice(2).forEach((file) => {
// ClassName.foo = ...;
// ClassName.prototype.foo = ...;
// function Identifier(...) {...};
+ // class Foo {...}
//
const indirect = {};
@@ -153,6 +154,24 @@ process.argv.slice(2).forEach((file) => {
if (basename.startsWith('_')) return;
definition[`${basename}.${name}`] =
`${link}#L${statement.loc.start.line}`;
+
+ } else if (statement.type === 'ClassDeclaration') {
+ if (!exported.constructors.includes(statement.id.name)) return;
+ definition[statement.id.name] = `${link}#L${statement.loc.start.line}`;
+
+ const name = statement.id.name.slice(0, 1).toLowerCase() +
+ statement.id.name.slice(1);
+
+ statement.body.body.forEach((defn) => {
+ if (defn.type !== 'MethodDefinition') return;
+ if (defn.kind === 'method') {
+ definition[`${name}.${defn.key.name}`] =
+ `${link}#L${defn.loc.start.line}`;
+ } else if (defn.kind === 'constructor') {
+ definition[`new ${statement.id.name}`] =
+ `${link}#L${defn.loc.start.line}`;
+ }
+ });
}
});