rbtr-lang-less 2026.7.0.dev0__py3-none-any.whl

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 @@
1
+ """Less language plugin package."""
@@ -0,0 +1,23 @@
1
+
2
+ ; Comments (Less: `/* */` 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_definition
10
+ (class_name) @_fn_name) @function
11
+
12
+ (rule_set
13
+ (selectors) @_cls_name) @class
14
+
15
+ (media_statement) @class
16
+
17
+ (charset_statement) @config_key
18
+
19
+ (keyframes_statement
20
+ (keyframes_name) @_cls_name) @class
21
+
22
+ (import_statement
23
+ (string_value) @_import_module) @import
@@ -0,0 +1,43 @@
1
+ """Less language plugin.
2
+
3
+ Extends CSS extraction with the Less preprocessor constructs,
4
+ via a tree-sitter query. Rule sets and `@media`/`@keyframes`
5
+ blocks are captured as classes; `@charset` as a config key;
6
+ `@`-prefixed declarations as variables; `.mixin()` definitions
7
+ as functions;
8
+ `@import` as imports for cross-file edges. Mixin *calls*
9
+ (`mixin_statement`) are references, not definitions, and are
10
+ skipped.
11
+
12
+ Extracted chunks::
13
+
14
+ @primary: #333; → variable "@primary"
15
+ .rounded(@r) { ... } → function "rounded"
16
+ .btn { ... } → class ".btn"
17
+ @keyframes slide { ... } → class "slide"
18
+ @import "reset"; → import, metadata {module: "reset"}
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
+ less = LanguageRegistration(
32
+ id="less",
33
+ extensions=frozenset({".less"}),
34
+ grammar_module="tree_sitter_less",
35
+ extraction=QueryExtraction(
36
+ query=load_query(__package__, "less"),
37
+ ),
38
+ import_targets=frozenset({"css", "scss", "less"}),
39
+ extraction_serial=3,
40
+ )
41
+
42
+ less.scope_extractor(css_nesting_scope)
43
+ less.import_extractor(build_quoted_import)
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ [
2
+ "less.less::@import \"base\"; -> base.less::@bg [imports]"
3
+ ]
@@ -0,0 +1,218 @@
1
+ [
2
+ {
3
+ "id": "e03b0b6a01be78d0",
4
+ "blob_sha": "sha1",
5
+ "file_path": "base.less",
6
+ "kind": "comment",
7
+ "name": "<anonymous>",
8
+ "scope": "",
9
+ "language": "less",
10
+ "content": "// Imported by less.less via `@import \"base\"`.",
11
+ "line_start": 1,
12
+ "line_end": 1,
13
+ "metadata": {
14
+ "module": "",
15
+ "names": "",
16
+ "dots": "",
17
+ "language_hint": ""
18
+ }
19
+ },
20
+ {
21
+ "id": "8f10aa0b97fda5ea",
22
+ "blob_sha": "sha1",
23
+ "file_path": "base.less",
24
+ "kind": "variable",
25
+ "name": "@bg",
26
+ "scope": "",
27
+ "language": "less",
28
+ "content": "@bg: #ffffff;",
29
+ "line_start": 3,
30
+ "line_end": 3,
31
+ "metadata": {
32
+ "module": "",
33
+ "names": "",
34
+ "dots": "",
35
+ "language_hint": ""
36
+ }
37
+ },
38
+ {
39
+ "id": "214b26100f73bc2c",
40
+ "blob_sha": "sha1",
41
+ "file_path": "less.less",
42
+ "kind": "comment",
43
+ "name": "<anonymous>",
44
+ "scope": "",
45
+ "language": "less",
46
+ "content": "// Greeter theme (Less).\n//\n// The Less plugin extracts @-variables, .mixin() definitions, rule sets\n// and @media/@charset/@keyframes as doc sections, and @import as imports.\n// Mixin calls (e.g. `.rounded(8px)`) are references, not definitions.",
47
+ "line_start": 1,
48
+ "line_end": 5,
49
+ "metadata": {
50
+ "module": "",
51
+ "names": "",
52
+ "dots": "",
53
+ "language_hint": ""
54
+ }
55
+ },
56
+ {
57
+ "id": "14b448311d1139b8",
58
+ "blob_sha": "sha1",
59
+ "file_path": "less.less",
60
+ "kind": "import",
61
+ "name": "@import \"base\";",
62
+ "scope": "",
63
+ "language": "less",
64
+ "content": "@import \"base\";",
65
+ "line_start": 7,
66
+ "line_end": 7,
67
+ "metadata": {
68
+ "module": "base",
69
+ "names": "",
70
+ "dots": "",
71
+ "language_hint": ""
72
+ }
73
+ },
74
+ {
75
+ "id": "8d9441ee2a311c25",
76
+ "blob_sha": "sha1",
77
+ "file_path": "less.less",
78
+ "kind": "variable",
79
+ "name": "@primary",
80
+ "scope": "",
81
+ "language": "less",
82
+ "content": "@primary: #333;",
83
+ "line_start": 9,
84
+ "line_end": 9,
85
+ "metadata": {
86
+ "module": "",
87
+ "names": "",
88
+ "dots": "",
89
+ "language_hint": ""
90
+ }
91
+ },
92
+ {
93
+ "id": "7c7b0d1e3f708b87",
94
+ "blob_sha": "sha1",
95
+ "file_path": "less.less",
96
+ "kind": "variable",
97
+ "name": "@spacing",
98
+ "scope": "",
99
+ "language": "less",
100
+ "content": "@spacing: 8px;",
101
+ "line_start": 10,
102
+ "line_end": 10,
103
+ "metadata": {
104
+ "module": "",
105
+ "names": "",
106
+ "dots": "",
107
+ "language_hint": ""
108
+ }
109
+ },
110
+ {
111
+ "id": "70cc768af8829886",
112
+ "blob_sha": "sha1",
113
+ "file_path": "less.less",
114
+ "kind": "function",
115
+ "name": "rounded",
116
+ "scope": "",
117
+ "language": "less",
118
+ "content": ".rounded(@radius: 4px) {\n border-radius: @radius;\n}",
119
+ "line_start": 12,
120
+ "line_end": 14,
121
+ "metadata": {
122
+ "module": "",
123
+ "names": "",
124
+ "dots": "",
125
+ "language_hint": ""
126
+ }
127
+ },
128
+ {
129
+ "id": "787412e930624b62",
130
+ "blob_sha": "sha1",
131
+ "file_path": "less.less",
132
+ "kind": "class",
133
+ "name": ".greeter",
134
+ "scope": "",
135
+ "language": "less",
136
+ "content": ".greeter {\n color: @primary;\n padding: @spacing;\n .rounded(8px);\n .greeting-label {\n text-transform: uppercase;\n }\n}",
137
+ "line_start": 16,
138
+ "line_end": 23,
139
+ "metadata": {
140
+ "module": "",
141
+ "names": "",
142
+ "dots": "",
143
+ "language_hint": ""
144
+ }
145
+ },
146
+ {
147
+ "id": "a21acf50441166ff",
148
+ "blob_sha": "sha1",
149
+ "file_path": "less.less",
150
+ "kind": "class",
151
+ "name": ".greeting-label",
152
+ "scope": ".greeter",
153
+ "language": "less",
154
+ "content": ".greeting-label {\n text-transform: uppercase;\n }",
155
+ "line_start": 20,
156
+ "line_end": 22,
157
+ "metadata": {
158
+ "module": "",
159
+ "names": "",
160
+ "dots": "",
161
+ "language_hint": ""
162
+ }
163
+ },
164
+ {
165
+ "id": "289a7c82bd01f03c",
166
+ "blob_sha": "sha1",
167
+ "file_path": "less.less",
168
+ "kind": "class",
169
+ "name": "<anonymous>",
170
+ "scope": "",
171
+ "language": "less",
172
+ "content": "@media (max-width: 600px) {\n .greeter {\n font-size: 14px;\n }\n}",
173
+ "line_start": 25,
174
+ "line_end": 29,
175
+ "metadata": {
176
+ "module": "",
177
+ "names": "",
178
+ "dots": "",
179
+ "language_hint": ""
180
+ }
181
+ },
182
+ {
183
+ "id": "a4d6c82c63beab1c",
184
+ "blob_sha": "sha1",
185
+ "file_path": "less.less",
186
+ "kind": "class",
187
+ "name": ".greeter",
188
+ "scope": "",
189
+ "language": "less",
190
+ "content": ".greeter {\n font-size: 14px;\n }",
191
+ "line_start": 26,
192
+ "line_end": 28,
193
+ "metadata": {
194
+ "module": "",
195
+ "names": "",
196
+ "dots": "",
197
+ "language_hint": ""
198
+ }
199
+ },
200
+ {
201
+ "id": "4d89902ee8dcd396",
202
+ "blob_sha": "sha1",
203
+ "file_path": "less.less",
204
+ "kind": "class",
205
+ "name": "greeting-fade",
206
+ "scope": "",
207
+ "language": "less",
208
+ "content": "@keyframes greeting-fade {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}",
209
+ "line_start": 31,
210
+ "line_end": 38,
211
+ "metadata": {
212
+ "module": "",
213
+ "names": "",
214
+ "dots": "",
215
+ "language_hint": ""
216
+ }
217
+ }
218
+ ]
@@ -0,0 +1,3 @@
1
+ // Imported by less.less via `@import "base"`.
2
+
3
+ @bg: #ffffff;
@@ -0,0 +1,38 @@
1
+ // Greeter theme (Less).
2
+ //
3
+ // The Less plugin extracts @-variables, .mixin() definitions, rule sets
4
+ // and @media/@charset/@keyframes as doc sections, and @import as imports.
5
+ // Mixin calls (e.g. `.rounded(8px)`) are references, not definitions.
6
+
7
+ @import "base";
8
+
9
+ @primary: #333;
10
+ @spacing: 8px;
11
+
12
+ .rounded(@radius: 4px) {
13
+ border-radius: @radius;
14
+ }
15
+
16
+ .greeter {
17
+ color: @primary;
18
+ padding: @spacing;
19
+ .rounded(8px);
20
+ .greeting-label {
21
+ text-transform: uppercase;
22
+ }
23
+ }
24
+
25
+ @media (max-width: 600px) {
26
+ .greeter {
27
+ font-size: 14px;
28
+ }
29
+ }
30
+
31
+ @keyframes greeting-fade {
32
+ from {
33
+ opacity: 0;
34
+ }
35
+ to {
36
+ opacity: 1;
37
+ }
38
+ }
@@ -0,0 +1,82 @@
1
+ """Less sample extraction: the `samples/less/` project through the real pipeline.
2
+
3
+ The snapshots are the golden record of what Less 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.git import FileEntry
16
+ from rbtr.index.models import Chunk, ChunkKind, Edge
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/less/` project."""
29
+ root = Path(__file__).parent / "samples" / "less"
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 "less"
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 Less's class, variable, function, and import chunks."""
56
+ kinds = {c.kind for c in chunks}
57
+ assert {
58
+ ChunkKind.CLASS,
59
+ ChunkKind.VARIABLE,
60
+ ChunkKind.FUNCTION,
61
+ ChunkKind.IMPORT,
62
+ ChunkKind.COMMENT,
63
+ } <= kinds
64
+
65
+
66
+ def test_parses_cleanly(project: list[tuple[str, str]]) -> None:
67
+ """Every project file is valid source — no tree-sitter ERROR/MISSING nodes."""
68
+ manager = get_manager()
69
+ for path, text in project:
70
+ grammar = manager.grammar(manager.detect_language(path) or "less")
71
+ assert grammar is not None
72
+ assert not Parser(grammar).parse(text.encode()).root_node.has_error, path
73
+
74
+
75
+ def test_extraction_matches_snapshot(chunks: list[Chunk], snapshot_json: SnapshotAssertion) -> None:
76
+ assert chunks == snapshot_json
77
+
78
+
79
+ def test_edges_match_snapshot(
80
+ chunks: list[Chunk], edges: list[Edge], snapshot_json: SnapshotAssertion
81
+ ) -> None:
82
+ assert render_edges(edges, chunks) == snapshot_json
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: rbtr-lang-less
3
+ Version: 2026.7.0.dev0
4
+ Summary: rbtr — Less language plugin
5
+ License-Expression: MIT
6
+ Requires-Dist: rbtr==2026.7.0.dev0
7
+ Requires-Dist: rbtr-lang-css==2026.7.0.dev0
8
+ Requires-Dist: tree-sitter-less
9
+ Requires-Python: >=3.13
@@ -0,0 +1,14 @@
1
+ rbtr_lang_less/__init__.py,sha256=E42CXBcXhyXDXketMTwv9XjpQDnhF0A2Gzi4lEYNtOU,36
2
+ rbtr_lang_less/less.scm,sha256=2jrlfjlTSTietKO8B1gLOrIYrYYm_sUxK_MY3PN2pdM,461
3
+ rbtr_lang_less/plugin.py,sha256=vGhVTUs-9oTMYfaMKIFF9a1Kik2jHtJERLI7XMg3zhk,1317
4
+ rbtr_lang_less/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ rbtr_lang_less/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ rbtr_lang_less/tests/__snapshots__/test_samples/test_edges_match_snapshot.json,sha256=I8OT2FZ17c6YO_bW4dzC24YlLqv6wVCLAErptVE8Iho,65
7
+ rbtr_lang_less/tests/__snapshots__/test_samples/test_extraction_matches_snapshot.json,sha256=bpzNyCSvRoH-6hZJtL238z6JuXIk7iaupsJE4k-VQeg,5005
8
+ rbtr_lang_less/tests/samples/less/base.less,sha256=2h-NAkIQrv7wAe87uMImcEQP4DF8UzRM22UZIwjrvOc,62
9
+ rbtr_lang_less/tests/samples/less/less.less,sha256=4chFgMXhUioo903qkgjQBfDnZqMQGNhwIZw_k162AvE,631
10
+ rbtr_lang_less/tests/test_samples.py,sha256=8auXPA50APYzijx-1Iyy1H74tutea53O2J79QbFGeMg,2776
11
+ rbtr_lang_less-2026.7.0.dev0.dist-info/WHEEL,sha256=CoDSoyhtC_eO_tlxRYzsTraPv1fPJRXFx91k6ISeAvA,81
12
+ rbtr_lang_less-2026.7.0.dev0.dist-info/entry_points.txt,sha256=-Hm26DERb7xxNRI39RA4YGso21CZEVpvBFinToa-RxE,52
13
+ rbtr_lang_less-2026.7.0.dev0.dist-info/METADATA,sha256=iRMvpHyi_3Eyq0utSdquW7FFw4mTtKASoCASeavgk3w,264
14
+ rbtr_lang_less-2026.7.0.dev0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.11.28
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [rbtr.languages]
2
+ less = rbtr_lang_less.plugin:less
3
+