rbtr-lang-scss 2026.9.0.dev1__tar.gz

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alejandro Giacometti
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,70 @@
1
+ Metadata-Version: 2.4
2
+ Name: rbtr-lang-scss
3
+ Version: 2026.9.0.dev1
4
+ Summary: rbtr — SCSS/Sass language plugin
5
+ Keywords: code-search,code-index,tree-sitter,static-analysis,semantic-search,developer-tools,scss,sass
6
+ Author: Alejandro Giacometti
7
+ Author-email: Alejandro Giacometti <alejandro.giacometti@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Software Development :: Libraries
15
+ Classifier: Topic :: Text Processing :: Indexing
16
+ Classifier: Typing :: Typed
17
+ Requires-Dist: rbtr==2026.9.0.dev1
18
+ Requires-Dist: rbtr-lang-css==2026.9.0.dev1
19
+ Requires-Dist: tree-sitter-scss
20
+ Requires-Python: >=3.13
21
+ Project-URL: Homepage, https://github.com/janrito/rbtr
22
+ Project-URL: Repository, https://github.com/janrito/rbtr
23
+ Project-URL: Documentation, https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-scss#readme
24
+ Project-URL: Issues, https://github.com/janrito/rbtr/issues
25
+ Project-URL: Changelog, https://github.com/janrito/rbtr/releases
26
+ Description-Content-Type: text/markdown
27
+
28
+ # rbtr-lang-scss
29
+
30
+ SCSS / Sass support for [rbtr]. Optional plugin — install with
31
+ `pip install rbtr[scss]`.
32
+
33
+ [rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
34
+
35
+ ## What it ingests
36
+
37
+ SCSS extends CSS with the Sass preprocessor constructs. Definitions map onto
38
+ rbtr's capture conventions by shape:
39
+
40
+ - **Variables** — `$`-prefixed declarations (`$primary: #333;`).
41
+ - **Routines** — `@mixin` and `@function` definitions → functions.
42
+ - **Rule sets & at-rule blocks** — selectors (incl. `%placeholder`), `@media`,
43
+ `@keyframes` → classes (a named collection of declarations).
44
+ - **Directives** — `@charset` → config key.
45
+ - **Imports** — `@use` / `@forward` / `@import` → imports (for cross-file
46
+ edges).
47
+
48
+ ## Chunks produced
49
+
50
+ `name` is the declaration/selector; `scope` is the ancestor rule-set
51
+ selectors for a nested rule (CSS-family nesting), else empty.
52
+
53
+ ```scss
54
+ $primary: #333; /* variable "$primary" */
55
+ @mixin flex($dir) { … } /* function "flex" */
56
+ @function rem($px) { … } /* function "rem" */
57
+ %card { … } /* class "%card" */
58
+ .btn { … } /* class ".btn" */
59
+ @keyframes slide { … } /* class "slide" */
60
+ @use "config"; /* import, metadata {module: "config"} */
61
+ ```
62
+
63
+ ## Embedded / injected chunks
64
+
65
+ None. SCSS does not embed other languages (it is embedded by the SFC plugins).
66
+
67
+ ## Grammar & dependencies
68
+
69
+ Uses the `tree-sitter-scss` grammar. Depends on **rbtr-lang-css** — it reuses
70
+ that plugin's public `css_nesting_scope` helper for CSS-family rule nesting.
@@ -0,0 +1,43 @@
1
+ # rbtr-lang-scss
2
+
3
+ SCSS / Sass support for [rbtr]. Optional plugin — install with
4
+ `pip install rbtr[scss]`.
5
+
6
+ [rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
7
+
8
+ ## What it ingests
9
+
10
+ SCSS extends CSS with the Sass preprocessor constructs. Definitions map onto
11
+ rbtr's capture conventions by shape:
12
+
13
+ - **Variables** — `$`-prefixed declarations (`$primary: #333;`).
14
+ - **Routines** — `@mixin` and `@function` definitions → functions.
15
+ - **Rule sets & at-rule blocks** — selectors (incl. `%placeholder`), `@media`,
16
+ `@keyframes` → classes (a named collection of declarations).
17
+ - **Directives** — `@charset` → config key.
18
+ - **Imports** — `@use` / `@forward` / `@import` → imports (for cross-file
19
+ edges).
20
+
21
+ ## Chunks produced
22
+
23
+ `name` is the declaration/selector; `scope` is the ancestor rule-set
24
+ selectors for a nested rule (CSS-family nesting), else empty.
25
+
26
+ ```scss
27
+ $primary: #333; /* variable "$primary" */
28
+ @mixin flex($dir) { … } /* function "flex" */
29
+ @function rem($px) { … } /* function "rem" */
30
+ %card { … } /* class "%card" */
31
+ .btn { … } /* class ".btn" */
32
+ @keyframes slide { … } /* class "slide" */
33
+ @use "config"; /* import, metadata {module: "config"} */
34
+ ```
35
+
36
+ ## Embedded / injected chunks
37
+
38
+ None. SCSS does not embed other languages (it is embedded by the SFC plugins).
39
+
40
+ ## Grammar & dependencies
41
+
42
+ Uses the `tree-sitter-scss` grammar. Depends on **rbtr-lang-css** — it reuses
43
+ that plugin's public `css_nesting_scope` helper for CSS-family rule nesting.
@@ -0,0 +1,62 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.11.26,<1"]
3
+ build-backend = "uv_build"
4
+
5
+ [tool.uv.build-backend]
6
+ module-name = "rbtr_lang_scss"
7
+
8
+ [tool.uv.sources.rbtr]
9
+ workspace = true
10
+
11
+ [tool.uv.sources.rbtr-lang-css]
12
+ workspace = true
13
+
14
+ [project]
15
+ name = "rbtr-lang-scss"
16
+ version = "2026.9.0-dev1"
17
+ description = "rbtr — SCSS/Sass language plugin"
18
+ readme = "README.md"
19
+ license = "MIT"
20
+ license-files = ["LICENSE"]
21
+ keywords = [
22
+ "code-search",
23
+ "code-index",
24
+ "tree-sitter",
25
+ "static-analysis",
26
+ "semantic-search",
27
+ "developer-tools",
28
+ "scss",
29
+ "sass",
30
+ ]
31
+ classifiers = [
32
+ "Development Status :: 4 - Beta",
33
+ "Intended Audience :: Developers",
34
+ "Programming Language :: Python :: 3 :: Only",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Topic :: Software Development :: Libraries",
37
+ "Topic :: Text Processing :: Indexing",
38
+ "Typing :: Typed",
39
+ ]
40
+ requires-python = ">=3.13"
41
+ dependencies = [
42
+ "rbtr==2026.9.0-dev1",
43
+ "rbtr-lang-css==2026.9.0-dev1",
44
+ "tree-sitter-scss",
45
+ ]
46
+
47
+ [[project.authors]]
48
+ name = "Alejandro Giacometti"
49
+ email = "alejandro.giacometti@gmail.com"
50
+
51
+ [project.urls]
52
+ Homepage = "https://github.com/janrito/rbtr"
53
+ Repository = "https://github.com/janrito/rbtr"
54
+ Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-scss#readme"
55
+ Issues = "https://github.com/janrito/rbtr/issues"
56
+ Changelog = "https://github.com/janrito/rbtr/releases"
57
+
58
+ [project.entry-points."rbtr.languages"]
59
+ scss = "rbtr_lang_scss.plugin:scss"
60
+
61
+ [dependency-groups]
62
+ dev = ["rbtr[test]"]
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.11.26,<1"]
3
+ build-backend = "uv_build"
4
+
5
+ [tool.uv.build-backend]
6
+ module-name = "rbtr_lang_scss"
7
+ # No source-exclude: the plugin's tests, samples, and snapshots ship
8
+ # with the wheel (they are the language's golden record), and scss.scm
9
+ # ships as package data.
10
+
11
+ [project]
12
+ name = "rbtr-lang-scss"
13
+ version = "2026.9.0-dev1"
14
+ description = "rbtr — SCSS/Sass language plugin"
15
+ readme = "README.md"
16
+ license = "MIT"
17
+ license-files = ["LICENSE"]
18
+ authors = [
19
+ { name = "Alejandro Giacometti", email = "alejandro.giacometti@gmail.com" },
20
+ ]
21
+ keywords = [
22
+ "code-search",
23
+ "code-index",
24
+ "tree-sitter",
25
+ "static-analysis",
26
+ "semantic-search",
27
+ "developer-tools",
28
+ "scss",
29
+ "sass",
30
+ ]
31
+ classifiers = [
32
+ "Development Status :: 4 - Beta",
33
+ "Intended Audience :: Developers",
34
+ "Programming Language :: Python :: 3 :: Only",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Topic :: Software Development :: Libraries",
37
+ "Topic :: Text Processing :: Indexing",
38
+ "Typing :: Typed",
39
+ ]
40
+ requires-python = ">=3.13"
41
+ dependencies = [
42
+ "rbtr==2026.9.0-dev1",
43
+ # Reuses css_nesting_scope from the css plugin (CSS-family nesting).
44
+ "rbtr-lang-css==2026.9.0-dev1",
45
+ "tree-sitter-scss",
46
+ ]
47
+
48
+ [project.urls]
49
+ Homepage = "https://github.com/janrito/rbtr"
50
+ Repository = "https://github.com/janrito/rbtr"
51
+ Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-scss#readme"
52
+ Issues = "https://github.com/janrito/rbtr/issues"
53
+ Changelog = "https://github.com/janrito/rbtr/releases"
54
+
55
+ [project.entry-points."rbtr.languages"]
56
+ # The value resolves to the language's `LanguageRegistration` (named by its
57
+ # id) — see the rbtr ARCHITECTURE "External plugins" note.
58
+ scss = "rbtr_lang_scss.plugin:scss"
59
+
60
+ [tool.uv.sources]
61
+ rbtr = { workspace = true }
62
+ rbtr-lang-css = { workspace = true }
63
+
64
+ [dependency-groups]
65
+ dev = ["rbtr[test]"]
@@ -0,0 +1 @@
1
+ """SCSS language plugin package."""
@@ -0,0 +1,43 @@
1
+ """SCSS / Sass language plugin.
2
+
3
+ Extends CSS extraction with the Sass preprocessor constructs,
4
+ via a tree-sitter query. Rule sets (incl. `%placeholder`
5
+ selectors) and `@media`/`@keyframes` blocks are captured as
6
+ classes; `@charset` as a config key; `$`-prefixed declarations
7
+ as variables; `@mixin` and `@function` definitions as functions;
8
+ `@use`/`@forward`/`@import` as imports for cross-file edges.
9
+
10
+ Extracted chunks::
11
+
12
+ $primary: #333; → variable "$primary"
13
+ @mixin flex($dir) { ... } → function "flex"
14
+ @function rem($px) { ... } → function "rem"
15
+ %card { ... } → class "%card"
16
+ .btn { ... } → class ".btn"
17
+ @keyframes slide { ... } → class "slide"
18
+ @use "config"; → import, metadata {module: "config"}
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ from rbtr.languages.registration import (
24
+ LanguageRegistration,
25
+ QueryExtraction,
26
+ build_quoted_import,
27
+ load_query,
28
+ )
29
+ from rbtr_lang_css.plugin import css_nesting_scope
30
+
31
+ scss = LanguageRegistration(
32
+ id="scss",
33
+ extensions=frozenset({".scss"}),
34
+ grammar_module="tree_sitter_scss",
35
+ extraction=QueryExtraction(
36
+ query=load_query(__package__, "scss"),
37
+ ),
38
+ import_targets=frozenset({"css", "scss", "less"}),
39
+ extraction_serial=3,
40
+ )
41
+
42
+ scss.scope_extractor(css_nesting_scope)
43
+ scss.import_extractor(build_quoted_import)
@@ -0,0 +1,32 @@
1
+
2
+ ; Comments (SCSS: `/* */` is `comment`, `//` is `js_comment`).
3
+ [(comment) (js_comment)] @comment
4
+
5
+ (declaration
6
+ (property_name) @_var_name
7
+ (#match? @_var_name "^[$]")) @variable
8
+
9
+ (mixin_statement
10
+ (identifier) @_fn_name) @function
11
+
12
+ (function_statement
13
+ (identifier) @_fn_name) @function
14
+
15
+ (rule_set
16
+ (selectors) @_cls_name) @class
17
+
18
+ (media_statement) @class
19
+
20
+ (charset_statement) @config_key
21
+
22
+ (keyframes_statement
23
+ (keyframes_name) @_cls_name) @class
24
+
25
+ (use_statement
26
+ (string_value) @_import_module) @import
27
+
28
+ (forward_statement
29
+ (string_value) @_import_module) @import
30
+
31
+ (import_statement
32
+ (string_value) @_import_module) @import
@@ -0,0 +1,7 @@
1
+ [
2
+ "partials/dark.scss::@use \"tokens\"; -> partials/tokens.scss::$ink [imports]",
3
+ "scss.scss::@forward \"theme\"; -> theme.scss::$radius [imports]",
4
+ "scss.scss::@import \"reset\"; -> reset.scss::* [imports]",
5
+ "scss.scss::@use \"config\"; -> config.scss::$brand [imports]",
6
+ "scss.scss::@use \"partials/dark\"; -> partials/dark.scss::.greeting--dark [imports]"
7
+ ]
@@ -0,0 +1,496 @@
1
+ [
2
+ {
3
+ "blob_sha": "sha1",
4
+ "file_path": "config.scss",
5
+ "kind": "comment",
6
+ "name": "",
7
+ "scope": "",
8
+ "language": "scss",
9
+ "file_language": "scss",
10
+ "content": "// Imported by scss.scss via `@use \"config\"`.",
11
+ "line_start": 1,
12
+ "line_end": 1,
13
+ "metadata": {
14
+ "module": "",
15
+ "names": "",
16
+ "dots": "",
17
+ "language_hint": ""
18
+ },
19
+ "id": "10b9e0c7ef48dbc6"
20
+ },
21
+ {
22
+ "blob_sha": "sha1",
23
+ "file_path": "config.scss",
24
+ "kind": "variable",
25
+ "name": "$brand",
26
+ "scope": "",
27
+ "language": "scss",
28
+ "file_language": "scss",
29
+ "content": "$brand: #00aa77;",
30
+ "line_start": 3,
31
+ "line_end": 3,
32
+ "metadata": {
33
+ "module": "",
34
+ "names": "",
35
+ "dots": "",
36
+ "language_hint": ""
37
+ },
38
+ "id": "52e340a0eb1936f5"
39
+ },
40
+ {
41
+ "blob_sha": "sha1",
42
+ "file_path": "partials/dark.scss",
43
+ "kind": "comment",
44
+ "name": "",
45
+ "scope": "",
46
+ "language": "scss",
47
+ "file_language": "scss",
48
+ "content": "// Used by scss.scss. Uses its own sibling by bare name, which only\n// resolves relative to this directory.",
49
+ "line_start": 1,
50
+ "line_end": 2,
51
+ "metadata": {
52
+ "module": "",
53
+ "names": "",
54
+ "dots": "",
55
+ "language_hint": ""
56
+ },
57
+ "id": "c6843977ca6a1f31"
58
+ },
59
+ {
60
+ "blob_sha": "sha1",
61
+ "file_path": "partials/dark.scss",
62
+ "kind": "import",
63
+ "name": "@use \"tokens\";",
64
+ "scope": "",
65
+ "language": "scss",
66
+ "file_language": "scss",
67
+ "content": "@use \"tokens\";",
68
+ "line_start": 3,
69
+ "line_end": 3,
70
+ "metadata": {
71
+ "module": "tokens",
72
+ "names": "",
73
+ "dots": "",
74
+ "language_hint": ""
75
+ },
76
+ "id": "fb5ca20e552f6628"
77
+ },
78
+ {
79
+ "blob_sha": "sha1",
80
+ "file_path": "partials/dark.scss",
81
+ "kind": "class",
82
+ "name": ".greeting--dark",
83
+ "scope": "",
84
+ "language": "scss",
85
+ "file_language": "scss",
86
+ "content": ".greeting--dark {\n color: tokens.$ink;\n}",
87
+ "line_start": 5,
88
+ "line_end": 7,
89
+ "metadata": {
90
+ "module": "",
91
+ "names": "",
92
+ "dots": "",
93
+ "language_hint": ""
94
+ },
95
+ "id": "1f9af74673427ce0"
96
+ },
97
+ {
98
+ "blob_sha": "sha1",
99
+ "file_path": "partials/tokens.scss",
100
+ "kind": "variable",
101
+ "name": "$ink",
102
+ "scope": "",
103
+ "language": "scss",
104
+ "file_language": "scss",
105
+ "content": "// Used by partials/dark.scss as a bare sibling.\n$ink: #eeeeee;",
106
+ "line_start": 1,
107
+ "line_end": 2,
108
+ "metadata": {
109
+ "module": "",
110
+ "names": "",
111
+ "dots": "",
112
+ "language_hint": ""
113
+ },
114
+ "id": "6422526823945bc5"
115
+ },
116
+ {
117
+ "blob_sha": "sha1",
118
+ "file_path": "reset.scss",
119
+ "kind": "comment",
120
+ "name": "",
121
+ "scope": "",
122
+ "language": "scss",
123
+ "file_language": "scss",
124
+ "content": "// Imported by scss.scss via `@import \"reset\"`.",
125
+ "line_start": 1,
126
+ "line_end": 1,
127
+ "metadata": {
128
+ "module": "",
129
+ "names": "",
130
+ "dots": "",
131
+ "language_hint": ""
132
+ },
133
+ "id": "10b9e0c7ef48dbc6"
134
+ },
135
+ {
136
+ "blob_sha": "sha1",
137
+ "file_path": "reset.scss",
138
+ "kind": "class",
139
+ "name": "*",
140
+ "scope": "",
141
+ "language": "scss",
142
+ "file_language": "scss",
143
+ "content": "* {\n margin: 0;\n padding: 0;\n}",
144
+ "line_start": 3,
145
+ "line_end": 6,
146
+ "metadata": {
147
+ "module": "",
148
+ "names": "",
149
+ "dots": "",
150
+ "language_hint": ""
151
+ },
152
+ "id": "719eb53fd28a4226"
153
+ },
154
+ {
155
+ "blob_sha": "sha1",
156
+ "file_path": "scss.scss",
157
+ "kind": "comment",
158
+ "name": "",
159
+ "scope": "",
160
+ "language": "scss",
161
+ "file_language": "scss",
162
+ "content": "// Greeter theme (SCSS).\n//\n// The SCSS plugin extracts $-variables, @mixin and @function definitions,\n// rule sets (including %placeholders and nested rules), @media/@charset/\n// @keyframes as doc sections, and @use/@forward/@import as imports.",
163
+ "line_start": 1,
164
+ "line_end": 5,
165
+ "metadata": {
166
+ "module": "",
167
+ "names": "",
168
+ "dots": "",
169
+ "language_hint": ""
170
+ },
171
+ "id": "cff1e9ff754e1d2d"
172
+ },
173
+ {
174
+ "blob_sha": "sha1",
175
+ "file_path": "scss.scss",
176
+ "kind": "config_key",
177
+ "name": "",
178
+ "scope": "",
179
+ "language": "scss",
180
+ "file_language": "scss",
181
+ "content": "@charset \"UTF-8\";",
182
+ "line_start": 7,
183
+ "line_end": 7,
184
+ "metadata": {
185
+ "module": "",
186
+ "names": "",
187
+ "dots": "",
188
+ "language_hint": ""
189
+ },
190
+ "id": "1acf400ee24cb6b3"
191
+ },
192
+ {
193
+ "blob_sha": "sha1",
194
+ "file_path": "scss.scss",
195
+ "kind": "import",
196
+ "name": "@use \"config\";",
197
+ "scope": "",
198
+ "language": "scss",
199
+ "file_language": "scss",
200
+ "content": "@use \"config\";",
201
+ "line_start": 9,
202
+ "line_end": 9,
203
+ "metadata": {
204
+ "module": "config",
205
+ "names": "",
206
+ "dots": "",
207
+ "language_hint": ""
208
+ },
209
+ "id": "5b65dc8850d3d6d5"
210
+ },
211
+ {
212
+ "blob_sha": "sha1",
213
+ "file_path": "scss.scss",
214
+ "kind": "import",
215
+ "name": "@forward \"theme\";",
216
+ "scope": "",
217
+ "language": "scss",
218
+ "file_language": "scss",
219
+ "content": "@forward \"theme\";",
220
+ "line_start": 10,
221
+ "line_end": 10,
222
+ "metadata": {
223
+ "module": "theme",
224
+ "names": "",
225
+ "dots": "",
226
+ "language_hint": ""
227
+ },
228
+ "id": "d5fd0a10aa078b1b"
229
+ },
230
+ {
231
+ "blob_sha": "sha1",
232
+ "file_path": "scss.scss",
233
+ "kind": "import",
234
+ "name": "@import \"reset\";",
235
+ "scope": "",
236
+ "language": "scss",
237
+ "file_language": "scss",
238
+ "content": "@import \"reset\";",
239
+ "line_start": 11,
240
+ "line_end": 11,
241
+ "metadata": {
242
+ "module": "reset",
243
+ "names": "",
244
+ "dots": "",
245
+ "language_hint": ""
246
+ },
247
+ "id": "b8bb8586a8f0b2f3"
248
+ },
249
+ {
250
+ "blob_sha": "sha1",
251
+ "file_path": "scss.scss",
252
+ "kind": "variable",
253
+ "name": "$primary",
254
+ "scope": "",
255
+ "language": "scss",
256
+ "file_language": "scss",
257
+ "content": "$primary: #333;",
258
+ "line_start": 13,
259
+ "line_end": 13,
260
+ "metadata": {
261
+ "module": "",
262
+ "names": "",
263
+ "dots": "",
264
+ "language_hint": ""
265
+ },
266
+ "id": "eb470061d1a7b0d7"
267
+ },
268
+ {
269
+ "blob_sha": "sha1",
270
+ "file_path": "scss.scss",
271
+ "kind": "variable",
272
+ "name": "$spacing",
273
+ "scope": "",
274
+ "language": "scss",
275
+ "file_language": "scss",
276
+ "content": "$spacing: 8px;",
277
+ "line_start": 14,
278
+ "line_end": 14,
279
+ "metadata": {
280
+ "module": "",
281
+ "names": "",
282
+ "dots": "",
283
+ "language_hint": ""
284
+ },
285
+ "id": "f2f236eb0be1b193"
286
+ },
287
+ {
288
+ "blob_sha": "sha1",
289
+ "file_path": "scss.scss",
290
+ "kind": "function",
291
+ "name": "flex-center",
292
+ "scope": "",
293
+ "language": "scss",
294
+ "file_language": "scss",
295
+ "content": "@mixin flex-center($direction: row) {\n display: flex;\n flex-direction: $direction;\n align-items: center;\n}",
296
+ "line_start": 16,
297
+ "line_end": 20,
298
+ "metadata": {
299
+ "module": "",
300
+ "names": "",
301
+ "dots": "",
302
+ "language_hint": ""
303
+ },
304
+ "id": "e0552982f0d82fec"
305
+ },
306
+ {
307
+ "blob_sha": "sha1",
308
+ "file_path": "scss.scss",
309
+ "kind": "function",
310
+ "name": "rem",
311
+ "scope": "",
312
+ "language": "scss",
313
+ "file_language": "scss",
314
+ "content": "@function rem($px) {\n @return $px * 1rem;\n}",
315
+ "line_start": 22,
316
+ "line_end": 24,
317
+ "metadata": {
318
+ "module": "",
319
+ "names": "",
320
+ "dots": "",
321
+ "language_hint": ""
322
+ },
323
+ "id": "d473ca15da3fdc5f"
324
+ },
325
+ {
326
+ "blob_sha": "sha1",
327
+ "file_path": "scss.scss",
328
+ "kind": "class",
329
+ "name": "%card-base",
330
+ "scope": "",
331
+ "language": "scss",
332
+ "file_language": "scss",
333
+ "content": "%card-base {\n border-radius: 4px;\n padding: $spacing;\n}",
334
+ "line_start": 26,
335
+ "line_end": 29,
336
+ "metadata": {
337
+ "module": "",
338
+ "names": "",
339
+ "dots": "",
340
+ "language_hint": ""
341
+ },
342
+ "id": "8f095b47d2535eb6"
343
+ },
344
+ {
345
+ "blob_sha": "sha1",
346
+ "file_path": "scss.scss",
347
+ "kind": "class",
348
+ "name": ".greeter",
349
+ "scope": "",
350
+ "language": "scss",
351
+ "file_language": "scss",
352
+ "content": ".greeter {\n color: $primary;\n @include flex-center(column);\n\n &:hover {\n color: blue;\n }\n}",
353
+ "line_start": 31,
354
+ "line_end": 38,
355
+ "metadata": {
356
+ "module": "",
357
+ "names": "",
358
+ "dots": "",
359
+ "language_hint": ""
360
+ },
361
+ "id": "a2cb287a9ded83d2"
362
+ },
363
+ {
364
+ "blob_sha": "sha1",
365
+ "file_path": "scss.scss",
366
+ "kind": "class",
367
+ "name": "&:hover",
368
+ "scope": ".greeter",
369
+ "language": "scss",
370
+ "file_language": "scss",
371
+ "content": "&:hover {\n color: blue;\n }",
372
+ "line_start": 35,
373
+ "line_end": 37,
374
+ "metadata": {
375
+ "module": "",
376
+ "names": "",
377
+ "dots": "",
378
+ "language_hint": ""
379
+ },
380
+ "id": "c80bf42a8e0a332e"
381
+ },
382
+ {
383
+ "blob_sha": "sha1",
384
+ "file_path": "scss.scss",
385
+ "kind": "class",
386
+ "name": "",
387
+ "scope": "",
388
+ "language": "scss",
389
+ "file_language": "scss",
390
+ "content": "@media (max-width: 600px) {\n .greeter {\n font-size: rem(14);\n }\n}",
391
+ "line_start": 40,
392
+ "line_end": 44,
393
+ "metadata": {
394
+ "module": "",
395
+ "names": "",
396
+ "dots": "",
397
+ "language_hint": ""
398
+ },
399
+ "id": "458eced79f685c08"
400
+ },
401
+ {
402
+ "blob_sha": "sha1",
403
+ "file_path": "scss.scss",
404
+ "kind": "class",
405
+ "name": ".greeter",
406
+ "scope": "",
407
+ "language": "scss",
408
+ "file_language": "scss",
409
+ "content": ".greeter {\n font-size: rem(14);\n }",
410
+ "line_start": 41,
411
+ "line_end": 43,
412
+ "metadata": {
413
+ "module": "",
414
+ "names": "",
415
+ "dots": "",
416
+ "language_hint": ""
417
+ },
418
+ "id": "065098f107e87ec7"
419
+ },
420
+ {
421
+ "blob_sha": "sha1",
422
+ "file_path": "scss.scss",
423
+ "kind": "class",
424
+ "name": "greeting-fade",
425
+ "scope": "",
426
+ "language": "scss",
427
+ "file_language": "scss",
428
+ "content": "@keyframes greeting-fade {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}",
429
+ "line_start": 46,
430
+ "line_end": 53,
431
+ "metadata": {
432
+ "module": "",
433
+ "names": "",
434
+ "dots": "",
435
+ "language_hint": ""
436
+ },
437
+ "id": "a56c5673f0ac04b8"
438
+ },
439
+ {
440
+ "blob_sha": "sha1",
441
+ "file_path": "scss.scss",
442
+ "kind": "import",
443
+ "name": "@use \"partials/dark\";",
444
+ "scope": "",
445
+ "language": "scss",
446
+ "file_language": "scss",
447
+ "content": "@use \"partials/dark\";",
448
+ "line_start": 55,
449
+ "line_end": 55,
450
+ "metadata": {
451
+ "module": "partials/dark",
452
+ "names": "",
453
+ "dots": "",
454
+ "language_hint": ""
455
+ },
456
+ "id": "f356c78c2fc2927d"
457
+ },
458
+ {
459
+ "blob_sha": "sha1",
460
+ "file_path": "theme.scss",
461
+ "kind": "comment",
462
+ "name": "",
463
+ "scope": "",
464
+ "language": "scss",
465
+ "file_language": "scss",
466
+ "content": "// Re-exported by scss.scss via `@forward \"theme\"`.",
467
+ "line_start": 1,
468
+ "line_end": 1,
469
+ "metadata": {
470
+ "module": "",
471
+ "names": "",
472
+ "dots": "",
473
+ "language_hint": ""
474
+ },
475
+ "id": "10b9e0c7ef48dbc6"
476
+ },
477
+ {
478
+ "blob_sha": "sha1",
479
+ "file_path": "theme.scss",
480
+ "kind": "variable",
481
+ "name": "$radius",
482
+ "scope": "",
483
+ "language": "scss",
484
+ "file_language": "scss",
485
+ "content": "$radius: 6px;",
486
+ "line_start": 3,
487
+ "line_end": 3,
488
+ "metadata": {
489
+ "module": "",
490
+ "names": "",
491
+ "dots": "",
492
+ "language_hint": ""
493
+ },
494
+ "id": "1780202d18786446"
495
+ }
496
+ ]
@@ -0,0 +1,3 @@
1
+ // Imported by scss.scss via `@use "config"`.
2
+
3
+ $brand: #00aa77;
@@ -0,0 +1,7 @@
1
+ // Used by scss.scss. Uses its own sibling by bare name, which only
2
+ // resolves relative to this directory.
3
+ @use "tokens";
4
+
5
+ .greeting--dark {
6
+ color: tokens.$ink;
7
+ }
@@ -0,0 +1,2 @@
1
+ // Used by partials/dark.scss as a bare sibling.
2
+ $ink: #eeeeee;
@@ -0,0 +1,6 @@
1
+ // Imported by scss.scss via `@import "reset"`.
2
+
3
+ * {
4
+ margin: 0;
5
+ padding: 0;
6
+ }
@@ -0,0 +1,55 @@
1
+ // Greeter theme (SCSS).
2
+ //
3
+ // The SCSS plugin extracts $-variables, @mixin and @function definitions,
4
+ // rule sets (including %placeholders and nested rules), @media/@charset/
5
+ // @keyframes as doc sections, and @use/@forward/@import as imports.
6
+
7
+ @charset "UTF-8";
8
+
9
+ @use "config";
10
+ @forward "theme";
11
+ @import "reset";
12
+
13
+ $primary: #333;
14
+ $spacing: 8px;
15
+
16
+ @mixin flex-center($direction: row) {
17
+ display: flex;
18
+ flex-direction: $direction;
19
+ align-items: center;
20
+ }
21
+
22
+ @function rem($px) {
23
+ @return $px * 1rem;
24
+ }
25
+
26
+ %card-base {
27
+ border-radius: 4px;
28
+ padding: $spacing;
29
+ }
30
+
31
+ .greeter {
32
+ color: $primary;
33
+ @include flex-center(column);
34
+
35
+ &:hover {
36
+ color: blue;
37
+ }
38
+ }
39
+
40
+ @media (max-width: 600px) {
41
+ .greeter {
42
+ font-size: rem(14);
43
+ }
44
+ }
45
+
46
+ @keyframes greeting-fade {
47
+ from {
48
+ opacity: 0;
49
+ }
50
+ to {
51
+ opacity: 1;
52
+ }
53
+ }
54
+
55
+ @use "partials/dark";
@@ -0,0 +1,3 @@
1
+ // Re-exported by scss.scss via `@forward "theme"`.
2
+
3
+ $radius: 6px;
@@ -0,0 +1,83 @@
1
+ """SCSS sample extraction: the `samples/scss/` project through the real pipeline.
2
+
3
+ The snapshots are the golden record of what SCSS extraction produces.
4
+ Engine-wide invariants are covered once in core.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from pathlib import Path
10
+ from typing import TYPE_CHECKING
11
+
12
+ import pytest
13
+ from tree_sitter import Parser
14
+
15
+ from rbtr.domain.models import Chunk, ChunkKind, Edge
16
+ from rbtr.git import FileEntry
17
+ from rbtr.languages.edges import build_resolution_map, infer_import_edges
18
+ from rbtr.languages.extract import extract_file
19
+ from rbtr.languages.manager import get_manager
20
+ from rbtr.testing import render_edges
21
+
22
+ if TYPE_CHECKING:
23
+ from syrupy.assertion import SnapshotAssertion
24
+
25
+
26
+ @pytest.fixture
27
+ def project() -> list[tuple[str, str]]:
28
+ """The `(relative path, text)` files of the `samples/scss/` project."""
29
+ root = Path(__file__).parent / "samples" / "scss"
30
+ return [
31
+ (str(p.relative_to(root)), p.read_text()) for p in sorted(root.rglob("*")) if p.is_file()
32
+ ]
33
+
34
+
35
+ @pytest.fixture
36
+ def chunks(project: list[tuple[str, str]]) -> list[Chunk]:
37
+ """Chunks from every project file, each via the real `extract_file`."""
38
+ manager = get_manager()
39
+ out: list[Chunk] = []
40
+ for path, text in project:
41
+ lang = manager.detect_language(path) or "scss"
42
+ out.extend(extract_file(FileEntry(path, "sha1", text.encode()), lang))
43
+ return out
44
+
45
+
46
+ @pytest.fixture
47
+ def edges(project: list[tuple[str, str]], chunks: list[Chunk]) -> list[Edge]:
48
+ """Import edges inferred across the project's files."""
49
+ manager = get_manager()
50
+ repo_files = {path for path, _ in project}
51
+ return infer_import_edges(chunks, repo_files, build_resolution_map(manager))
52
+
53
+
54
+ def test_emits_expected_kinds(chunks: list[Chunk]) -> None:
55
+ """The sample exercises SCSS's class, variable, function, config-key, and import chunks."""
56
+ kinds = {c.kind for c in chunks}
57
+ assert {
58
+ ChunkKind.CLASS,
59
+ ChunkKind.VARIABLE,
60
+ ChunkKind.FUNCTION,
61
+ ChunkKind.CONFIG_KEY,
62
+ ChunkKind.IMPORT,
63
+ ChunkKind.COMMENT,
64
+ } <= kinds
65
+
66
+
67
+ def test_parses_cleanly(project: list[tuple[str, str]]) -> None:
68
+ """Every project file is valid source — no tree-sitter ERROR/MISSING nodes."""
69
+ manager = get_manager()
70
+ for path, text in project:
71
+ grammar = manager.grammar(manager.detect_language(path) or "scss")
72
+ assert grammar is not None
73
+ assert not Parser(grammar).parse(text.encode()).root_node.has_error, path
74
+
75
+
76
+ def test_extraction_matches_snapshot(chunks: list[Chunk], snapshot_json: SnapshotAssertion) -> None:
77
+ assert chunks == snapshot_json
78
+
79
+
80
+ def test_edges_match_snapshot(
81
+ chunks: list[Chunk], edges: list[Edge], snapshot_json: SnapshotAssertion
82
+ ) -> None:
83
+ assert render_edges(edges, chunks) == snapshot_json