@cssdoc/core 0.4.2 → 0.5.1

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 CHANGED
@@ -1,564 +1,5 @@
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
196
- //#region src/configuration.d.ts
197
- /**
198
- * The syntactic kind of a tag, mirroring TSDoc's Block/Modifier/Inline split, plus cssdoc's own
199
- * `record` kind for the tags that open a documentation record (`@component`, `@utility`, …).
200
- */
201
- type CssDocSyntaxKind = "record" | "block" | "modifier" | "inline";
202
- /** Options for constructing a {@link CssDocTagDefinition}. */
203
- interface CssDocTagDefinitionOptions {
204
- /** The tag name, with or without a leading `@` (e.g. `@modifier` or `modifier`). */
205
- tagName: string;
206
- /** The tag's syntactic kind. */
207
- syntaxKind: CssDocSyntaxKind;
208
- /** Whether the tag may appear more than once in a comment (defaults to `false`). */
209
- allowMultiple?: boolean;
210
- /** For `record` tags, the {@link CssRecordKind} the tag selects. */
211
- recordKind?: CssRecordKind;
212
- /** The canonical tag (without `@`) this tag is an alias of, e.g. `@csspart` aliases `part`. */
213
- aliasFor?: string;
214
- }
215
- /** One tag in the vocabulary: its name, kind, and how it may be used. */
216
- declare class CssDocTagDefinition {
217
- /** The normalized tag name, always with a leading `@` (e.g. `@modifier`). */
218
- readonly tagName: string;
219
- /** The tag name without its leading `@` (e.g. `modifier`). */
220
- readonly tagNameWithoutAt: string;
221
- readonly syntaxKind: CssDocSyntaxKind;
222
- readonly allowMultiple: boolean;
223
- readonly recordKind?: CssRecordKind;
224
- /** The canonical tag name (without `@`) this aliases, if any; otherwise its own name. */
225
- readonly aliasFor?: string;
226
- constructor(options: CssDocTagDefinitionOptions);
227
- /** The tag this definition resolves to when handled — its alias target, or itself. */
228
- get canonicalName(): string;
229
- }
230
- /**
231
- * A parse configuration: the set of tag definitions plus which are supported. Construct one to get the
232
- * full standard vocabulary, then add custom tags or disable standard ones.
233
- *
234
- * @example
235
- * ```ts
236
- * import { CssDocConfiguration, CssDocTagDefinition, parseCssDocs } from "@cssdoc/core";
237
- *
238
- * const config = new CssDocConfiguration();
239
- * config.addTagDefinition(new CssDocTagDefinition({ tagName: "@token", syntaxKind: "block" }), true);
240
- * const model = parseCssDocs(css, { configuration: config });
241
- * ```
242
- */
243
- declare class CssDocConfiguration {
244
- private readonly _tagDefinitions;
245
- private readonly _byName;
246
- private readonly _supported;
247
- private _modifierConvention;
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;
253
- /** Every registered tag definition, in registration order. */
254
- get tagDefinitions(): readonly CssDocTagDefinition[];
255
- /** Only the tag definitions that are currently supported. */
256
- get supportedTagDefinitions(): readonly CssDocTagDefinition[];
257
- /**
258
- * Register a tag definition. Re-registering a tag name replaces the earlier definition.
259
- *
260
- * @param definition - The tag to add.
261
- * @param supported - Whether it is supported (defaults to `true`).
262
- */
263
- addTagDefinition(definition: CssDocTagDefinition, supported?: boolean): void;
264
- /** Register several tag definitions. */
265
- addTagDefinitions(definitions: readonly CssDocTagDefinition[], supported?: boolean): void;
266
- /** Look up a tag definition by name (with or without a leading `@`). */
267
- tryGetTagDefinition(tagName: string): CssDocTagDefinition | undefined;
268
- /** Whether a tag definition is supported. */
269
- isTagSupported(definition: CssDocTagDefinition): boolean;
270
- /** Enable or disable support for a tag. */
271
- setSupportForTag(definition: CssDocTagDefinition, supported: boolean): void;
272
- /** Enable or disable support for several tags. */
273
- setSupportForTags(definitions: readonly CssDocTagDefinition[], supported: boolean): void;
274
- /** Disable support for every standard tag (custom tags added later remain supported). */
275
- setNoStandardTags(): void;
276
- /** The names (without `@`) of every standard tag — the canonical vocabulary from `@cssdoc/spec`. */
277
- static readonly standardTagNames: readonly string[];
278
- /** A fresh set of the standard tag definitions (new instances on each call), built from the spec. */
279
- static standardTags(): CssDocTagDefinition[];
280
- }
281
- //#endregion
282
- //#region src/model.d.ts
283
- /**
284
- * The serializable CSS-documentation model — the output-agnostic IR produced by {@link parseCssDocs}.
285
- * Emitters (markdown, JSON, …) consume this; it carries no assumptions about any particular project,
286
- * class prefix, or output format.
287
- *
288
- * The model documents the modern CSSOM surface a stylesheet exposes: modifiers and parts, registered
289
- * custom properties (`@property`), custom functions (`@function`), animations (`@keyframes`), cascade
290
- * layers (`@layer`), conditional-support blocks (`@container`/`@supports`/`@media`), states, and slots.
291
- * Facts that can be derived from the CSS AST are derived (so they can't drift); doc-comment tags supply
292
- * the prose.
293
- *
294
- * @module
295
- */
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
- */
300
- interface CssModifier {
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
- */
306
- name: string;
307
- /** The property segment — a grouping key derived from the modifier (e.g. `color`, `variant`, `primary`). */
308
- prop: string;
309
- /** The value segment, e.g. `secondary` or `ghost`; absent for boolean/flag modifiers. */
310
- value?: string;
311
- /** Prose from a `@modifier` doc tag, when authored. */
312
- description?: string;
313
- /**
314
- * Set when the modifier is deprecated. `canonical` (from an AST alias marker) is the modifier class
315
- * to use instead; `note` (from an authored inline deprecation tag on the `@modifier` line) is
316
- * free-text replacement guidance for cases where the replacement isn't itself a modifier.
317
- */
318
- deprecated?: {
319
- canonical?: string;
320
- note?: string;
321
- };
322
- }
323
- /** A sub-element ("part") of a component — a scoped child class like `.item` or `.tip`. */
324
- interface CssPart {
325
- /** The part class without the leading dot, e.g. `item`. */
326
- name: string;
327
- /** Prose from a `@part` doc tag, when authored. */
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[];
331
- }
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`). */
339
- interface CssState {
340
- /** The state name without its punctuation, e.g. `open`, `selected`, or `disabled`. */
341
- name: string;
342
- /** How the state is expressed in CSS. */
343
- kind: CssStateKind;
344
- /** Prose from a `@cssstate` doc tag, when authored. */
345
- description?: string;
346
- }
347
- /** A named slot a component shell exposes (`@slot`, Custom Elements Manifest). */
348
- interface CssSlot {
349
- /** The slot name (empty string for the default slot). */
350
- name: string;
351
- /** Prose from a `@slot` doc tag, when authored. */
352
- description?: string;
353
- }
354
- /** A custom property the component declares (`@property`) or documents (`@cssproperty`). */
355
- interface CssPropertyDeclared {
356
- /** The custom-property name, e.g. `--value`. */
357
- name: string;
358
- /** The `@property` `syntax` descriptor, e.g. `<number>`, when known. */
359
- syntax?: string;
360
- /** The `@property` `inherits` flag, when declared. */
361
- inherits?: boolean;
362
- /** The default value (`@property` `initial-value`, or an authored `@defaultValue`), when known. */
363
- defaultValue?: string;
364
- /** Prose from a `@cssproperty` doc tag, when authored. */
365
- description?: string;
366
- }
367
- /** A CSS custom function (`@function --name`) the stylesheet defines. */
368
- interface CssFunction {
369
- /** The function name, e.g. `--negate`. */
370
- name: string;
371
- /** The declared parameters, e.g. `["--value"]`, when derivable from the `@function` at-rule. */
372
- parameters: string[];
373
- /** The `result` descriptor/type, when declared. */
374
- result?: string;
375
- /** Prose from a `@function` doc tag, when authored. */
376
- description?: string;
377
- }
378
- /** An animation the component exposes (`@keyframes` at-rule / `@animation` doc tag). */
379
- interface CssAnimation {
380
- /** The animation (keyframes) name. */
381
- name: string;
382
- /** Prose from an `@animation`/`@keyframes` doc tag, when authored. */
383
- description?: string;
384
- }
385
- /** A cascade layer the stylesheet participates in (`@layer`). */
386
- interface CssLayer {
387
- /** The layer name, possibly dotted (e.g. `theme.dark`). */
388
- name: string;
389
- /** Prose from a `@layer` doc tag, when authored. */
390
- description?: string;
391
- }
392
- /** A conditional-support block the component's rules sit under. */
393
- interface CssCondition {
394
- /** Which at-rule expressed the condition. */
395
- type: "container" | "supports" | "media";
396
- /** The condition text, e.g. `(min-width: 40rem)` or `(display: grid)`. */
397
- query: string;
398
- /** A container name, for `@container` blocks that target a named container. */
399
- containerName?: string;
400
- /** Prose from a `@container`/`@supports`/`@media`/`@responsive` doc tag, when authored. */
401
- description?: string;
402
- }
403
- /**
404
- * What kind of CSS surface a record documents. `component` is a namespaced component class with
405
- * `-modifier`s and parts; `utility` a single-purpose class family; `rule` bare-element/reset styling;
406
- * `declaration` a custom-property / `@property` registration layer. The record-opening tag chooses it
407
- * (`@component`/`@utility`/`@rule`/`@declaration`); `@name` is an alias for `component`.
408
- */
409
- type CssRecordKind = "component" | "utility" | "rule" | "declaration";
410
- /**
411
- * A release stage from a modifier (flag) tag — `@alpha`, `@beta`, `@experimental`, `@internal`, or
412
- * `@public` — mirroring TSDoc's release-tag semantics.
413
- */
414
- type CssReleaseStage = "alpha" | "beta" | "experimental" | "internal" | "public";
415
- /**
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.
419
- */
420
- interface StructureNode {
421
- /** The node's compound selector, e.g. `.tabs`, `.tab.-selected`, or `.list:has(.tab)`. */
422
- selector: string;
423
- /** Child nodes (rules nested one brace level deeper). */
424
- children: StructureNode[];
425
- }
426
- /**
427
- * A design token the component consumes via `var(--*)`. The set is derived from the CSS; an authored
428
- * `@tokens` tag annotates one with prose (and may add a token not literally found via `var()`). Type and
429
- * resolved value are not modeled here — an emitter resolves them via its own token source (e.g. a
430
- * `resolveToken` hook).
431
- */
432
- interface CssTokenConsumed {
433
- /** The custom-property name, e.g. `--color-primary`. */
434
- name: string;
435
- /** Prose from an `@tokens` doc tag, when authored. */
436
- description?: string;
437
- }
438
- /** A related component cross-reference (`@related`). */
439
- interface CssRelated {
440
- /** The related record's name, e.g. `card`. */
441
- name: string;
442
- /** Prose from the `@related` tag, when authored. */
443
- description?: string;
444
- }
445
- /** Where a record was authored, for source links. Positions are 1-based, matching PostCSS. */
446
- interface CssSource {
447
- /** The file the record was parsed from, when {@link ParseOptions.fileName} was supplied. */
448
- file?: string;
449
- /** The 1-based line of the record's opening doc comment. */
450
- line?: number;
451
- /** The 1-based column of the record's opening doc comment. */
452
- column?: number;
453
- }
454
- /** One documented CSS record: its base class plus everything derived from the CSS + doc comments. */
455
- interface CssDocEntry {
456
- /** The record name from `@component`/`@utility`/`@rule`/`@declaration`/`@name`, e.g. `button`. */
457
- name: string;
458
- /** Which kind of CSS surface this documents (defaults to `component`). */
459
- kind: CssRecordKind;
460
- /** The base class selector, e.g. `.button` (inferred from the first bare-class rule). */
461
- className: string;
462
- /** One-line summary from `@summary`. */
463
- summary?: string;
464
- /** Extended prose from `@remarks`. */
465
- remarks?: string;
466
- /** Internal-only prose from `@privateRemarks` (emitters may choose to omit it from public output). */
467
- privateRemarks?: string;
468
- /** The release stage from a modifier flag tag (`@alpha`/`@beta`/`@experimental`/`@internal`/`@public`). */
469
- releaseStage?: CssReleaseStage;
470
- /** Version introduced, from `@since`. */
471
- since?: string;
472
- /** A documentation group/category, from `@group`/`@category`. */
473
- group?: string;
474
- /** Accessibility guidance, from `@a11y`/`@accessibility`. */
475
- accessibility?: string;
476
- /** AST-extracted modifiers, annotated with `@modifier` prose where authored. */
477
- modifiers: CssModifier[];
478
- /** AST-extracted sub-element parts (class-based), annotated with `@part` prose where authored. */
479
- parts: CssPart[];
480
- /** Shadow-DOM exposed parts (`::part(name)`), from `@csspart` or a `::part()` selector. */
481
- shadowParts: CssPart[];
482
- /** States the component reacts to, from `@cssstate`, `:state()`, pseudo-classes, or state classes. */
483
- states: CssState[];
484
- /** Named slots the component shell exposes, from `@slot`. */
485
- slots: CssSlot[];
486
- /**
487
- * Design tokens this component consumes: every `--*` custom property referenced via `var(...)` inside
488
- * its rules, each annotated with `@tokens` prose where authored (and including any `@tokens`-declared
489
- * token not literally found via `var()`).
490
- */
491
- cssPropertiesConsumed: CssTokenConsumed[];
492
- /** Custom properties this component declares (`@property`) or documents (`@cssproperty`). */
493
- cssPropertiesDeclared: CssPropertyDeclared[];
494
- /** CSS custom functions (`@function`) this component defines. */
495
- functions: CssFunction[];
496
- /** Animations (`@keyframes`) this component exposes. */
497
- animations: CssAnimation[];
498
- /** Cascade layers (`@layer`) this component participates in. */
499
- layers: CssLayer[];
500
- /** Conditional-support blocks (`@container`/`@supports`/`@media`) the rules sit under. */
501
- conditions: CssCondition[];
502
- /** `@example` blocks, verbatim. */
503
- examples: string[];
504
- /** The authored `@structure` element tree (top-level nodes), when present. */
505
- structure?: StructureNode[];
506
- /** An optional prose description leading the `@structure` body, when authored. */
507
- structureDescription?: string;
508
- /** `@demo <spec>` (e.g. `self:button`), when authored. */
509
- demo?: string;
510
- /** Component-level deprecation replacement text, when authored (the argument to a `@deprecated` tag). */
511
- deprecated?: string;
512
- /** `@see <ref>` cross-references. */
513
- see: string[];
514
- /** Usage prose from `@usage` — how to include the stylesheet / use the component. */
515
- usage?: string;
516
- /** Browser-support / feature-compatibility notes from `@compat`. */
517
- compat: string[];
518
- /** Related components from `@related`. */
519
- related: CssRelated[];
520
- /** Where the record was authored, when position info is available (for source links). */
521
- source?: CssSource;
522
- /**
523
- * Content of registered custom (block) tags, keyed by tag name without its `@`. Populated only for
524
- * tags added via configuration; unregistered unknown tags are ignored. Absent when none were found.
525
- */
526
- customBlocks?: Record<string, string[]>;
527
- }
528
- /** A PostCSS parse function — turns a source string into a Root. Inject one to read a non-CSS dialect. */
529
- type CssParse = (css: string) => import("postcss").Root;
530
- /** Options for {@link parseCssDocs}. */
531
- interface ParseOptions {
532
- /**
533
- * How records are delimited. By default a new record begins at any doc comment (`/** … *\/`) that
534
- * carries an `@component` or `@name` tag, which is the recommended, framework-agnostic convention.
535
- * Supply a custom test to split on something else (e.g. a per-component header comment).
536
- */
537
- isRecordBoundary?: (commentText: string) => string | undefined;
538
- /**
539
- * The tag configuration (standard + custom tags, and which are supported). Defaults to a fresh
540
- * {@link CssDocConfiguration} with every standard tag enabled — i.e. the full built-in vocabulary.
541
- * Supply one (e.g. from `@cssdoc/config`) to register custom tags or disable standard ones.
542
- */
543
- configuration?: CssDocConfiguration;
544
- /**
545
- * The modifier convention — how modifier classes are spelled (BEM `.button--primary` by default;
546
- * `rscss`, `bare`, or a custom `ModifierConvention` for SUIT/CUBE/etc.). Overrides the
547
- * `configuration`'s convention when both are given.
548
- */
549
- modifierConvention?: ModifierConventionInput;
550
- /**
551
- * The PostCSS parser to read `css` with. Defaults to `postcss.parse` (plain CSS). Inject a dialect
552
- * parser (e.g. `postcss-scss`/`postcss-less` via `@cssdoc/dialects`) to document `.scss`/`.less`.
553
- */
554
- parse?: CssParse;
555
- /**
556
- * The source file name to record on each entry's {@link CssSource}, enabling source links. The parser
557
- * always records line/column; supply this to also record the file.
558
- */
559
- fileName?: string;
560
- }
561
- //#endregion
1
+ import { A as CssState, B as ModifierMatcher, C as CssPart, D as CssReleaseStage, E as CssRelated, F as DEFAULT_STATE_PSEUDO_CLASSES, I as MODIFIER_PRESETS, L as ModifierConvention, M as ParseOptions, N as StructureNode, O as CssSlot, P as DEFAULT_MODIFIER_CONVENTION, R as ModifierConventionInput, S as CssParse, T as CssRecordKind, V as resolveModifierConvention, _ as CssCondition, a as DocModifier, b as CssLayer, c as parseDocComment, d as stripCommentFraming, f as CssDocConfiguration, g as CssAnimation, h as CssDocTagDefinitionOptions, i as DocCssProperty, j as CssTokenConsumed, k as CssSource, l as parseStructure, m as CssDocTagDefinition, n as toMermaid, o as ParsedDoc, p as CssDocSyntaxKind, r as DocCondition, s as RECORD_TAGS, t as toJson, u as recordNameOf, v as CssDocEntry, w as CssPropertyDeclared, x as CssModifier, y as CssFunction, z as ModifierHit } from "./lite-DtKEwRkS.mjs";
2
+
562
3
  //#region src/parse.d.ts
563
4
  /**
564
5
  * Parse a CSS string into a documentation model. Records are delimited by `/**` doc comments carrying a
@@ -579,173 +20,4 @@ interface ParseOptions {
579
20
  */
580
21
  declare function parseCssDocs(css: string, options?: ParseOptions): CssDocEntry[];
581
22
  //#endregion
582
- //#region src/grammar.d.ts
583
- /**
584
- * The record-opening tags and the {@link CssRecordKind} each selects, as the default boundary map.
585
- * A doc comment carrying one of these opens a new record; `@name` is an alias for `@component`. A
586
- * {@link CssDocConfiguration} may add more record tags.
587
- */
588
- declare const RECORD_TAGS: Record<string, CssRecordKind>;
589
- /** A custom property documented by a `@cssproperty` tag. */
590
- interface DocCssProperty {
591
- name: string;
592
- syntax?: string;
593
- defaultValue?: string;
594
- description?: string;
595
- }
596
- /** The prose a `@modifier` tag contributes: a description and/or an inline deprecation replacement note. */
597
- interface DocModifier {
598
- description?: string;
599
- /** Set when the modifier carries a bare `@deprecated` (no note and no canonical link). */
600
- deprecatedFlag?: boolean;
601
- /** Free-text replacement guidance from an inline `deprecated` tag on the modifier line. */
602
- deprecated?: string;
603
- /**
604
- * The canonical modifier this one deprecates, from a `{@link -canonical}` in the deprecation note
605
- * (e.g. `@deprecated {@link -color-danger}`). Stored without its leading dot, matching the AST-derived
606
- * `deprecated.canonical`, so an authored alias and a generated one resolve to the same reference.
607
- */
608
- deprecatedCanonical?: string;
609
- }
610
- /** An authored conditional-support tag (`@container`/`@supports`/`@media`/`@responsive`). */
611
- interface DocCondition {
612
- type: "container" | "supports" | "media";
613
- query: string;
614
- description?: string;
615
- }
616
- /** The structured content extracted from one doc-comment block. */
617
- interface ParsedDoc {
618
- /** `@component`/`@utility`/`@rule`/`@declaration`/`@name` — the record name. Marks a record boundary. */
619
- component?: string;
620
- /** The record kind chosen by the opening tag (`component` unless `@utility`/`@rule`/`@declaration`). */
621
- kind?: CssRecordKind;
622
- /** `@class` — an explicit base class selector (otherwise inferred from the CSS). */
623
- className?: string;
624
- /** `@summary` — one-line intro. */
625
- summary?: string;
626
- /** `@remarks` — extended prose. */
627
- remarks?: string;
628
- /** `@privateRemarks` — internal-only prose. */
629
- privateRemarks?: string;
630
- /** `@since` — version introduced. */
631
- since?: string;
632
- /** `@group`/`@category` — a documentation group. */
633
- group?: string;
634
- /** `@a11y`/`@accessibility` — accessibility guidance. */
635
- accessibility?: string;
636
- /** The release stage from a modifier flag tag (`@alpha`/`@beta`/…). */
637
- releaseStage?: CssReleaseStage;
638
- /** `@modifier` prose, keyed by the modifier class without its dot (e.g. `-color-secondary`). */
639
- modifiers: Map<string, DocModifier>;
640
- /** `@part` descriptions, keyed by the class part name without its dot (e.g. `item`). */
641
- parts: Map<string, string>;
642
- /** `@tokens` descriptions, keyed by custom-property name (e.g. `--color-primary`). */
643
- tokens: Map<string, string>;
644
- /** `@csspart` descriptions (shadow-DOM `::part()`), keyed by the bare part name (e.g. `header`). */
645
- cssParts: Map<string, string>;
646
- /** `@cssproperty` declarations. */
647
- cssProperties: DocCssProperty[];
648
- /** `@cssstate` descriptions, keyed by state name. */
649
- cssStates: Map<string, string>;
650
- /** `@slot` descriptions, keyed by slot name (empty string for the default slot). */
651
- slots: Map<string, string>;
652
- /** `@function` descriptions, keyed by function name (e.g. `--negate`). */
653
- functions: Map<string, string>;
654
- /** `@keyframes`/`@animation` descriptions, keyed by animation name. */
655
- animations: Map<string, string>;
656
- /** `@layer` descriptions, keyed by layer name. */
657
- layers: Map<string, string>;
658
- /** `@container`/`@supports`/`@media`/`@responsive` authored conditions. */
659
- conditions: DocCondition[];
660
- /** `@example` blocks. */
661
- examples: string[];
662
- /** `@structure` — the nested-CSS body, parsed into a selector tree by {@link parseStructure}. */
663
- structure?: StructureNode[];
664
- /** An optional prose description leading the `@structure` body. */
665
- structureDescription?: string;
666
- /** The `<replacement>` argument from a `@deprecated` tag. */
667
- deprecated?: string;
668
- /** `@demo <spec>`. */
669
- demo?: string;
670
- /** `@see <ref>` entries. */
671
- see: string[];
672
- /** `@usage` prose — how to include the stylesheet / use the component. */
673
- usage?: string;
674
- /** `@compat` browser-support / feature-compatibility notes. */
675
- compat: string[];
676
- /** `@related` component cross-references. */
677
- related: CssRelated[];
678
- /** Content of registered custom (block) tags, keyed by tag name without its `@`. */
679
- customBlocks: Map<string, string[]>;
680
- }
681
- /** Strip the comment framing (`/**`, `*\/`, and leading ` * `) from a raw block-comment body. */
682
- declare function stripCommentFraming(raw: string): string;
683
- /**
684
- * Parse a doc-comment's INNER text (already stripped of `/* *\/` framing, or a raw block — both are
685
- * handled) into a {@link ParsedDoc}. The `configuration` decides which tags are active and which custom
686
- * tags to capture; unknown or unsupported tags are ignored, so the grammar degrades gracefully.
687
- *
688
- * @param raw - The comment text (with or without `/** … *\/` framing).
689
- * @param configuration - The active tag configuration (defaults to the full standard vocabulary).
690
- * @returns The structured tags.
691
- */
692
- declare function parseDocComment(raw: string, configuration?: CssDocConfiguration): ParsedDoc;
693
- /**
694
- * Whether a comment's text opens a record — i.e. carries a record tag. Uses the `configuration`'s
695
- * record tags when given, else the default {@link RECORD_TAGS}.
696
- *
697
- * @param commentText - The comment body.
698
- * @param configuration - The active configuration (optional).
699
- * @returns The record name, or `undefined`.
700
- */
701
- declare function recordNameOf(commentText: string, configuration?: CssDocConfiguration): string | undefined;
702
- /**
703
- * Parse a `@structure` body — nested CSS (brace-delimited rules) — into a {@link StructureNode} tree.
704
- * Each rule's selector becomes a node; nested rules become its children. Because a node is a real
705
- * compound selector, `:has()` (contains), `:is()` / selector-lists (one-of), and `:not()` (not) express
706
- * relationships natively. Leaf nodes are written as empty rules (`.tab {}`). A malformed body parses to
707
- * an empty tree rather than throwing.
708
- *
709
- * @example
710
- * ```
711
- * .tabs {
712
- * .list { .tab {} }
713
- * .panel {}
714
- * }
715
- * ```
716
- */
717
- declare function parseStructure(raw: string): StructureNode[];
718
- //#endregion
719
- //#region src/mermaid.d.ts
720
- /**
721
- * Convert a structure tree to a Mermaid `flowchart` definition. Each node gets a stable id (`n0`, `n1`,
722
- * …) in depth-first order; edges connect a parent to each child.
723
- *
724
- * @param roots - Top-level {@link StructureNode}s (an authored `@structure`).
725
- * @param options - `direction` sets the flowchart orientation (default `TD`, top-down).
726
- * @returns Mermaid source, or an empty string when there are no nodes.
727
- *
728
- * @example
729
- * ```ts
730
- * toMermaid([{ selector: ".tabs", children: [{ selector: ".panel", children: [] }] }]);
731
- * // flowchart TD
732
- * // n0[".tabs"]
733
- * // n1[".panel"]
734
- * // n0 --> n1
735
- * ```
736
- */
737
- declare function toMermaid(roots: StructureNode[], options?: {
738
- direction?: "TD" | "LR";
739
- }): string;
740
- //#endregion
741
- //#region src/index.d.ts
742
- /**
743
- * Serialize a documentation model to pretty JSON (the raw, emitter-agnostic artifact — like TypeDoc's
744
- * `--json`).
745
- *
746
- * @param model - The entries from {@link parseCssDocs}.
747
- * @returns A JSON string.
748
- */
749
- declare function toJson(model: CssDocEntry[]): string;
750
- //#endregion
751
23
  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 CssRelated, type CssReleaseStage, type CssSlot, type CssSource, type CssState, type CssTokenConsumed, 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 };