@cssdoc/core 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cssdoc/core",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "A generic CSS documentation extractor: parse doc-comments + the CSS AST into a serializable model (TSDoc, for CSS).",
5
5
  "keywords": [
6
6
  "css",
@@ -19,8 +19,7 @@
19
19
  "directory": "packages/core"
20
20
  },
21
21
  "files": [
22
- "dist",
23
- "grammar"
22
+ "dist"
24
23
  ],
25
24
  "type": "module",
26
25
  "exports": {
@@ -31,12 +30,12 @@
31
30
  "access": "public"
32
31
  },
33
32
  "dependencies": {
34
- "postcss": "^8.5.16"
33
+ "postcss": "^8.5.16",
34
+ "@cssdoc/spec": "0.3.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^24.13.3",
38
38
  "@vitest/coverage-v8": "4.1.9",
39
- "grammarkdown": "^3.3.2",
40
39
  "publint": "^0.3.21",
41
40
  "typescript": "^6.0.3",
42
41
  "vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
@@ -1,406 +0,0 @@
1
- // CssDoc — the doc-comment grammar for @cssdoc/core.
2
- //
3
- // A formal, RFC-style specification of the tag vocabulary parsed out of `/** … */` block comments,
4
- // modeled on TSDoc's DeclarationReference.grammarkdown. It is organized as a lexical grammar
5
- // (characters, comment framing, tokens, names) building toward a syntactic grammar (the doc comment,
6
- // its block tags, and the CssReference used inside inline `{@link}` / `{@inheritDoc}` tags).
7
- //
8
- // The grammar is the source of truth for the shape of a doc comment; the runtime parser in
9
- // grammar.ts is hand-written to conform to these productions. It is deliberately expansive — modeled
10
- // on TSDoc's full Block / Modifier / Inline taxonomy plus cssdoc's own Record kind — and documents the
11
- // modern CSSOM surface (registered properties, custom functions, keyframes, cascade layers, container
12
- // / supports / media conditions, states, parts, slots). Where a feature is a real CSS at-rule, core
13
- // derives the facts from the CSS AST; the tags below supply the authored prose.
14
- //
15
- // Notation: `::` marks a lexical production, `:` a syntactic one. Terminals are in backticks; `> …`
16
- // lines are prose (used for character classes and layout-sensitive constructs that sit outside
17
- // context-free notation).
18
-
19
- // ============================================================================================
20
- // Lexical Grammar
21
- // ============================================================================================
22
-
23
- SourceCharacter ::
24
- > any Unicode code point
25
-
26
- WhiteSpace ::
27
- > a space or a horizontal tab
28
-
29
- LineTerminator ::
30
- > a line feed or a carriage return
31
-
32
- // --- Comment framing ---------------------------------------------------------------------------
33
- // PostCSS hands the parser the comment's inner text; the framing is stripped either way.
34
-
35
- CommentOpen ::
36
- `/**`
37
-
38
- CommentClose ::
39
- `*/`
40
-
41
- LinePrefix ::
42
- WhiteSpace? `*` WhiteSpace?
43
-
44
- // --- Tokens ------------------------------------------------------------------------------------
45
-
46
- BlockSigil ::
47
- `@`
48
-
49
- InlineOpen ::
50
- `{@`
51
-
52
- InlineClose ::
53
- `}`
54
-
55
- // The head/description separator on a tag line: an em dash or a hyphen, surrounded by whitespace.
56
- Separator :: one of
57
- `—` `-`
58
-
59
- Digit :: one of
60
- `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
61
-
62
- Letter ::
63
- > an ASCII letter
64
-
65
- // --- Names -------------------------------------------------------------------------------------
66
-
67
- IdentifierStart ::
68
- Letter
69
- `_`
70
-
71
- IdentifierPart ::
72
- IdentifierStart
73
- Digit
74
- `-`
75
-
76
- Identifier ::
77
- IdentifierStart
78
- Identifier IdentifierPart
79
-
80
- // A record name, e.g. `button` or `progress-circle`.
81
- RecordName ::
82
- Identifier
83
-
84
- // How a modifier is spelled is configurable (see the `ModifierConvention` in `@cssdoc/core`); the
85
- // DEFAULT is BEM — the modifier is conjoined onto the base class with `--`, e.g. `.button--primary`.
86
- // Other conventions:
87
- // rscss — `.button.-color-secondary` (a chained `-`-prefixed class, split into Prop/Value)
88
- // bare / OOCSS — `.button.primary` (any class chained to the base)
89
- // CUBE — `.card[data-variant="ghost"]` (a data-attribute exception on the base)
90
- // The default (BEM) form:
91
- ModifierName ::
92
- Identifier `--` Identifier
93
-
94
- // The rscss form: a `-<prop>` boolean modifier, or a `-<prop>-<value>` modifier. `Prop` is the segment
95
- // up to the first interior hyphen; `Value` is the remainder (which may itself contain hyphens).
96
- RscssModifierName ::
97
- `-` Prop
98
- `-` Prop `-` Value
99
-
100
- // The CUBE form: an attribute-selector exception on the base, e.g. `[data-variant="ghost"]`. The
101
- // value is a quoted string; shown here as an identifier for brevity.
102
- AttributeModifier ::
103
- `[` Identifier `]`
104
- `[` Identifier `=` Identifier `]`
105
-
106
- Prop ::
107
- > an identifier segment of letters and digits, containing no hyphen
108
-
109
- Value ::
110
- Identifier
111
-
112
- // A `.`-prefixed sub-element class, e.g. `.item`.
113
- PartName ::
114
- `.` Identifier
115
-
116
- // A base-class selector, e.g. `.button`.
117
- ClassSelector ::
118
- `.` Identifier
119
-
120
- // A `--`-prefixed custom property (`@property`) or custom function (`@function`) name.
121
- CustomPropertyName ::
122
- `--` Identifier
123
-
124
- // The `<…>` CSS syntax descriptor on a `@cssproperty`/`@property` line, e.g. `<number>`.
125
- SyntaxDescriptor ::
126
- `<` SyntaxBody `>`
127
-
128
- SyntaxBody ::
129
- > one or more SourceCharacters other than a greater-than sign
130
-
131
- // ============================================================================================
132
- // Syntactic Grammar
133
- // ============================================================================================
134
-
135
- // A doc comment is a sequence of block tags. Leading untagged prose is ignored; each `@tag` opens a
136
- // block that runs until the next `@tag` (so multi-line @example / @summary bodies are captured).
137
- DocComment :
138
- CommentOpen TagList CommentClose
139
-
140
- TagList :
141
- [empty]
142
- TagList BlockTag
143
-
144
- BlockTag :
145
- RecordTag
146
- ClassTag
147
- SummaryTag
148
- RemarksTag
149
- PrivateRemarksTag
150
- ModifierTag
151
- PartTag
152
- CssPropertyTag
153
- CssStateTag
154
- CssFunctionTag
155
- KeyframesTag
156
- LayerTag
157
- ContainerTag
158
- SupportsTag
159
- MediaTag
160
- SlotTag
161
- AccessibilityTag
162
- StructureTag
163
- ExampleTag
164
- DemoTag
165
- DeprecatedTag
166
- SeeTag
167
- SinceTag
168
- GroupTag
169
- DefaultValueTag
170
- ModifierFlagTag
171
- CustomTag
172
-
173
- // --- Record-opening tags (choose the CssRecordKind; `@name` is an alias for `@component`) --------
174
-
175
- RecordTag :
176
- RecordKeyword WhiteSpace RecordName
177
-
178
- RecordKeyword :
179
- `@component`
180
- `@name`
181
- `@utility`
182
- `@rule`
183
- `@declaration`
184
-
185
- // --- Prose tags (TSDoc-adopted) ----------------------------------------------------------------
186
-
187
- ClassTag :
188
- `@class` WhiteSpace ClassSelector
189
-
190
- SummaryTag :
191
- `@summary` WhiteSpace Description
192
-
193
- RemarksTag :
194
- `@remarks` WhiteSpace Description
195
-
196
- PrivateRemarksTag :
197
- `@privateRemarks` WhiteSpace Description
198
-
199
- SeeTag :
200
- `@see` WhiteSpace Description
201
-
202
- SinceTag :
203
- `@since` WhiteSpace Description
204
-
205
- GroupTag :
206
- GroupKeyword WhiteSpace Description
207
-
208
- GroupKeyword :
209
- `@group`
210
- `@category`
211
-
212
- DefaultValueTag :
213
- `@defaultValue` WhiteSpace Description
214
-
215
- DeprecatedTag :
216
- `@deprecated`
217
- `@deprecated` WhiteSpace Description
218
-
219
- ExampleTag :
220
- `@example` ExampleBody
221
-
222
- ExampleBody :
223
- > verbatim example text, which may span multiple lines
224
-
225
- // --- CSS-surface tags (existing + Custom Elements Manifest) ------------------------------------
226
-
227
- // A `-modifier`; the list itself is AST-derived, this supplies prose (or an inline deprecation).
228
- ModifierTag :
229
- `@modifier` WhiteSpace ModifierName
230
- `@modifier` WhiteSpace ModifierName Separator ModifierBody
231
-
232
- ModifierBody :
233
- Description
234
- InlineDeprecation
235
-
236
- // `@deprecated` on a modifier line: free-text guidance and/or a `{@link -canonical}` replacement.
237
- InlineDeprecation :
238
- `@deprecated`
239
- `@deprecated` WhiteSpace Description
240
-
241
- PartTag :
242
- PartKeyword WhiteSpace PartName
243
- PartKeyword WhiteSpace PartName Separator Description
244
-
245
- PartKeyword :
246
- `@part`
247
- `@csspart`
248
-
249
- // A registered custom property. Core reads the `@property` at-rule AST-first; this supplies prose.
250
- CssPropertyTag :
251
- CssPropertyKeyword WhiteSpace CustomPropertyName
252
- CssPropertyKeyword WhiteSpace CustomPropertyName SyntaxDescriptor
253
- CssPropertyKeyword WhiteSpace CustomPropertyName Separator Description
254
- CssPropertyKeyword WhiteSpace CustomPropertyName SyntaxDescriptor Separator Description
255
-
256
- CssPropertyKeyword :
257
- `@cssproperty`
258
- `@property`
259
-
260
- CssStateTag :
261
- `@cssstate` WhiteSpace StateName
262
- `@cssstate` WhiteSpace StateName Separator Description
263
-
264
- StateName :
265
- Identifier
266
-
267
- SlotTag :
268
- `@slot` WhiteSpace SlotName
269
- `@slot` WhiteSpace SlotName Separator Description
270
-
271
- SlotName :
272
- Identifier
273
-
274
- // --- CSSOM at-rule surfaces (AST-derived; prose optional) --------------------------------------
275
-
276
- // A CSS custom function (`@function --name`). Core reads the `@function` at-rule AST-first.
277
- CssFunctionTag :
278
- `@function` WhiteSpace CustomPropertyName
279
- `@function` WhiteSpace CustomPropertyName Separator Description
280
-
281
- // An animation the component exposes (`@keyframes`/`@animation`). AST-derived from `@keyframes`.
282
- KeyframesTag :
283
- KeyframesKeyword WhiteSpace AnimationName
284
- KeyframesKeyword WhiteSpace AnimationName Separator Description
285
-
286
- KeyframesKeyword :
287
- `@keyframes`
288
- `@animation`
289
-
290
- AnimationName :
291
- Identifier
292
-
293
- // A cascade layer (`@layer`). AST-derived from `@layer` names.
294
- LayerTag :
295
- `@layer` WhiteSpace LayerName
296
- `@layer` WhiteSpace LayerName Separator Description
297
-
298
- LayerName ::
299
- > a cascade-layer name, optionally dotted, e.g. theme.dark
300
-
301
- // A container-query surface (`@container`). AST-derived from `@container` / `container-name`.
302
- ContainerTag :
303
- `@container` WhiteSpace Description
304
-
305
- // A feature-query dependency (`@supports`). AST-derived from `@supports` conditions.
306
- SupportsTag :
307
- `@supports` WhiteSpace Description
308
-
309
- // Responsive behavior (`@media`/`@responsive`). AST-derived from `@media` conditions.
310
- MediaTag :
311
- MediaKeyword WhiteSpace Description
312
-
313
- MediaKeyword :
314
- `@media`
315
- `@responsive`
316
-
317
- // Accessibility guidance.
318
- AccessibilityTag :
319
- AccessibilityKeyword WhiteSpace Description
320
-
321
- AccessibilityKeyword :
322
- `@a11y`
323
- `@accessibility`
324
-
325
- // --- Structure & demo --------------------------------------------------------------------------
326
-
327
- StructureTag :
328
- `@structure` LineTerminator StructureTree
329
-
330
- // Indentation-nested selectors: each deeper indent level is a child of the line above. Layout
331
- // sensitivity (INDENT / DEDENT) sits outside pure context-free notation, so it is given as prose.
332
- StructureTree ::
333
- > one selector per line; a greater indent than the preceding line makes the node its child
334
-
335
- DemoTag :
336
- `@demo` WhiteSpace DemoSpec
337
-
338
- DemoSpec :
339
- Url
340
- Provider `:` Ref
341
- `self` `:` RecordName
342
-
343
- Provider ::
344
- Identifier
345
-
346
- Ref ::
347
- > a provider-specific reference token
348
-
349
- Url ::
350
- > an absolute URL
351
-
352
- // --- Modifier (flag) tags: release stage / traits; presence means true ------------------------
353
-
354
- ModifierFlagTag :
355
- `@alpha`
356
- `@beta`
357
- `@experimental`
358
- `@internal`
359
- `@public`
360
-
361
- // --- Custom tags: registered via @cssdoc/config; unregistered tags are ignored ----------------
362
-
363
- CustomTag :
364
- BlockSigil Identifier
365
- BlockSigil Identifier WhiteSpace CustomTagContent
366
-
367
- CustomTagContent ::
368
- > tag-specific content, interpreted per the tag's configured syntax kind
369
-
370
- // ============================================================================================
371
- // Descriptions & inline tags
372
- // ============================================================================================
373
-
374
- // Free-text prose that may interleave inline tags. This is where the CssReference — cssdoc's analog
375
- // to TSDoc's DeclarationReference — is used.
376
- Description :
377
- DescriptionAtom
378
- Description DescriptionAtom
379
-
380
- DescriptionAtom :
381
- TextRun
382
- InlineTag
383
-
384
- TextRun ::
385
- > a run of prose containing no inline tag
386
-
387
- InlineTag :
388
- LinkTag
389
- InheritDocTag
390
- LabelTag
391
-
392
- LinkTag :
393
- InlineOpen `link` WhiteSpace CssReference InlineClose
394
-
395
- InheritDocTag :
396
- InlineOpen `inheritDoc` WhiteSpace CssReference InlineClose
397
-
398
- LabelTag :
399
- InlineOpen `label` WhiteSpace Identifier InlineClose
400
-
401
- // The target of an inline reference: a modifier, a part, or a record — the CSS analog of TSDoc's
402
- // DeclarationReference top-level production.
403
- CssReference :
404
- ModifierName
405
- PartName
406
- RecordName