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: add [src] links to async_hooks.html #22656

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,12 @@ out/apilinks.json: $(wildcard lib/*.js) tools/doc/apilinks.js
$(call available-node, $(gen-apilink))

out/doc/api/%.json out/doc/api/%.html: doc/api/%.md tools/doc/generate.js \
tools/doc/html.js tools/doc/json.js | out/apilinks.json
tools/doc/html.js tools/doc/json.js tools/doc/apilinks.js | \
out/apilinks.json
$(call available-node, $(gen-api))

out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.js
out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.js \
tools/doc/apilinks.js
$(call available-node, tools/doc/allhtml.js)

out/doc/api/all.json: $(apidocs_json) tools/doc/alljson.js
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/apilinks/class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

// An exported class using ES2015 class syntax.

class Class {
constructor() {};
method() {};
}

module.exports = {
Class
};
5 changes: 5 additions & 0 deletions test/fixtures/apilinks/class.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Class": "class.js#L5",
"new Class": "class.js#L6",
"class.method": "class.js#L7"
}
19 changes: 19 additions & 0 deletions tools/doc/apilinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ process.argv.slice(2).forEach((file) => {
// ClassName.foo = ...;
// ClassName.prototype.foo = ...;
// function Identifier(...) {...};
// class Foo {...}
//
const indirect = {};

Expand Down Expand Up @@ -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}`;
}
});
}
});

Expand Down