@cssdoc/core 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +267 -26
- package/dist/index.mjs +465 -315
- package/package.json +4 -5
- package/grammar/CssDoc.grammarkdown +0 -390
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,198 @@
|
|
|
1
|
+
//#region src/modifier.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The modifier convention — how a component's modifier variations are spelled in CSS, and the one
|
|
4
|
+
* place that spelling is turned into (and back out of) selectors. cssdoc is framework-agnostic, so it
|
|
5
|
+
* doesn't assume any single scheme: BEM (`.button--primary`, the default), rscss (`.button.-color-x`),
|
|
6
|
+
* bare/OOCSS chained classes (`.button.primary`), CUBE data-attribute exceptions
|
|
7
|
+
* (`.card[data-variant="ghost"]`), and anything expressible as the three structural forms below.
|
|
8
|
+
*
|
|
9
|
+
* {@link ModifierMatcher} is the single owner of modifier matching, prop/value analysis, and
|
|
10
|
+
* selector rendering — both `parse.ts` and `index.ts` route through it, so their notions of "what is a
|
|
11
|
+
* modifier" can't drift.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* How a modifier attaches to a component's base class.
|
|
17
|
+
*
|
|
18
|
+
* - `chained` — a separate class on the base element: `.base.primary` (bare/OOCSS), `.base.-mod`
|
|
19
|
+
* (rscss), `.base.is-open` (state). `separator` is the required class prefix (`""` = any chained
|
|
20
|
+
* class, `-`, `is-`).
|
|
21
|
+
* - `suffix` — appended into the base class name itself: `.button--primary` (BEM/SUIT). `separator` is
|
|
22
|
+
* the delimiter between the base and the modifier body (`--`).
|
|
23
|
+
* - `attribute` — an attribute selector on the base element: `.card[data-variant="ghost"]` (CUBE).
|
|
24
|
+
* `separator` is the required attribute-name prefix (`data-`; `""` = any attribute).
|
|
25
|
+
*/
|
|
26
|
+
interface ModifierConvention {
|
|
27
|
+
/** The structural form. An open union — further forms may be added without a breaking change. */
|
|
28
|
+
structure: "chained" | "suffix" | "attribute";
|
|
29
|
+
/**
|
|
30
|
+
* The prefix/delimiter, interpreted per {@link ModifierConvention.structure}. May be a single
|
|
31
|
+
* string or several — any one of which marks a modifier. Separators are matched literally.
|
|
32
|
+
*/
|
|
33
|
+
separator: string | string[];
|
|
34
|
+
/**
|
|
35
|
+
* The delimiter that marks a **BEM-style element** inside the base class name (e.g. `"__"` in
|
|
36
|
+
* `.block__element`). When set (`suffix` structure only), a matching class is recorded as a
|
|
37
|
+
* {@link https://cssdoc.dev part} rather than a modifier. Its own modifiers
|
|
38
|
+
* (`.block__element--mod`) are captured as part of the element name for now.
|
|
39
|
+
*/
|
|
40
|
+
elementSeparator?: string | string[];
|
|
41
|
+
/**
|
|
42
|
+
* Class prefixes that mark a **state** rather than a modifier (e.g. `["is-", "has-"]`). A class
|
|
43
|
+
* chained to the base whose name starts with one of these is recorded as a state, and is never
|
|
44
|
+
* treated as a modifier. Opt-in; no preset sets it by default.
|
|
45
|
+
*/
|
|
46
|
+
statePrefixes?: string[];
|
|
47
|
+
/**
|
|
48
|
+
* Native pseudo-classes (without the `:`) to recognize as states when they appear on the base,
|
|
49
|
+
* e.g. `["disabled", "checked"]`. Defaults to {@link DEFAULT_STATE_PSEUDO_CLASSES} — a curated set
|
|
50
|
+
* of form/UI states, deliberately excluding ubiquitous interaction pseudos (`:hover`, `:focus`).
|
|
51
|
+
*/
|
|
52
|
+
statePseudoClasses?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Split the modifier body into `prop`/`value` on {@link ModifierConvention.propValueSeparator}?
|
|
55
|
+
* Defaults to `false`. Ignored for `attribute` (which always derives `prop` from the attribute name
|
|
56
|
+
* and `value` from the attribute value).
|
|
57
|
+
*/
|
|
58
|
+
propValue?: boolean;
|
|
59
|
+
/** The separator for the `prop`/`value` split. Defaults to `-`. */
|
|
60
|
+
propValueSeparator?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The pseudo-classes cssdoc treats as component states by default — form and UI states a component
|
|
64
|
+
* meaningfully declares. Ubiquitous interaction pseudos (`:hover`, `:focus`, `:active`) are omitted so
|
|
65
|
+
* incidental rules don't become documented states; add them via `statePseudoClasses` if you want them.
|
|
66
|
+
*/
|
|
67
|
+
declare const DEFAULT_STATE_PSEUDO_CLASSES: readonly string[];
|
|
68
|
+
/** The built-in convention presets. Other schemes use the custom object (see the docs). */
|
|
69
|
+
declare const MODIFIER_PRESETS: {
|
|
70
|
+
/** BEM / SUIT — `.button--primary`, with `.button__element` sub-elements. The default. */readonly bem: {
|
|
71
|
+
readonly structure: "suffix";
|
|
72
|
+
readonly separator: "--";
|
|
73
|
+
readonly elementSeparator: "__";
|
|
74
|
+
readonly propValue: false;
|
|
75
|
+
}; /** rscss — `.button.-color-secondary`, split into `prop`/`value`. */
|
|
76
|
+
readonly rscss: {
|
|
77
|
+
readonly structure: "chained";
|
|
78
|
+
readonly separator: "-";
|
|
79
|
+
readonly propValue: true;
|
|
80
|
+
readonly propValueSeparator: "-";
|
|
81
|
+
}; /** OOCSS / bare chained classes — `.button.primary` (any class chained to the base). */
|
|
82
|
+
readonly bare: {
|
|
83
|
+
readonly structure: "chained";
|
|
84
|
+
readonly separator: "";
|
|
85
|
+
readonly propValue: false;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/** A preset name, or a full custom {@link ModifierConvention}. */
|
|
89
|
+
type ModifierConventionInput = keyof typeof MODIFIER_PRESETS | ModifierConvention;
|
|
90
|
+
/** The default convention: BEM. */
|
|
91
|
+
declare const DEFAULT_MODIFIER_CONVENTION: ModifierConvention;
|
|
92
|
+
/**
|
|
93
|
+
* Resolve a preset name or custom object into a fully-populated {@link ModifierConvention} (defaults
|
|
94
|
+
* filled in). No argument resolves to the {@link DEFAULT_MODIFIER_CONVENTION} (BEM).
|
|
95
|
+
*
|
|
96
|
+
* @throws If given an unknown preset name.
|
|
97
|
+
*/
|
|
98
|
+
declare function resolveModifierConvention(input?: ModifierConventionInput): ModifierConvention;
|
|
99
|
+
/** One modifier found on a selector: its canonical name plus the derived `prop`/`value`. */
|
|
100
|
+
interface ModifierHit {
|
|
101
|
+
/** The modifier as written, minus outer punctuation — `button--primary`, `-color-secondary`,
|
|
102
|
+
* `primary`, or `data-variant="ghost"`. Render it back with {@link ModifierMatcher.selectorFor}. */
|
|
103
|
+
name: string;
|
|
104
|
+
/** The property segment (a grouping key). */
|
|
105
|
+
prop: string;
|
|
106
|
+
/** The value segment; absent for boolean modifiers. */
|
|
107
|
+
value?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The single owner of modifier recognition for one convention: finds modifiers on selectors, derives
|
|
111
|
+
* `prop`/`value`, renders a modifier name back to a selector fragment, and answers "does this host-doc
|
|
112
|
+
* token look like a modifier usage?". Constructed once per parse from the resolved convention.
|
|
113
|
+
*/
|
|
114
|
+
declare class ModifierMatcher {
|
|
115
|
+
readonly convention: ModifierConvention;
|
|
116
|
+
/** The separator(s), longest-first so overlapping prefixes (e.g. `--` before `-`) match greedily. */
|
|
117
|
+
private readonly separators;
|
|
118
|
+
/** The separators as a non-capturing regex alternation, e.g. `(?:is-|has-)` (or `(?:)` when empty). */
|
|
119
|
+
private readonly sepAlt;
|
|
120
|
+
/** BEM-style element separators (longest-first), or empty when the convention has none. */
|
|
121
|
+
private readonly elementSeparators;
|
|
122
|
+
/** The element separators as a non-capturing alternation, or `""` when there are none. */
|
|
123
|
+
private readonly elementSepAlt;
|
|
124
|
+
/** State-class prefixes (longest-first), or empty when the convention has none. */
|
|
125
|
+
private readonly statePrefixes;
|
|
126
|
+
/** Native pseudo-classes (no `:`) recognized as states. */
|
|
127
|
+
private readonly statePseudoClasses;
|
|
128
|
+
constructor(convention: ModifierConvention);
|
|
129
|
+
/** Does a class name (no leading dot) start with one of the convention's state prefixes? */
|
|
130
|
+
private isStateClass;
|
|
131
|
+
/** Strip a leading chained-class separator from `name` (the longest that matches), else return it. */
|
|
132
|
+
private stripPrefix;
|
|
133
|
+
/** Return the suffix body — the part after the first (longest) non-empty separator occurrence. */
|
|
134
|
+
private stripToBody;
|
|
135
|
+
/**
|
|
136
|
+
* Every modifier attached to `baseNoDot` within one selector. `selector` should have its pseudos
|
|
137
|
+
* already dropped (as `parse.ts`/`index.ts` do); the base is given without its leading dot.
|
|
138
|
+
*/
|
|
139
|
+
modifiersIn(selector: string, baseNoDot: string): ModifierHit[];
|
|
140
|
+
/**
|
|
141
|
+
* Every BEM-style element attached to `baseNoDot` within one selector (`.base<elementSep><name>`),
|
|
142
|
+
* as parts, each with any element-scoped modifiers (`.base__element--mod` → element `base__element`
|
|
143
|
+
* with modifier `mod`). Only meaningful for `suffix` conventions with an `elementSeparator`.
|
|
144
|
+
*/
|
|
145
|
+
elementsIn(selector: string, baseNoDot: string): {
|
|
146
|
+
name: string;
|
|
147
|
+
modifiers: ModifierHit[];
|
|
148
|
+
}[];
|
|
149
|
+
/**
|
|
150
|
+
* Split `.base__element--mod`-style tokens into the element class (`base__element`) and, if a
|
|
151
|
+
* modifier separator follows the element name, the element-scoped modifier.
|
|
152
|
+
*/
|
|
153
|
+
private splitElementModifier;
|
|
154
|
+
/**
|
|
155
|
+
* Every state class chained to `baseNoDot` within one selector — a class whose name starts with one
|
|
156
|
+
* of the convention's {@link ModifierConvention.statePrefixes} (e.g. `.tabs.is-open` → `is-open`).
|
|
157
|
+
* Empty when the convention sets no state prefixes.
|
|
158
|
+
*/
|
|
159
|
+
statesIn(selector: string, baseNoDot: string): {
|
|
160
|
+
name: string;
|
|
161
|
+
}[];
|
|
162
|
+
/**
|
|
163
|
+
* Every native pseudo-class on the selector recognized as a state — a `:name` whose `name` is in the
|
|
164
|
+
* convention's {@link ModifierConvention.statePseudoClasses} (e.g. `.tab:disabled` → `disabled`).
|
|
165
|
+
* Pseudo-elements (`::part`) and pseudos not in the set are ignored.
|
|
166
|
+
*/
|
|
167
|
+
pseudoStatesIn(selector: string): {
|
|
168
|
+
name: string;
|
|
169
|
+
}[];
|
|
170
|
+
/** Derive `prop`/`value` for a modifier `name` (as returned by {@link modifiersIn} or authored). */
|
|
171
|
+
analyze(name: string): {
|
|
172
|
+
prop: string;
|
|
173
|
+
value?: string;
|
|
174
|
+
};
|
|
175
|
+
/** Render a modifier `name` as the selector fragment it denotes (`.name` or `[name]`). */
|
|
176
|
+
selectorFor(name: string): string;
|
|
177
|
+
/** Normalize a member token/expression to its canonical `name` key (the inverse of authoring noise). */
|
|
178
|
+
normalizeMember(token: string): string;
|
|
179
|
+
/**
|
|
180
|
+
* Does a token/expression seen in a host document (an HTML class token, or an attribute expression)
|
|
181
|
+
* look like a modifier usage of `baseNoDot`? Replaces the old `startsWith("-")` gate.
|
|
182
|
+
*/
|
|
183
|
+
looksLikeUsage(token: string, baseNoDot?: string): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Classify a host-document class token relative to `baseNoDot`: a `modifier` usage, a `state` class
|
|
186
|
+
* (a `statePrefixes` prefix), a BEM `element` class (`base<elementSep>…`), or `undefined` if it's
|
|
187
|
+
* none of those. Consumer-side linting routes each kind to the right "unknown-…" check.
|
|
188
|
+
*/
|
|
189
|
+
usageKind(token: string, baseNoDot?: string): "modifier" | "state" | "element" | undefined;
|
|
190
|
+
/** Canonicalize an attribute expression (bracket-inner): normalize quotes to double, trim. */
|
|
191
|
+
private normalizeAttribute;
|
|
192
|
+
/** Does an attribute-expression's name carry one of the convention's required prefixes? */
|
|
193
|
+
private attributeMatches;
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
1
196
|
//#region src/configuration.d.ts
|
|
2
197
|
/**
|
|
3
198
|
* The syntactic kind of a tag, mirroring TSDoc's Block/Modifier/Inline split, plus cssdoc's own
|
|
@@ -49,7 +244,12 @@ declare class CssDocConfiguration {
|
|
|
49
244
|
private readonly _tagDefinitions;
|
|
50
245
|
private readonly _byName;
|
|
51
246
|
private readonly _supported;
|
|
247
|
+
private _modifierConvention;
|
|
52
248
|
constructor();
|
|
249
|
+
/** The resolved modifier convention this configuration parses with (defaults to BEM). */
|
|
250
|
+
get modifierConvention(): ModifierConvention;
|
|
251
|
+
/** Set the modifier convention from a preset name or a custom {@link ModifierConvention}. */
|
|
252
|
+
setModifierConvention(input: ModifierConventionInput): void;
|
|
53
253
|
/** Every registered tag definition, in registration order. */
|
|
54
254
|
get tagDefinitions(): readonly CssDocTagDefinition[];
|
|
55
255
|
/** Only the tag definitions that are currently supported. */
|
|
@@ -73,9 +273,9 @@ declare class CssDocConfiguration {
|
|
|
73
273
|
setSupportForTags(definitions: readonly CssDocTagDefinition[], supported: boolean): void;
|
|
74
274
|
/** Disable support for every standard tag (custom tags added later remain supported). */
|
|
75
275
|
setNoStandardTags(): void;
|
|
76
|
-
/** The names (without `@`) of every standard tag
|
|
276
|
+
/** The names (without `@`) of every standard tag — the canonical vocabulary from `@cssdoc/spec`. */
|
|
77
277
|
static readonly standardTagNames: readonly string[];
|
|
78
|
-
/** A fresh set of the standard tag definitions (new instances on each call). */
|
|
278
|
+
/** A fresh set of the standard tag definitions (new instances on each call), built from the spec. */
|
|
79
279
|
static standardTags(): CssDocTagDefinition[];
|
|
80
280
|
}
|
|
81
281
|
//#endregion
|
|
@@ -93,13 +293,20 @@ declare class CssDocConfiguration {
|
|
|
93
293
|
*
|
|
94
294
|
* @module
|
|
95
295
|
*/
|
|
96
|
-
/**
|
|
296
|
+
/**
|
|
297
|
+
* A modifier variation on a component's base class. How modifiers are spelled is configurable (see
|
|
298
|
+
* {@link ParseOptions.modifierConvention}); the default is BEM (`.button--primary`).
|
|
299
|
+
*/
|
|
97
300
|
interface CssModifier {
|
|
98
|
-
/**
|
|
301
|
+
/**
|
|
302
|
+
* The modifier as written, minus its outer punctuation — its exact spelling depends on the
|
|
303
|
+
* convention: `button--primary` (BEM, the default), `-color-secondary` (rscss), `primary`
|
|
304
|
+
* (bare/OOCSS), or `data-variant="ghost"` (CUBE attribute).
|
|
305
|
+
*/
|
|
99
306
|
name: string;
|
|
100
|
-
/** The property segment
|
|
307
|
+
/** The property segment — a grouping key derived from the modifier (e.g. `color`, `variant`, `primary`). */
|
|
101
308
|
prop: string;
|
|
102
|
-
/** The value segment, e.g. `secondary`; absent for boolean modifiers. */
|
|
309
|
+
/** The value segment, e.g. `secondary` or `ghost`; absent for boolean/flag modifiers. */
|
|
103
310
|
value?: string;
|
|
104
311
|
/** Prose from a `@modifier` doc tag, when authored. */
|
|
105
312
|
description?: string;
|
|
@@ -117,13 +324,23 @@ interface CssModifier {
|
|
|
117
324
|
interface CssPart {
|
|
118
325
|
/** The part class without the leading dot, e.g. `item`. */
|
|
119
326
|
name: string;
|
|
120
|
-
/** Prose from a `@part`
|
|
327
|
+
/** Prose from a `@part` doc tag, when authored. */
|
|
121
328
|
description?: string;
|
|
329
|
+
/** The part's own modifiers, e.g. `.block__element--active` on a BEM element. Present when non-empty. */
|
|
330
|
+
modifiers?: CssModifier[];
|
|
122
331
|
}
|
|
123
|
-
/**
|
|
332
|
+
/**
|
|
333
|
+
* How a component state is spelled — the CSSOM custom state `:state(x)`, a native pseudo-class
|
|
334
|
+
* (`:disabled`), or a state class from the convention's `statePrefixes` (`.is-open`). Only `custom`
|
|
335
|
+
* maps to a Custom Elements Manifest `cssStates` entry.
|
|
336
|
+
*/
|
|
337
|
+
type CssStateKind = "custom" | "pseudo-class" | "class";
|
|
338
|
+
/** A component state — from `:state()`, a native pseudo-class, or a state class (`@cssstate`). */
|
|
124
339
|
interface CssState {
|
|
125
|
-
/** The state name, e.g. `open` or `
|
|
340
|
+
/** The state name without its punctuation, e.g. `open`, `selected`, or `disabled`. */
|
|
126
341
|
name: string;
|
|
342
|
+
/** How the state is expressed in CSS. */
|
|
343
|
+
kind: CssStateKind;
|
|
127
344
|
/** Prose from a `@cssstate` doc tag, when authored. */
|
|
128
345
|
description?: string;
|
|
129
346
|
}
|
|
@@ -196,13 +413,14 @@ type CssRecordKind = "component" | "utility" | "rule" | "declaration";
|
|
|
196
413
|
*/
|
|
197
414
|
type CssReleaseStage = "alpha" | "beta" | "experimental" | "internal" | "public";
|
|
198
415
|
/**
|
|
199
|
-
* A node in an authored
|
|
200
|
-
* children
|
|
416
|
+
* A node in an authored structure tree (`@structure`), written as nested CSS: a compound selector for
|
|
417
|
+
* the element and its children (the rules nested inside it). Emitters render the tree and, via
|
|
418
|
+
* {@link toMermaid}, a diagram.
|
|
201
419
|
*/
|
|
202
420
|
interface StructureNode {
|
|
203
|
-
/** The node's selector
|
|
421
|
+
/** The node's compound selector, e.g. `.tabs`, `.tab.-selected`, or `.list:has(.tab)`. */
|
|
204
422
|
selector: string;
|
|
205
|
-
/** Child nodes (one
|
|
423
|
+
/** Child nodes (rules nested one brace level deeper). */
|
|
206
424
|
children: StructureNode[];
|
|
207
425
|
}
|
|
208
426
|
/** One documented CSS record: its base class plus everything derived from the CSS + doc comments. */
|
|
@@ -229,9 +447,11 @@ interface CssDocEntry {
|
|
|
229
447
|
accessibility?: string;
|
|
230
448
|
/** AST-extracted modifiers, annotated with `@modifier` prose where authored. */
|
|
231
449
|
modifiers: CssModifier[];
|
|
232
|
-
/** AST-extracted sub-element parts, annotated with `@part
|
|
450
|
+
/** AST-extracted sub-element parts (class-based), annotated with `@part` prose where authored. */
|
|
233
451
|
parts: CssPart[];
|
|
234
|
-
/**
|
|
452
|
+
/** Shadow-DOM exposed parts (`::part(name)`), from `@csspart` or a `::part()` selector. */
|
|
453
|
+
shadowParts: CssPart[];
|
|
454
|
+
/** States the component reacts to, from `@cssstate`, `:state()`, pseudo-classes, or state classes. */
|
|
235
455
|
states: CssState[];
|
|
236
456
|
/** Named slots the component shell exposes, from `@slot`. */
|
|
237
457
|
slots: CssSlot[];
|
|
@@ -249,8 +469,10 @@ interface CssDocEntry {
|
|
|
249
469
|
conditions: CssCondition[];
|
|
250
470
|
/** `@example` blocks, verbatim. */
|
|
251
471
|
examples: string[];
|
|
252
|
-
/** The authored `@structure`
|
|
472
|
+
/** The authored `@structure` element tree (top-level nodes), when present. */
|
|
253
473
|
structure?: StructureNode[];
|
|
474
|
+
/** An optional prose description leading the `@structure` body, when authored. */
|
|
475
|
+
structureDescription?: string;
|
|
254
476
|
/** `@demo <spec>` (e.g. `self:button`), when authored. */
|
|
255
477
|
demo?: string;
|
|
256
478
|
/** Component-level deprecation replacement text, when authored (the argument to a `@deprecated` tag). */
|
|
@@ -263,6 +485,8 @@ interface CssDocEntry {
|
|
|
263
485
|
*/
|
|
264
486
|
customBlocks?: Record<string, string[]>;
|
|
265
487
|
}
|
|
488
|
+
/** A PostCSS parse function — turns a source string into a Root. Inject one to read a non-CSS dialect. */
|
|
489
|
+
type CssParse = (css: string) => import("postcss").Root;
|
|
266
490
|
/** Options for {@link parseCssDocs}. */
|
|
267
491
|
interface ParseOptions {
|
|
268
492
|
/**
|
|
@@ -277,6 +501,17 @@ interface ParseOptions {
|
|
|
277
501
|
* Supply one (e.g. from `@cssdoc/config`) to register custom tags or disable standard ones.
|
|
278
502
|
*/
|
|
279
503
|
configuration?: CssDocConfiguration;
|
|
504
|
+
/**
|
|
505
|
+
* The modifier convention — how modifier classes are spelled (BEM `.button--primary` by default;
|
|
506
|
+
* `rscss`, `bare`, or a custom `ModifierConvention` for SUIT/CUBE/etc.). Overrides the
|
|
507
|
+
* `configuration`'s convention when both are given.
|
|
508
|
+
*/
|
|
509
|
+
modifierConvention?: ModifierConventionInput;
|
|
510
|
+
/**
|
|
511
|
+
* The PostCSS parser to read `css` with. Defaults to `postcss.parse` (plain CSS). Inject a dialect
|
|
512
|
+
* parser (e.g. `postcss-scss`/`postcss-less` via `@cssdoc/dialects`) to document `.scss`/`.less`.
|
|
513
|
+
*/
|
|
514
|
+
parse?: CssParse;
|
|
280
515
|
}
|
|
281
516
|
//#endregion
|
|
282
517
|
//#region src/parse.d.ts
|
|
@@ -357,8 +592,10 @@ interface ParsedDoc {
|
|
|
357
592
|
releaseStage?: CssReleaseStage;
|
|
358
593
|
/** `@modifier` prose, keyed by the modifier class without its dot (e.g. `-color-secondary`). */
|
|
359
594
|
modifiers: Map<string, DocModifier>;
|
|
360
|
-
/** `@part
|
|
595
|
+
/** `@part` descriptions, keyed by the class part name without its dot (e.g. `item`). */
|
|
361
596
|
parts: Map<string, string>;
|
|
597
|
+
/** `@csspart` descriptions (shadow-DOM `::part()`), keyed by the bare part name (e.g. `header`). */
|
|
598
|
+
cssParts: Map<string, string>;
|
|
362
599
|
/** `@cssproperty` declarations. */
|
|
363
600
|
cssProperties: DocCssProperty[];
|
|
364
601
|
/** `@cssstate` descriptions, keyed by state name. */
|
|
@@ -375,8 +612,10 @@ interface ParsedDoc {
|
|
|
375
612
|
conditions: DocCondition[];
|
|
376
613
|
/** `@example` blocks. */
|
|
377
614
|
examples: string[];
|
|
378
|
-
/** `@structure` — the
|
|
615
|
+
/** `@structure` — the nested-CSS body, parsed into a selector tree by {@link parseStructure}. */
|
|
379
616
|
structure?: StructureNode[];
|
|
617
|
+
/** An optional prose description leading the `@structure` body. */
|
|
618
|
+
structureDescription?: string;
|
|
380
619
|
/** The `<replacement>` argument from a `@deprecated` tag. */
|
|
381
620
|
deprecated?: string;
|
|
382
621
|
/** `@demo <spec>`. */
|
|
@@ -408,16 +647,18 @@ declare function parseDocComment(raw: string, configuration?: CssDocConfiguratio
|
|
|
408
647
|
*/
|
|
409
648
|
declare function recordNameOf(commentText: string, configuration?: CssDocConfiguration): string | undefined;
|
|
410
649
|
/**
|
|
411
|
-
* Parse a `@structure` body —
|
|
412
|
-
*
|
|
413
|
-
*
|
|
650
|
+
* Parse a `@structure` body — nested CSS (brace-delimited rules) — into a {@link StructureNode} tree.
|
|
651
|
+
* Each rule's selector becomes a node; nested rules become its children. Because a node is a real
|
|
652
|
+
* compound selector, `:has()` (contains), `:is()` / selector-lists (one-of), and `:not()` (not) express
|
|
653
|
+
* relationships natively. Leaf nodes are written as empty rules (`.tab {}`). A malformed body parses to
|
|
654
|
+
* an empty tree rather than throwing.
|
|
414
655
|
*
|
|
415
656
|
* @example
|
|
416
657
|
* ```
|
|
417
|
-
* .tabs
|
|
418
|
-
* .list
|
|
419
|
-
*
|
|
420
|
-
*
|
|
658
|
+
* .tabs {
|
|
659
|
+
* .list { .tab {} }
|
|
660
|
+
* .panel {}
|
|
661
|
+
* }
|
|
421
662
|
* ```
|
|
422
663
|
*/
|
|
423
664
|
declare function parseStructure(raw: string): StructureNode[];
|
|
@@ -454,4 +695,4 @@ declare function toMermaid(roots: StructureNode[], options?: {
|
|
|
454
695
|
*/
|
|
455
696
|
declare function toJson(model: CssDocEntry[]): string;
|
|
456
697
|
//#endregion
|
|
457
|
-
export { type CssAnimation, type CssCondition, CssDocConfiguration, type CssDocEntry, type CssDocSyntaxKind, CssDocTagDefinition, type CssDocTagDefinitionOptions, type CssFunction, type CssLayer, type CssModifier, type CssPart, type CssPropertyDeclared, type CssRecordKind, type CssReleaseStage, type CssSlot, type CssState, type DocCondition, type DocCssProperty, type DocModifier, type ParseOptions, type ParsedDoc, RECORD_TAGS, type StructureNode, parseCssDocs, parseDocComment, parseStructure, recordNameOf, stripCommentFraming, toJson, toMermaid };
|
|
698
|
+
export { type CssAnimation, type CssCondition, CssDocConfiguration, type CssDocEntry, type CssDocSyntaxKind, CssDocTagDefinition, type CssDocTagDefinitionOptions, type CssFunction, type CssLayer, type CssModifier, type CssParse, type CssPart, type CssPropertyDeclared, type CssRecordKind, type CssReleaseStage, type CssSlot, type CssState, DEFAULT_MODIFIER_CONVENTION, DEFAULT_STATE_PSEUDO_CLASSES, type DocCondition, type DocCssProperty, type DocModifier, MODIFIER_PRESETS, type ModifierConvention, type ModifierConventionInput, type ModifierHit, ModifierMatcher, type ParseOptions, type ParsedDoc, RECORD_TAGS, type StructureNode, parseCssDocs, parseDocComment, parseStructure, recordNameOf, resolveModifierConvention, stripCommentFraming, toJson, toMermaid };
|