GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tools: Include links to source code in documentation · nodejs/node@50100f3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Makefile
  • doc/api_assets
    • style.css
  • test
    • doctool
      • test-apilinks.js
      • test-doctool-html.js
    • fixtures/apilinks
      • buffer.json
      • buffer.js
      • mod.json
      • mod.js
      • prototype.json
      • prototype.js
  • tools/doc
    • apilinks.js
    • generate.js
    • html.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Makefile‎

Copy file name to clipboardExpand all lines: Makefile
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,15 @@ out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets
645645
run-npm-ci = $(PWD)/$(NPM) ci
646646

647647
gen-api = tools/doc/generate.js --node-version=$(FULLVERSION) \
648+
--apilinks=out/apilinks.json \
648649
--analytics=$(DOCS_ANALYTICS) $< --output-directory=out/doc/api
650+
gen-apilink = tools/doc/apilinks.js $(wildcard lib/*.js) > $@
651+
652+
out/apilinks.json: $(wildcard lib/*.js) tools/doc/apilinks.js
653+
$(call available-node, $(gen-apilink))
649654

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

654659
out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.js
Collapse file

‎doc/api_assets/style.css‎

Copy file name to clipboardExpand all lines: doc/api_assets/style.css
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ h2, h3, h4, h5 {
283283
padding-right: 40px;
284284
}
285285

286+
.srclink {
287+
float: right;
288+
font-size: smaller;
289+
}
290+
286291
h1 span, h2 span, h3 span, h4 span {
287292
position: absolute;
288293
display: block;
Collapse file

‎test/doctool/test-apilinks.js‎

Copy file name to clipboard
+39Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
require('../common');
4+
const fixtures = require('../common/fixtures');
5+
const fs = require('fs');
6+
const assert = require('assert');
7+
const path = require('path');
8+
const { execFileSync } = require('child_process');
9+
10+
const script = path.join(__dirname, '..', '..', 'tools', 'doc', 'apilinks.js');
11+
12+
const apilinks = fixtures.path('apilinks');
13+
fs.readdirSync(apilinks).forEach((fixture) => {
14+
if (!fixture.endsWith('.js')) return;
15+
const file = path.join(apilinks, fixture);
16+
17+
const expectedContent = fs.readFileSync(file + 'on', 'utf8');
18+
19+
const output = execFileSync(
20+
process.execPath,
21+
[script, file],
22+
{ encoding: 'utf-8' }
23+
);
24+
25+
const expectedLinks = JSON.parse(expectedContent);
26+
const actualLinks = JSON.parse(output);
27+
28+
for (const [k, v] of Object.entries(expectedLinks)) {
29+
assert.ok(k in actualLinks, `link not found: ${k}`);
30+
assert.ok(actualLinks[k].endsWith('/' + v),
31+
`link ${actualLinks[k]} expected to end with ${v}`);
32+
delete actualLinks[k];
33+
}
34+
35+
assert.strictEqual(
36+
Object.keys(actualLinks).length, 0,
37+
`unexpected links returned ${JSON.stringify(actualLinks)}`
38+
);
39+
});
Collapse file

‎test/doctool/test-doctool-html.js‎

Copy file name to clipboardExpand all lines: test/doctool/test-doctool-html.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function toHTML({ input, filename, nodeVersion, analytics }, cb) {
2828
.use(html.firstHeader)
2929
.use(html.preprocessText)
3030
.use(html.preprocessElements, { filename })
31-
.use(html.buildToc, { filename })
31+
.use(html.buildToc, { filename, apilinks: {} })
3232
.use(remark2rehype, { allowDangerousHTML: true })
3333
.use(raw)
3434
.use(htmlStringify)
Collapse file

‎test/fixtures/apilinks/buffer.js‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
// Buffer instance methods are exported as 'buf'.
4+
5+
function Buffer() {
6+
}
7+
8+
Buffer.prototype.instanceMethod = function() {}
9+
10+
module.exports = {
11+
Buffer
12+
};
Collapse file

‎test/fixtures/apilinks/buffer.json‎

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"buffer.Buffer": "buffer.js#L5",
3+
"buf.instanceMethod": "buffer.js#L8"
4+
}
Collapse file

‎test/fixtures/apilinks/mod.js‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
// A module may export one or more methods.
4+
5+
function foo() {
6+
}
7+
8+
9+
module.exports = {
10+
foo
11+
};
Collapse file

‎test/fixtures/apilinks/mod.json‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mod.foo": "mod.js#L5"
3+
}
Collapse file

‎test/fixtures/apilinks/prototype.js‎

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
// An exported class using classic prototype syntax.
4+
5+
function Class() {
6+
}
7+
8+
Class.classMethod = function() {}
9+
Class.prototype.instanceMethod = function() {}
10+
11+
module.exports = {
12+
Class
13+
};
Collapse file

‎test/fixtures/apilinks/prototype.json‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"prototype.Class": "prototype.js#L5",
3+
"Class.classMethod": "prototype.js#L8",
4+
"class.instanceMethod": "prototype.js#L9"
5+
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.