Skip to content

Commit 03934ea

Browse files
docs(syntax): describe the visitor API without naming other tools
1 parent 8b31039 commit 03934ea

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎lib/css/syntax-parser.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17567,7 +17567,7 @@ const buildSkipSet = (nodeTypes) => {
1756717567

1756817568
/* eslint-disable jsdoc/require-template -- `A` below is the accessor const, not a type parameter */
1756917569
/**
17570-
* The CSS path (Babel's `path` shape): the AST accessor with the walk's
17570+
* The CSS path: the AST accessor with the walk's
1757117571
* current position on it — the single argument every visitor receives.
1757217572
* @typedef {typeof A} CssPath
1757317573
*/
@@ -17602,7 +17602,7 @@ const _materializeList = (n) => {
1760217602
return out;
1760317603
};
1760417604

17605-
// Babel's `path.skip()`, children-only: set by `A.skipChildren()` during an
17605+
// Children-only skip: set by `A.skipChildren()` during an
1760617606
// `enter` dispatch, consumed by the walk.
1760717607
let _walkSkip = false;
1760817608
// Set by `A.stop()` for the rest of the parse: no visitor fires after it, and a

‎lib/css/syntax.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const printer = () => _printer || (_printer = require("./syntax-printer"));
3535
* `grammar`. All configuration is per `process` call. `process(src, { minimize:
3636
* true })` returns `{ code, map }` — the safely-minified serialization (built by
3737
* the same walk that fires visitors) and its source map; without `minimize` it
38-
* just walks and returns `undefined`. Babel-style usage:
38+
* just walks and returns `undefined`. Usage:
3939
*
4040
* ```
4141
* new CssSourceProcessor().use({ [NodeType.AtRule]: (path) => {} }).process(source, { skip });

‎lib/html/syntax-parser.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13798,7 +13798,7 @@ const parseCssUrls = (input) => {
1379813798
return result;
1379913799
};
1380013800

13801-
// Babel's `path.skip()`, children-only: set by `A.skipChildren()` during an
13801+
// Children-only skip: set by `A.skipChildren()` during an
1380213802
// `enter` dispatch, consumed by the walk.
1380313803
let _walkSkip = false;
1380413804
// Set by `A.stop()` for the rest of the parse: no visitor fires after it, and a
@@ -13828,7 +13828,7 @@ let _cursorEpoch = 1;
1382813828

1382913829
/* eslint-disable jsdoc/require-template -- `A` below is the accessor const, not a type parameter */
1383013830
/**
13831-
* The HTML path (Babel's `path` shape): the AST accessor with the walk's
13831+
* The HTML path: the AST accessor with the walk's
1383213832
* current position on it — the single argument every visitor receives.
1383313833
* @typedef {typeof A} HtmlPath
1383413834
*/

‎lib/html/syntax.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const printer = () => _printer || (_printer = require("./syntax-printer"));
3232

3333
/**
3434
* The generic visitor coordinator (`util/SourceProcessor`) bound to the HTML
35-
* `grammar`. Babel-style usage:
35+
* `grammar`. Usage:
3636
*
3737
* ```
3838
* new HtmlSourceProcessor().use({ [NodeType.Element]: (path) => {}, [NodeType.Comment]: { enter, exit } }).process(source, { skip });

‎lib/util/SourceProcessor.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ const declineDeferredWrites = (text, writes) =>
119119
);
120120

121121
/**
122-
* Babel-style visitor map keyed by a numeric node-type discriminator; a bucket
122+
* Visitor map keyed by a numeric node-type discriminator; a bucket
123123
* is a function (enter-only) or `{ enter?, exit? }`.
124124
*
125-
* A visitor receives a single `path` argument (the Babel `path` shape): the
125+
* A visitor receives a single `path` argument: the
126126
* language's AST accessor with the current position on it — `path.node`,
127127
* `path.parent` (null at a root) — plus `path.skipChildren()` (enter only)
128128
* to stop the walk descending, and every field-read method (which defaults
@@ -1016,7 +1016,7 @@ class PrintContext {
10161016
* Visitor coordinator: owns the visitor registry and drives a language
10171017
* `grammar` over the source. Language-agnostic — each syntax (CSS, HTML, …)
10181018
* binds its own grammar, node-type enum and (optionally) node printer.
1019-
* Babel-style usage:
1019+
* Usage:
10201020
*
10211021
* ```
10221022
* processor.use({ [NodeType.X]: (path) => {}, [NodeType.Y]: { enter, exit } });
@@ -1049,7 +1049,7 @@ class SourceProcessor {
10491049
}
10501050

10511051
/**
1052-
* Register a Babel-style visitor map; calls accumulate per node type.
1052+
* Register a visitor map; calls accumulate per node type.
10531053
* A bucket is a function (= `{ enter }`) or `{ enter?, exit? }`.
10541054
* @overload
10551055
* @param {VisitorMap<TPath>} map visitor map keyed by node type

‎types.d.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6708,7 +6708,7 @@ declare interface CssProcessOptions {
67086708
* `grammar`. All configuration is per `process` call. `process(src, { minimize:
67096709
* true })` returns `{ code, map }` — the safely-minified serialization (built by
67106710
* the same walk that fires visitors) and its source map; without `minimize` it
6711-
* just walks and returns `undefined`. Babel-style usage:
6711+
* just walks and returns `undefined`. Usage:
67126712
* ```
67136713
* new CssSourceProcessor().use({ [NodeType.AtRule]: (path) => {} }).process(source, { skip });
67146714
* ```
@@ -11718,7 +11718,7 @@ declare interface HtmlResourceHintWebpackOptions {
1171811718

1171911719
/**
1172011720
* The generic visitor coordinator (`util/SourceProcessor`) bound to the HTML
11721-
* `grammar`. Babel-style usage:
11721+
* `grammar`. Usage:
1172211722
* ```
1172311723
* new HtmlSourceProcessor().use({ [NodeType.Element]: (path) => {}, [NodeType.Comment]: { enter, exit } }).process(source, { skip });
1172411724
* ```
@@ -29628,7 +29628,7 @@ declare interface SourcePosition {
2962829628
* Visitor coordinator: owns the visitor registry and drives a language
2962929629
* `grammar` over the source. Language-agnostic — each syntax (CSS, HTML, …)
2963029630
* binds its own grammar, node-type enum and (optionally) node printer.
29631-
* Babel-style usage:
29631+
* Usage:
2963229632
* ```
2963329633
* processor.use({ [NodeType.X]: (path) => {}, [NodeType.Y]: { enter, exit } });
2963429634
* processor.process(source);
@@ -29641,7 +29641,7 @@ declare abstract class SourceProcessor<
2964129641
TPrintOptions = object
2964229642
> {
2964329643
/**
29644-
* Register a Babel-style visitor map; calls accumulate per node type.
29644+
* Register a visitor map; calls accumulate per node type.
2964529645
* A bucket is a function (= `{ enter }`) or `{ enter?, exit? }`.
2964629646
*/
2964729647
use(
@@ -32187,9 +32187,9 @@ type VisitorBucket<TPath> =
3218732187
VisitorFn<TPath> | { enter?: VisitorFn<TPath>; exit?: VisitorFn<TPath> };
3218832188

3218932189
/**
32190-
* Babel-style visitor map keyed by a numeric node-type discriminator; a bucket
32190+
* Visitor map keyed by a numeric node-type discriminator; a bucket
3219132191
* is a function (enter-only) or `{ enter?, exit? }`.
32192-
* A visitor receives a single `path` argument (the Babel `path` shape): the
32192+
* A visitor receives a single `path` argument: the
3219332193
* language's AST accessor with the current position on it — `path.node`,
3219432194
* `path.parent` (null at a root) — plus `path.skipChildren()` (enter only)
3219532195
* to stop the walk descending, and every field-read method (which defaults

0 commit comments

Comments
 (0)