Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 460f412

Browse filesBrowse files
Renegade334aduh95
authored andcommitted
test: check stability block position in API markdown
PR-URL: #58590 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
1 parent a0316d3 commit 460f412
Copy full SHA for 460f412

3 files changed

+56-4Lines changed: 56 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/buffer.md‎

Copy file name to clipboardExpand all lines: doc/api/buffer.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3524,13 +3524,13 @@ changes:
35243524
calculations with them.
35253525
-->
35263526

3527+
> Stability: 0 - Deprecated: Use [`buf.subarray`][] instead.
3528+
35273529
* `start` {integer} Where the new `Buffer` will start. **Default:** `0`.
35283530
* `end` {integer} Where the new `Buffer` will end (not inclusive).
35293531
**Default:** [`buf.length`][].
35303532
* Returns: {Buffer}
35313533

3532-
> Stability: 0 - Deprecated: Use [`buf.subarray`][] instead.
3533-
35343534
Returns a new `Buffer` that references the same memory as the original, but
35353535
offset and cropped by the `start` and `end` indexes.
35363536

Collapse file

‎doc/api/environment_variables.md‎

Copy file name to clipboardExpand all lines: doc/api/environment_variables.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ For more details refer to the [`process.env` documentation][].
1818

1919
## DotEnv
2020

21-
Set of utilities for dealing with additional environment variables defined in `.env` files.
22-
2321
> Stability: 2 - Stable
2422
23+
Set of utilities for dealing with additional environment variables defined in `.env` files.
24+
2525
### .env files
2626

2727
`.env` files (also known as dotenv files) are files that define environment variables,
Collapse file
+52Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import '../common/index.mjs';
2+
3+
import fs from 'fs';
4+
import assert from 'assert';
5+
6+
import {
7+
remarkParse,
8+
unified,
9+
} from '../../tools/doc/deps.mjs';
10+
11+
const ignore = ['deprecations.md', 'documentation.md'];
12+
13+
const docURL = new URL('../../doc/api/', import.meta.url);
14+
const docList = fs.readdirSync(docURL).filter((filename) => !ignore.includes(filename));
15+
16+
const re = /^Stability: \d/;
17+
18+
for (const file of docList) {
19+
const fileURL = new URL(file, docURL);
20+
const tree = unified()
21+
.use(remarkParse)
22+
.parse(fs.readFileSync(fileURL));
23+
24+
// Traverse first-level nodes, ignoring comment blocks
25+
const nodes = tree.children.filter((node) => node.type !== 'html');
26+
27+
for (let i = 0; i < nodes.length; i++) {
28+
const { [i]: node, [i - 1]: previousNode } = nodes;
29+
if (node.type !== 'blockquote' || !node.children.length) continue;
30+
31+
const paragraph = node.children[0];
32+
if (paragraph.type !== 'paragraph' || !paragraph.children.length) continue;
33+
34+
const text = paragraph.children[0];
35+
if (text.type !== 'text' || !re.exec(text.value)) continue;
36+
37+
// Check that previous node type (excluding comment blocks) is one of:
38+
// * 'heading'
39+
// * 'paragraph' with a leading 'strong' node (pseudo-heading, eg. assert.equal)
40+
try {
41+
assert(previousNode.type === 'heading' ||
42+
(previousNode.type === 'paragraph' && previousNode.children[0]?.type === 'strong'),
43+
'Stability block must be the first content element under heading');
44+
} catch (error) {
45+
const { line, column } = node.position.start;
46+
error.stack = error.stack.split('\n')
47+
.toSpliced(1, 0, ` at ${fileURL}:${line}:${column}`)
48+
.join('\n');
49+
throw error;
50+
}
51+
}
52+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.