@cssdoc/core 0.4.1 → 0.5.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.
@@ -0,0 +1,749 @@
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
+ /** Set when the name is a `*` family (e.g. `-icon-*`, derived from a `[class*="-icon-"]` selector). */
109
+ pattern?: boolean;
110
+ }
111
+ /**
112
+ * The single owner of modifier recognition for one convention: finds modifiers on selectors, derives
113
+ * `prop`/`value`, renders a modifier name back to a selector fragment, and answers "does this host-doc
114
+ * token look like a modifier usage?". Constructed once per parse from the resolved convention.
115
+ */
116
+ declare class ModifierMatcher {
117
+ readonly convention: ModifierConvention;
118
+ /** The separator(s), longest-first so overlapping prefixes (e.g. `--` before `-`) match greedily. */
119
+ private readonly separators;
120
+ /** The separators as a non-capturing regex alternation, e.g. `(?:is-|has-)` (or `(?:)` when empty). */
121
+ private readonly sepAlt;
122
+ /** BEM-style element separators (longest-first), or empty when the convention has none. */
123
+ private readonly elementSeparators;
124
+ /** The element separators as a non-capturing alternation, or `""` when there are none. */
125
+ private readonly elementSepAlt;
126
+ /** State-class prefixes (longest-first), or empty when the convention has none. */
127
+ private readonly statePrefixes;
128
+ /** Native pseudo-classes (no `:`) recognized as states. */
129
+ private readonly statePseudoClasses;
130
+ constructor(convention: ModifierConvention);
131
+ /** Does a class name (no leading dot) start with one of the convention's state prefixes? */
132
+ private isStateClass;
133
+ /** Strip a leading chained-class separator from `name` (the longest that matches), else return it. */
134
+ private stripPrefix;
135
+ /** Return the suffix body — the part after the first (longest) non-empty separator occurrence. */
136
+ private stripToBody;
137
+ /**
138
+ * Every modifier attached to `baseNoDot` within one selector. `selector` should have its pseudos
139
+ * already dropped (as `parse.ts`/`index.ts` do); the base is given without its leading dot.
140
+ */
141
+ modifiersIn(selector: string, baseNoDot: string): ModifierHit[];
142
+ /**
143
+ * Family modifiers declared by a `class` attribute selector on the base — `.base[class*="-icon-"]`
144
+ * yields the `*` family `-icon-*`. The operator maps to the wildcard position: `*=`/`|=` and (rare)
145
+ * exact `~=`/`=` derive a prefix family or a concrete name, `$=` a suffix family; `^=` is skipped
146
+ * (it anchors to the start of the whole class attribute — the base class — not a chained modifier).
147
+ * The value must begin with a convention separator to count (so `[class*="-icon-"]` does, `[dir]` and
148
+ * `[class*="grid"]` don't), and carry a literal core beyond the separator.
149
+ */
150
+ private classAttrFamilies;
151
+ /** Derive a modifier name from a `[class OP value]` selector, or `undefined` when it isn't one. */
152
+ private classAttrFamily;
153
+ /**
154
+ * Every BEM-style element attached to `baseNoDot` within one selector (`.base<elementSep><name>`),
155
+ * as parts, each with any element-scoped modifiers (`.base__element--mod` → element `base__element`
156
+ * with modifier `mod`). Only meaningful for `suffix` conventions with an `elementSeparator`.
157
+ */
158
+ elementsIn(selector: string, baseNoDot: string): {
159
+ name: string;
160
+ modifiers: ModifierHit[];
161
+ }[];
162
+ /**
163
+ * Split `.base__element--mod`-style tokens into the element class (`base__element`) and, if a
164
+ * modifier separator follows the element name, the element-scoped modifier.
165
+ */
166
+ private splitElementModifier;
167
+ /**
168
+ * Every state class chained to `baseNoDot` within one selector — a class whose name starts with one
169
+ * of the convention's {@link ModifierConvention.statePrefixes} (e.g. `.tabs.is-open` → `is-open`).
170
+ * Empty when the convention sets no state prefixes.
171
+ */
172
+ statesIn(selector: string, baseNoDot: string): {
173
+ name: string;
174
+ }[];
175
+ /**
176
+ * Every native pseudo-class on the selector recognized as a state — a `:name` whose `name` is in the
177
+ * convention's {@link ModifierConvention.statePseudoClasses} (e.g. `.tab:disabled` → `disabled`).
178
+ * Pseudo-elements (`::part`) and pseudos not in the set are ignored.
179
+ */
180
+ pseudoStatesIn(selector: string): {
181
+ name: string;
182
+ }[];
183
+ /** Derive `prop`/`value` for a modifier `name` (as returned by {@link modifiersIn} or authored). */
184
+ analyze(name: string): {
185
+ prop: string;
186
+ value?: string;
187
+ };
188
+ /** Render a modifier `name` as the selector fragment it denotes (`.name` or `[name]`). */
189
+ selectorFor(name: string): string;
190
+ /**
191
+ * Whether a used class `used` is an instance of the documented modifier `name` — an exact match, or,
192
+ * when `name` is a `*` family (e.g. `-icon-*`), a glob match (`*` → any `[\w-]` run). Used consumer-side
193
+ * so `-icon-arrow` resolves to the documented `-icon-*` family.
194
+ */
195
+ matchesModifier(name: string, used: string): boolean;
196
+ /** Normalize a member token/expression to its canonical `name` key (the inverse of authoring noise). */
197
+ normalizeMember(token: string): string;
198
+ /**
199
+ * Does a token/expression seen in a host document (an HTML class token, or an attribute expression)
200
+ * look like a modifier usage of `baseNoDot`? Replaces the old `startsWith("-")` gate.
201
+ */
202
+ looksLikeUsage(token: string, baseNoDot?: string): boolean;
203
+ /**
204
+ * Classify a host-document class token relative to `baseNoDot`: a `modifier` usage, a `state` class
205
+ * (a `statePrefixes` prefix), a BEM `element` class (`base<elementSep>…`), or `undefined` if it's
206
+ * none of those. Consumer-side linting routes each kind to the right "unknown-…" check.
207
+ */
208
+ usageKind(token: string, baseNoDot?: string): "modifier" | "state" | "element" | undefined;
209
+ /** Canonicalize an attribute expression (bracket-inner): normalize quotes to double, trim. */
210
+ private normalizeAttribute;
211
+ /** Does an attribute-expression's name carry one of the convention's required prefixes? */
212
+ private attributeMatches;
213
+ }
214
+ //#endregion
215
+ //#region src/model.d.ts
216
+ /**
217
+ * The serializable CSS-documentation model — the output-agnostic IR produced by {@link parseCssDocs}.
218
+ * Emitters (markdown, JSON, …) consume this; it carries no assumptions about any particular project,
219
+ * class prefix, or output format.
220
+ *
221
+ * The model documents the modern CSSOM surface a stylesheet exposes: modifiers and parts, registered
222
+ * custom properties (`@property`), custom functions (`@function`), animations (`@keyframes`), cascade
223
+ * layers (`@layer`), conditional-support blocks (`@container`/`@supports`/`@media`), states, and slots.
224
+ * Facts that can be derived from the CSS AST are derived (so they can't drift); doc-comment tags supply
225
+ * the prose.
226
+ *
227
+ * @module
228
+ */
229
+ /**
230
+ * A modifier variation on a component's base class. How modifiers are spelled is configurable (see
231
+ * {@link ParseOptions.modifierConvention}); the default is BEM (`.button--primary`).
232
+ */
233
+ interface CssModifier {
234
+ /**
235
+ * The modifier as written, minus its outer punctuation — its exact spelling depends on the
236
+ * convention: `button--primary` (BEM, the default), `-color-secondary` (rscss), `primary`
237
+ * (bare/OOCSS), or `data-variant="ghost"` (CUBE attribute).
238
+ */
239
+ name: string;
240
+ /** The property segment — a grouping key derived from the modifier (e.g. `color`, `variant`, `primary`). */
241
+ prop: string;
242
+ /** The value segment, e.g. `secondary` or `ghost`; absent for boolean/flag modifiers. */
243
+ value?: string;
244
+ /**
245
+ * Set when this is a `*` family (e.g. `-icon-*`) rather than a single modifier — authored as
246
+ * `@modifier -icon-*` and/or derived from a `[class*="-icon-"]` selector. Concrete usages
247
+ * (`-icon-arrow`) are matched against it as instances.
248
+ */
249
+ pattern?: boolean;
250
+ /** Prose from a `@modifier` doc tag, when authored. */
251
+ description?: string;
252
+ /**
253
+ * Set when the modifier is deprecated. `canonical` (from an AST alias marker) is the modifier class
254
+ * to use instead; `note` (from an authored inline deprecation tag on the `@modifier` line) is
255
+ * free-text replacement guidance for cases where the replacement isn't itself a modifier.
256
+ */
257
+ deprecated?: {
258
+ canonical?: string;
259
+ note?: string;
260
+ };
261
+ }
262
+ /** A sub-element ("part") of a component — a scoped child class like `.item` or `.tip`. */
263
+ interface CssPart {
264
+ /** The part class without the leading dot, e.g. `item`. */
265
+ name: string;
266
+ /** Prose from a `@part` doc tag, when authored. */
267
+ description?: string;
268
+ /** The part's own modifiers, e.g. `.block__element--active` on a BEM element. Present when non-empty. */
269
+ modifiers?: CssModifier[];
270
+ }
271
+ /**
272
+ * How a component state is spelled — the CSSOM custom state `:state(x)`, a native pseudo-class
273
+ * (`:disabled`), or a state class from the convention's `statePrefixes` (`.is-open`). Only `custom`
274
+ * maps to a Custom Elements Manifest `cssStates` entry.
275
+ */
276
+ type CssStateKind = "custom" | "pseudo-class" | "class";
277
+ /** A component state — from `:state()`, a native pseudo-class, or a state class (`@cssstate`). */
278
+ interface CssState {
279
+ /** The state name without its punctuation, e.g. `open`, `selected`, or `disabled`. */
280
+ name: string;
281
+ /** How the state is expressed in CSS. */
282
+ kind: CssStateKind;
283
+ /** Prose from a `@cssstate` doc tag, when authored. */
284
+ description?: string;
285
+ }
286
+ /** A named slot a component shell exposes (`@slot`, Custom Elements Manifest). */
287
+ interface CssSlot {
288
+ /** The slot name (empty string for the default slot). */
289
+ name: string;
290
+ /** Prose from a `@slot` doc tag, when authored. */
291
+ description?: string;
292
+ }
293
+ /** A custom property the component declares (`@property`) or documents (`@cssproperty`). */
294
+ interface CssPropertyDeclared {
295
+ /** The custom-property name, e.g. `--value`. */
296
+ name: string;
297
+ /** The `@property` `syntax` descriptor, e.g. `<number>`, when known. */
298
+ syntax?: string;
299
+ /** The `@property` `inherits` flag, when declared. */
300
+ inherits?: boolean;
301
+ /** The default value (`@property` `initial-value`, or an authored `@defaultValue`), when known. */
302
+ defaultValue?: string;
303
+ /** Prose from a `@cssproperty` doc tag, when authored. */
304
+ description?: string;
305
+ }
306
+ /** A CSS custom function (`@function --name`) the stylesheet defines. */
307
+ interface CssFunction {
308
+ /** The function name, e.g. `--negate`. */
309
+ name: string;
310
+ /** The declared parameters, e.g. `["--value"]`, when derivable from the `@function` at-rule. */
311
+ parameters: string[];
312
+ /** The `result` descriptor/type, when declared. */
313
+ result?: string;
314
+ /** Prose from a `@function` doc tag, when authored. */
315
+ description?: string;
316
+ }
317
+ /** An animation the component exposes (`@keyframes` at-rule / `@animation` doc tag). */
318
+ interface CssAnimation {
319
+ /** The animation (keyframes) name. */
320
+ name: string;
321
+ /** Prose from an `@animation`/`@keyframes` doc tag, when authored. */
322
+ description?: string;
323
+ }
324
+ /** A cascade layer the stylesheet participates in (`@layer`). */
325
+ interface CssLayer {
326
+ /** The layer name, possibly dotted (e.g. `theme.dark`). */
327
+ name: string;
328
+ /** Prose from a `@layer` doc tag, when authored. */
329
+ description?: string;
330
+ }
331
+ /** A conditional-support block the component's rules sit under. */
332
+ interface CssCondition {
333
+ /** Which at-rule expressed the condition. */
334
+ type: "container" | "supports" | "media";
335
+ /** The condition text, e.g. `(min-width: 40rem)` or `(display: grid)`. */
336
+ query: string;
337
+ /** A container name, for `@container` blocks that target a named container. */
338
+ containerName?: string;
339
+ /** Prose from a `@container`/`@supports`/`@media`/`@responsive` doc tag, when authored. */
340
+ description?: string;
341
+ }
342
+ /**
343
+ * What kind of CSS surface a record documents. `component` is a namespaced component class with
344
+ * `-modifier`s and parts; `utility` a single-purpose class family; `rule` bare-element/reset styling;
345
+ * `declaration` a custom-property / `@property` registration layer. The record-opening tag chooses it
346
+ * (`@component`/`@utility`/`@rule`/`@declaration`); `@name` is an alias for `component`.
347
+ */
348
+ type CssRecordKind = "component" | "utility" | "rule" | "declaration";
349
+ /**
350
+ * A release stage from a modifier (flag) tag — `@alpha`, `@beta`, `@experimental`, `@internal`, or
351
+ * `@public` — mirroring TSDoc's release-tag semantics.
352
+ */
353
+ type CssReleaseStage = "alpha" | "beta" | "experimental" | "internal" | "public";
354
+ /**
355
+ * A node in an authored structure tree (`@structure`), written as nested CSS: a compound selector for
356
+ * the element and its children (the rules nested inside it). Emitters render the tree and, via
357
+ * {@link toMermaid}, a diagram.
358
+ */
359
+ interface StructureNode {
360
+ /** The node's compound selector, e.g. `.tabs`, `.tab.-selected`, or `.list:has(.tab)`. */
361
+ selector: string;
362
+ /**
363
+ * How often the child may appear, from a trailing pseudo on the selector: `:optional`/`:opt` (0..1),
364
+ * `:many` (0..n), or `:one-or-more`/`:more` (1..n). Absent means the child is required (present when
365
+ * the component is used). A pseudo, not a `/* … *\/` comment, because `@structure` lives inside a doc
366
+ * comment where comments can't nest; an unknown pseudo is valid selector syntax and is stripped from
367
+ * the stored selector.
368
+ */
369
+ cardinality?: "optional" | "many" | "one-or-more";
370
+ /** Child nodes (rules nested one brace level deeper). */
371
+ children: StructureNode[];
372
+ }
373
+ /**
374
+ * A design token the component consumes via `var(--*)`. The set is derived from the CSS; an authored
375
+ * `@tokens` tag annotates one with prose (and may add a token not literally found via `var()`). Type and
376
+ * resolved value are not modeled here — an emitter resolves them via its own token source (e.g. a
377
+ * `resolveToken` hook).
378
+ */
379
+ interface CssTokenConsumed {
380
+ /** The custom-property name, e.g. `--color-primary`. */
381
+ name: string;
382
+ /** Prose from an `@tokens` doc tag, when authored. */
383
+ description?: string;
384
+ }
385
+ /** A related component cross-reference (`@related`). */
386
+ interface CssRelated {
387
+ /** The related record's name, e.g. `card`. */
388
+ name: string;
389
+ /** Prose from the `@related` tag, when authored. */
390
+ description?: string;
391
+ }
392
+ /** Where a record was authored, for source links. Positions are 1-based, matching PostCSS. */
393
+ interface CssSource {
394
+ /** The file the record was parsed from, when {@link ParseOptions.fileName} was supplied. */
395
+ file?: string;
396
+ /** The 1-based line of the record's opening doc comment. */
397
+ line?: number;
398
+ /** The 1-based column of the record's opening doc comment. */
399
+ column?: number;
400
+ }
401
+ /** One documented CSS record: its base class plus everything derived from the CSS + doc comments. */
402
+ interface CssDocEntry {
403
+ /** The record name from `@component`/`@utility`/`@rule`/`@declaration`/`@name`, e.g. `button`. */
404
+ name: string;
405
+ /** Which kind of CSS surface this documents (defaults to `component`). */
406
+ kind: CssRecordKind;
407
+ /** The base class selector, e.g. `.button` (inferred from the first bare-class rule). */
408
+ className: string;
409
+ /** One-line summary from `@summary`. */
410
+ summary?: string;
411
+ /** Extended prose from `@remarks`. */
412
+ remarks?: string;
413
+ /** Internal-only prose from `@privateRemarks` (emitters may choose to omit it from public output). */
414
+ privateRemarks?: string;
415
+ /** The release stage from a modifier flag tag (`@alpha`/`@beta`/`@experimental`/`@internal`/`@public`). */
416
+ releaseStage?: CssReleaseStage;
417
+ /** Version introduced, from `@since`. */
418
+ since?: string;
419
+ /** A documentation group/category, from `@group`/`@category`. */
420
+ group?: string;
421
+ /** Accessibility guidance, from `@a11y`/`@accessibility`. */
422
+ accessibility?: string;
423
+ /** AST-extracted modifiers, annotated with `@modifier` prose where authored. */
424
+ modifiers: CssModifier[];
425
+ /** AST-extracted sub-element parts (class-based), annotated with `@part` prose where authored. */
426
+ parts: CssPart[];
427
+ /** Shadow-DOM exposed parts (`::part(name)`), from `@csspart` or a `::part()` selector. */
428
+ shadowParts: CssPart[];
429
+ /** States the component reacts to, from `@cssstate`, `:state()`, pseudo-classes, or state classes. */
430
+ states: CssState[];
431
+ /** Named slots the component shell exposes, from `@slot`. */
432
+ slots: CssSlot[];
433
+ /**
434
+ * Design tokens this component consumes: every `--*` custom property referenced via `var(...)` inside
435
+ * its rules, each annotated with `@tokens` prose where authored (and including any `@tokens`-declared
436
+ * token not literally found via `var()`).
437
+ */
438
+ cssPropertiesConsumed: CssTokenConsumed[];
439
+ /** Custom properties this component declares (`@property`) or documents (`@cssproperty`). */
440
+ cssPropertiesDeclared: CssPropertyDeclared[];
441
+ /** CSS custom functions (`@function`) this component defines. */
442
+ functions: CssFunction[];
443
+ /** Animations (`@keyframes`) this component exposes. */
444
+ animations: CssAnimation[];
445
+ /** Cascade layers (`@layer`) this component participates in. */
446
+ layers: CssLayer[];
447
+ /** Conditional-support blocks (`@container`/`@supports`/`@media`) the rules sit under. */
448
+ conditions: CssCondition[];
449
+ /** `@example` blocks, verbatim. */
450
+ examples: string[];
451
+ /** The authored `@structure` element tree (top-level nodes), when present. */
452
+ structure?: StructureNode[];
453
+ /** An optional prose description leading the `@structure` body, when authored. */
454
+ structureDescription?: string;
455
+ /** `@demo <spec>` (e.g. `self:button`), when authored. */
456
+ demo?: string;
457
+ /** Component-level deprecation replacement text, when authored (the argument to a `@deprecated` tag). */
458
+ deprecated?: string;
459
+ /** `@see <ref>` cross-references. */
460
+ see: string[];
461
+ /** Usage prose from `@usage` — how to include the stylesheet / use the component. */
462
+ usage?: string;
463
+ /** Browser-support / feature-compatibility notes from `@compat`. */
464
+ compat: string[];
465
+ /** Related components from `@related`. */
466
+ related: CssRelated[];
467
+ /** Where the record was authored, when position info is available (for source links). */
468
+ source?: CssSource;
469
+ /**
470
+ * Content of registered custom (block) tags, keyed by tag name without its `@`. Populated only for
471
+ * tags added via configuration; unregistered unknown tags are ignored. Absent when none were found.
472
+ */
473
+ customBlocks?: Record<string, string[]>;
474
+ }
475
+ /** A PostCSS parse function — turns a source string into a Root. Inject one to read a non-CSS dialect. */
476
+ type CssParse = (css: string) => import("postcss").Root;
477
+ /** Options for {@link parseCssDocs}. */
478
+ interface ParseOptions {
479
+ /**
480
+ * How records are delimited. By default a new record begins at any doc comment (`/** … *\/`) that
481
+ * carries an `@component` or `@name` tag, which is the recommended, framework-agnostic convention.
482
+ * Supply a custom test to split on something else (e.g. a per-component header comment).
483
+ */
484
+ isRecordBoundary?: (commentText: string) => string | undefined;
485
+ /**
486
+ * The tag configuration (standard + custom tags, and which are supported). Defaults to a fresh
487
+ * {@link CssDocConfiguration} with every standard tag enabled — i.e. the full built-in vocabulary.
488
+ * Supply one (e.g. from `@cssdoc/config`) to register custom tags or disable standard ones.
489
+ */
490
+ configuration?: CssDocConfiguration;
491
+ /**
492
+ * The modifier convention — how modifier classes are spelled (BEM `.button--primary` by default;
493
+ * `rscss`, `bare`, or a custom `ModifierConvention` for SUIT/CUBE/etc.). Overrides the
494
+ * `configuration`'s convention when both are given.
495
+ */
496
+ modifierConvention?: ModifierConventionInput;
497
+ /**
498
+ * The PostCSS parser to read `css` with. Defaults to `postcss.parse` (plain CSS). Inject a dialect
499
+ * parser (e.g. `postcss-scss`/`postcss-less` via `@cssdoc/dialects`) to document `.scss`/`.less`.
500
+ */
501
+ parse?: CssParse;
502
+ /**
503
+ * The source file name to record on each entry's {@link CssSource}, enabling source links. The parser
504
+ * always records line/column; supply this to also record the file.
505
+ */
506
+ fileName?: string;
507
+ }
508
+ //#endregion
509
+ //#region src/configuration.d.ts
510
+ /**
511
+ * The syntactic kind of a tag, mirroring TSDoc's Block/Modifier/Inline split, plus cssdoc's own
512
+ * `record` kind for the tags that open a documentation record (`@component`, `@utility`, …).
513
+ */
514
+ type CssDocSyntaxKind = "record" | "block" | "modifier" | "inline";
515
+ /** Options for constructing a {@link CssDocTagDefinition}. */
516
+ interface CssDocTagDefinitionOptions {
517
+ /** The tag name, with or without a leading `@` (e.g. `@modifier` or `modifier`). */
518
+ tagName: string;
519
+ /** The tag's syntactic kind. */
520
+ syntaxKind: CssDocSyntaxKind;
521
+ /** Whether the tag may appear more than once in a comment (defaults to `false`). */
522
+ allowMultiple?: boolean;
523
+ /** For `record` tags, the {@link CssRecordKind} the tag selects. */
524
+ recordKind?: CssRecordKind;
525
+ /** The canonical tag (without `@`) this tag is an alias of, e.g. `@csspart` aliases `part`. */
526
+ aliasFor?: string;
527
+ }
528
+ /** One tag in the vocabulary: its name, kind, and how it may be used. */
529
+ declare class CssDocTagDefinition {
530
+ /** The normalized tag name, always with a leading `@` (e.g. `@modifier`). */
531
+ readonly tagName: string;
532
+ /** The tag name without its leading `@` (e.g. `modifier`). */
533
+ readonly tagNameWithoutAt: string;
534
+ readonly syntaxKind: CssDocSyntaxKind;
535
+ readonly allowMultiple: boolean;
536
+ readonly recordKind?: CssRecordKind;
537
+ /** The canonical tag name (without `@`) this aliases, if any; otherwise its own name. */
538
+ readonly aliasFor?: string;
539
+ constructor(options: CssDocTagDefinitionOptions);
540
+ /** The tag this definition resolves to when handled — its alias target, or itself. */
541
+ get canonicalName(): string;
542
+ }
543
+ /**
544
+ * A parse configuration: the set of tag definitions plus which are supported. Construct one to get the
545
+ * full standard vocabulary, then add custom tags or disable standard ones.
546
+ *
547
+ * @example
548
+ * ```ts
549
+ * import { CssDocConfiguration, CssDocTagDefinition, parseCssDocs } from "@cssdoc/core";
550
+ *
551
+ * const config = new CssDocConfiguration();
552
+ * config.addTagDefinition(new CssDocTagDefinition({ tagName: "@token", syntaxKind: "block" }), true);
553
+ * const model = parseCssDocs(css, { configuration: config });
554
+ * ```
555
+ */
556
+ declare class CssDocConfiguration {
557
+ private readonly _tagDefinitions;
558
+ private readonly _byName;
559
+ private readonly _supported;
560
+ private _modifierConvention;
561
+ constructor();
562
+ /** The resolved modifier convention this configuration parses with (defaults to BEM). */
563
+ get modifierConvention(): ModifierConvention;
564
+ /** Set the modifier convention from a preset name or a custom {@link ModifierConvention}. */
565
+ setModifierConvention(input: ModifierConventionInput): void;
566
+ /** Every registered tag definition, in registration order. */
567
+ get tagDefinitions(): readonly CssDocTagDefinition[];
568
+ /** Only the tag definitions that are currently supported. */
569
+ get supportedTagDefinitions(): readonly CssDocTagDefinition[];
570
+ /**
571
+ * Register a tag definition. Re-registering a tag name replaces the earlier definition.
572
+ *
573
+ * @param definition - The tag to add.
574
+ * @param supported - Whether it is supported (defaults to `true`).
575
+ */
576
+ addTagDefinition(definition: CssDocTagDefinition, supported?: boolean): void;
577
+ /** Register several tag definitions. */
578
+ addTagDefinitions(definitions: readonly CssDocTagDefinition[], supported?: boolean): void;
579
+ /** Look up a tag definition by name (with or without a leading `@`). */
580
+ tryGetTagDefinition(tagName: string): CssDocTagDefinition | undefined;
581
+ /** Whether a tag definition is supported. */
582
+ isTagSupported(definition: CssDocTagDefinition): boolean;
583
+ /** Enable or disable support for a tag. */
584
+ setSupportForTag(definition: CssDocTagDefinition, supported: boolean): void;
585
+ /** Enable or disable support for several tags. */
586
+ setSupportForTags(definitions: readonly CssDocTagDefinition[], supported: boolean): void;
587
+ /** Disable support for every standard tag (custom tags added later remain supported). */
588
+ setNoStandardTags(): void;
589
+ /** The names (without `@`) of every standard tag — the canonical vocabulary from `@cssdoc/spec`. */
590
+ static readonly standardTagNames: readonly string[];
591
+ /** A fresh set of the standard tag definitions (new instances on each call), built from the spec. */
592
+ static standardTags(): CssDocTagDefinition[];
593
+ }
594
+ //#endregion
595
+ //#region src/grammar.d.ts
596
+ /**
597
+ * The record-opening tags and the {@link CssRecordKind} each selects, as the default boundary map.
598
+ * A doc comment carrying one of these opens a new record; `@name` is an alias for `@component`. A
599
+ * {@link CssDocConfiguration} may add more record tags.
600
+ */
601
+ declare const RECORD_TAGS: Record<string, CssRecordKind>;
602
+ /** A custom property documented by a `@cssproperty` tag. */
603
+ interface DocCssProperty {
604
+ name: string;
605
+ syntax?: string;
606
+ defaultValue?: string;
607
+ description?: string;
608
+ }
609
+ /** The prose a `@modifier` tag contributes: a description and/or an inline deprecation replacement note. */
610
+ interface DocModifier {
611
+ description?: string;
612
+ /** Set when the modifier carries a bare `@deprecated` (no note and no canonical link). */
613
+ deprecatedFlag?: boolean;
614
+ /** Free-text replacement guidance from an inline `deprecated` tag on the modifier line. */
615
+ deprecated?: string;
616
+ /**
617
+ * The canonical modifier this one deprecates, from a `{@link -canonical}` in the deprecation note
618
+ * (e.g. `@deprecated {@link -color-danger}`). Stored without its leading dot, matching the AST-derived
619
+ * `deprecated.canonical`, so an authored alias and a generated one resolve to the same reference.
620
+ */
621
+ deprecatedCanonical?: string;
622
+ }
623
+ /** An authored conditional-support tag (`@container`/`@supports`/`@media`/`@responsive`). */
624
+ interface DocCondition {
625
+ type: "container" | "supports" | "media";
626
+ query: string;
627
+ description?: string;
628
+ }
629
+ /** The structured content extracted from one doc-comment block. */
630
+ interface ParsedDoc {
631
+ /** `@component`/`@utility`/`@rule`/`@declaration`/`@name` — the record name. Marks a record boundary. */
632
+ component?: string;
633
+ /** The record kind chosen by the opening tag (`component` unless `@utility`/`@rule`/`@declaration`). */
634
+ kind?: CssRecordKind;
635
+ /** `@class` — an explicit base class selector (otherwise inferred from the CSS). */
636
+ className?: string;
637
+ /** `@summary` — one-line intro. */
638
+ summary?: string;
639
+ /** `@remarks` — extended prose. */
640
+ remarks?: string;
641
+ /** `@privateRemarks` — internal-only prose. */
642
+ privateRemarks?: string;
643
+ /** `@since` — version introduced. */
644
+ since?: string;
645
+ /** `@group`/`@category` — a documentation group. */
646
+ group?: string;
647
+ /** `@a11y`/`@accessibility` — accessibility guidance. */
648
+ accessibility?: string;
649
+ /** The release stage from a modifier flag tag (`@alpha`/`@beta`/…). */
650
+ releaseStage?: CssReleaseStage;
651
+ /** `@modifier` prose, keyed by the modifier class without its dot (e.g. `-color-secondary`). */
652
+ modifiers: Map<string, DocModifier>;
653
+ /** `@part` descriptions, keyed by the class part name without its dot (e.g. `item`). */
654
+ parts: Map<string, string>;
655
+ /** `@tokens` descriptions, keyed by custom-property name (e.g. `--color-primary`). */
656
+ tokens: Map<string, string>;
657
+ /** `@csspart` descriptions (shadow-DOM `::part()`), keyed by the bare part name (e.g. `header`). */
658
+ cssParts: Map<string, string>;
659
+ /** `@cssproperty` declarations. */
660
+ cssProperties: DocCssProperty[];
661
+ /** `@cssstate` descriptions, keyed by state name. */
662
+ cssStates: Map<string, string>;
663
+ /** `@slot` descriptions, keyed by slot name (empty string for the default slot). */
664
+ slots: Map<string, string>;
665
+ /** `@function` descriptions, keyed by function name (e.g. `--negate`). */
666
+ functions: Map<string, string>;
667
+ /** `@keyframes`/`@animation` descriptions, keyed by animation name. */
668
+ animations: Map<string, string>;
669
+ /** `@layer` descriptions, keyed by layer name. */
670
+ layers: Map<string, string>;
671
+ /** `@container`/`@supports`/`@media`/`@responsive` authored conditions. */
672
+ conditions: DocCondition[];
673
+ /** `@example` blocks. */
674
+ examples: string[];
675
+ /** `@structure` — the nested-CSS body, parsed into a selector tree by {@link parseStructure}. */
676
+ structure?: StructureNode[];
677
+ /** An optional prose description leading the `@structure` body. */
678
+ structureDescription?: string;
679
+ /** The `<replacement>` argument from a `@deprecated` tag. */
680
+ deprecated?: string;
681
+ /** `@demo <spec>`. */
682
+ demo?: string;
683
+ /** `@see <ref>` entries. */
684
+ see: string[];
685
+ /** `@usage` prose — how to include the stylesheet / use the component. */
686
+ usage?: string;
687
+ /** `@compat` browser-support / feature-compatibility notes. */
688
+ compat: string[];
689
+ /** `@related` component cross-references. */
690
+ related: CssRelated[];
691
+ /** Content of registered custom (block) tags, keyed by tag name without its `@`. */
692
+ customBlocks: Map<string, string[]>;
693
+ }
694
+ /** Strip the comment framing (`/**`, `*\/`, and leading ` * `) from a raw block-comment body. */
695
+ declare function stripCommentFraming(raw: string): string;
696
+ /**
697
+ * Parse a doc-comment's INNER text (already stripped of `/* *\/` framing, or a raw block — both are
698
+ * handled) into a {@link ParsedDoc}. The `configuration` decides which tags are active and which custom
699
+ * tags to capture; unknown or unsupported tags are ignored, so the grammar degrades gracefully.
700
+ *
701
+ * @param raw - The comment text (with or without `/** … *\/` framing).
702
+ * @param configuration - The active tag configuration (defaults to the full standard vocabulary).
703
+ * @returns The structured tags.
704
+ */
705
+ declare function parseDocComment(raw: string, configuration?: CssDocConfiguration, parse?: CssParse): ParsedDoc;
706
+ /**
707
+ * Whether a comment's text opens a record — i.e. carries a record tag. Uses the `configuration`'s
708
+ * record tags when given, else the default {@link RECORD_TAGS}.
709
+ *
710
+ * @param commentText - The comment body.
711
+ * @param configuration - The active configuration (optional).
712
+ * @returns The record name, or `undefined`.
713
+ */
714
+ declare function recordNameOf(commentText: string, configuration?: CssDocConfiguration): string | undefined;
715
+ declare function parseStructure(raw: string, parse?: CssParse): StructureNode[];
716
+ //#endregion
717
+ //#region src/mermaid.d.ts
718
+ /**
719
+ * Convert a structure tree to a Mermaid `flowchart` definition. Each node gets a stable id (`n0`, `n1`,
720
+ * …) in depth-first order; edges connect a parent to each child.
721
+ *
722
+ * @param roots - Top-level {@link StructureNode}s (an authored `@structure`).
723
+ * @param options - `direction` sets the flowchart orientation (default `TD`, top-down).
724
+ * @returns Mermaid source, or an empty string when there are no nodes.
725
+ *
726
+ * @example
727
+ * ```ts
728
+ * toMermaid([{ selector: ".tabs", children: [{ selector: ".panel", children: [] }] }]);
729
+ * // flowchart TD
730
+ * // n0[".tabs"]
731
+ * // n1[".panel"]
732
+ * // n0 --> n1
733
+ * ```
734
+ */
735
+ declare function toMermaid(roots: StructureNode[], options?: {
736
+ direction?: "TD" | "LR";
737
+ }): string;
738
+ //#endregion
739
+ //#region src/lite.d.ts
740
+ /**
741
+ * Serialize a documentation model to pretty JSON (the raw, emitter-agnostic artifact — like TypeDoc's
742
+ * `--json`).
743
+ *
744
+ * @param model - The entries from `parseCssDocs`.
745
+ * @returns A JSON string.
746
+ */
747
+ declare function toJson(model: CssDocEntry[]): string;
748
+ //#endregion
749
+ export { CssState as A, ModifierMatcher as B, CssPart as C, CssReleaseStage as D, CssRelated as E, DEFAULT_STATE_PSEUDO_CLASSES as F, MODIFIER_PRESETS as I, ModifierConvention as L, ParseOptions as M, StructureNode as N, CssSlot as O, DEFAULT_MODIFIER_CONVENTION as P, ModifierConventionInput as R, CssParse as S, CssRecordKind as T, resolveModifierConvention as V, CssCondition as _, DocModifier as a, CssLayer as b, parseDocComment as c, stripCommentFraming as d, CssDocConfiguration as f, CssAnimation as g, CssDocTagDefinitionOptions as h, DocCssProperty as i, CssTokenConsumed as j, CssSource as k, parseStructure as l, CssDocTagDefinition as m, toMermaid as n, ParsedDoc as o, CssDocSyntaxKind as p, DocCondition as r, RECORD_TAGS as s, toJson as t, recordNameOf as u, CssDocEntry as v, CssPropertyDeclared as w, CssModifier as x, CssFunction as y, ModifierHit as z };