rbtr-lang-less 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.
- rbtr_lang_less-2026.9.0.dev1/LICENSE +21 -0
- rbtr_lang_less-2026.9.0.dev1/PKG-INFO +68 -0
- rbtr_lang_less-2026.9.0.dev1/README.md +41 -0
- rbtr_lang_less-2026.9.0.dev1/pyproject.toml +61 -0
- rbtr_lang_less-2026.9.0.dev1/pyproject.toml.orig +64 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/__init__.py +1 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/less.scm +23 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/plugin.py +43 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/py.typed +0 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/tests/__init__.py +0 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/tests/__snapshots__/test_samples/test_edges_match_snapshot.json +5 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/tests/__snapshots__/test_samples/test_extraction_matches_snapshot.json +325 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/tests/samples/less/base.less +3 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/tests/samples/less/less.less +40 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/tests/samples/less/partials/dark.less +7 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/tests/samples/less/partials/tokens.less +2 -0
- rbtr_lang_less-2026.9.0.dev1/src/rbtr_lang_less/tests/test_samples.py +82 -0
|
@@ -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,68 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rbtr-lang-less
|
|
3
|
+
Version: 2026.9.0.dev1
|
|
4
|
+
Summary: rbtr — Less language plugin
|
|
5
|
+
Keywords: code-search,code-index,tree-sitter,static-analysis,semantic-search,developer-tools,less
|
|
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-less
|
|
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-less#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-less
|
|
29
|
+
|
|
30
|
+
Less support for [rbtr]. Optional plugin — install with
|
|
31
|
+
`pip install rbtr[less]`.
|
|
32
|
+
|
|
33
|
+
[rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
|
|
34
|
+
|
|
35
|
+
## What it ingests
|
|
36
|
+
|
|
37
|
+
Less extends CSS with the Less preprocessor constructs. Definitions map onto
|
|
38
|
+
rbtr's capture conventions by shape:
|
|
39
|
+
|
|
40
|
+
- **Variables** — `@`-prefixed declarations (`@primary: #333;`).
|
|
41
|
+
- **Routines** — `.mixin()` definitions → functions. Mixin *calls* are
|
|
42
|
+
references, not definitions, and are skipped.
|
|
43
|
+
- **Rule sets & at-rule blocks** — selectors, `@media`, `@keyframes` → classes
|
|
44
|
+
(a named collection of declarations).
|
|
45
|
+
- **Directives** — `@charset` → config key.
|
|
46
|
+
- **Imports** — `@import` → imports (for cross-file 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
|
+
```less
|
|
54
|
+
@primary: #333; /* variable "@primary" */
|
|
55
|
+
.rounded(@r) { … } /* function "rounded" */
|
|
56
|
+
.btn { … } /* class ".btn" */
|
|
57
|
+
@keyframes slide { … } /* class "slide" */
|
|
58
|
+
@import "reset"; /* import, metadata {module: "reset"} */
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Embedded / injected chunks
|
|
62
|
+
|
|
63
|
+
None. Less does not embed other languages.
|
|
64
|
+
|
|
65
|
+
## Grammar & dependencies
|
|
66
|
+
|
|
67
|
+
Uses the `tree-sitter-less` grammar. Depends on **rbtr-lang-css** — it reuses
|
|
68
|
+
that plugin's public `css_nesting_scope` helper for CSS-family rule nesting.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# rbtr-lang-less
|
|
2
|
+
|
|
3
|
+
Less support for [rbtr]. Optional plugin — install with
|
|
4
|
+
`pip install rbtr[less]`.
|
|
5
|
+
|
|
6
|
+
[rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
|
|
7
|
+
|
|
8
|
+
## What it ingests
|
|
9
|
+
|
|
10
|
+
Less extends CSS with the Less preprocessor constructs. Definitions map onto
|
|
11
|
+
rbtr's capture conventions by shape:
|
|
12
|
+
|
|
13
|
+
- **Variables** — `@`-prefixed declarations (`@primary: #333;`).
|
|
14
|
+
- **Routines** — `.mixin()` definitions → functions. Mixin *calls* are
|
|
15
|
+
references, not definitions, and are skipped.
|
|
16
|
+
- **Rule sets & at-rule blocks** — selectors, `@media`, `@keyframes` → classes
|
|
17
|
+
(a named collection of declarations).
|
|
18
|
+
- **Directives** — `@charset` → config key.
|
|
19
|
+
- **Imports** — `@import` → imports (for cross-file 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
|
+
```less
|
|
27
|
+
@primary: #333; /* variable "@primary" */
|
|
28
|
+
.rounded(@r) { … } /* function "rounded" */
|
|
29
|
+
.btn { … } /* class ".btn" */
|
|
30
|
+
@keyframes slide { … } /* class "slide" */
|
|
31
|
+
@import "reset"; /* import, metadata {module: "reset"} */
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Embedded / injected chunks
|
|
35
|
+
|
|
36
|
+
None. Less does not embed other languages.
|
|
37
|
+
|
|
38
|
+
## Grammar & dependencies
|
|
39
|
+
|
|
40
|
+
Uses the `tree-sitter-less` grammar. Depends on **rbtr-lang-css** — it reuses
|
|
41
|
+
that plugin's public `css_nesting_scope` helper for CSS-family rule nesting.
|
|
@@ -0,0 +1,61 @@
|
|
|
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_less"
|
|
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-less"
|
|
16
|
+
version = "2026.9.0-dev1"
|
|
17
|
+
description = "rbtr — Less 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
|
+
"less",
|
|
29
|
+
]
|
|
30
|
+
classifiers = [
|
|
31
|
+
"Development Status :: 4 - Beta",
|
|
32
|
+
"Intended Audience :: Developers",
|
|
33
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
34
|
+
"Programming Language :: Python :: 3.13",
|
|
35
|
+
"Topic :: Software Development :: Libraries",
|
|
36
|
+
"Topic :: Text Processing :: Indexing",
|
|
37
|
+
"Typing :: Typed",
|
|
38
|
+
]
|
|
39
|
+
requires-python = ">=3.13"
|
|
40
|
+
dependencies = [
|
|
41
|
+
"rbtr==2026.9.0-dev1",
|
|
42
|
+
"rbtr-lang-css==2026.9.0-dev1",
|
|
43
|
+
"tree-sitter-less",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[[project.authors]]
|
|
47
|
+
name = "Alejandro Giacometti"
|
|
48
|
+
email = "alejandro.giacometti@gmail.com"
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/janrito/rbtr"
|
|
52
|
+
Repository = "https://github.com/janrito/rbtr"
|
|
53
|
+
Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-less#readme"
|
|
54
|
+
Issues = "https://github.com/janrito/rbtr/issues"
|
|
55
|
+
Changelog = "https://github.com/janrito/rbtr/releases"
|
|
56
|
+
|
|
57
|
+
[project.entry-points."rbtr.languages"]
|
|
58
|
+
less = "rbtr_lang_less.plugin:less"
|
|
59
|
+
|
|
60
|
+
[dependency-groups]
|
|
61
|
+
dev = ["rbtr[test]"]
|
|
@@ -0,0 +1,64 @@
|
|
|
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_less"
|
|
7
|
+
# No source-exclude: the plugin's tests, samples, and snapshots ship
|
|
8
|
+
# with the wheel (they are the language's golden record), and less.scm
|
|
9
|
+
# ships as package data.
|
|
10
|
+
|
|
11
|
+
[project]
|
|
12
|
+
name = "rbtr-lang-less"
|
|
13
|
+
version = "2026.9.0-dev1"
|
|
14
|
+
description = "rbtr — Less 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
|
+
"less",
|
|
29
|
+
]
|
|
30
|
+
classifiers = [
|
|
31
|
+
"Development Status :: 4 - Beta",
|
|
32
|
+
"Intended Audience :: Developers",
|
|
33
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
34
|
+
"Programming Language :: Python :: 3.13",
|
|
35
|
+
"Topic :: Software Development :: Libraries",
|
|
36
|
+
"Topic :: Text Processing :: Indexing",
|
|
37
|
+
"Typing :: Typed",
|
|
38
|
+
]
|
|
39
|
+
requires-python = ">=3.13"
|
|
40
|
+
dependencies = [
|
|
41
|
+
"rbtr==2026.9.0-dev1",
|
|
42
|
+
# Reuses css_nesting_scope from the css plugin (CSS-family nesting).
|
|
43
|
+
"rbtr-lang-css==2026.9.0-dev1",
|
|
44
|
+
"tree-sitter-less",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.urls]
|
|
48
|
+
Homepage = "https://github.com/janrito/rbtr"
|
|
49
|
+
Repository = "https://github.com/janrito/rbtr"
|
|
50
|
+
Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-less#readme"
|
|
51
|
+
Issues = "https://github.com/janrito/rbtr/issues"
|
|
52
|
+
Changelog = "https://github.com/janrito/rbtr/releases"
|
|
53
|
+
|
|
54
|
+
[project.entry-points."rbtr.languages"]
|
|
55
|
+
# The value resolves to the language's `LanguageRegistration` (named by its
|
|
56
|
+
# id) — see the rbtr ARCHITECTURE "External plugins" note.
|
|
57
|
+
less = "rbtr_lang_less.plugin:less"
|
|
58
|
+
|
|
59
|
+
[tool.uv.sources]
|
|
60
|
+
rbtr = { workspace = true }
|
|
61
|
+
rbtr-lang-css = { workspace = true }
|
|
62
|
+
|
|
63
|
+
[dependency-groups]
|
|
64
|
+
dev = ["rbtr[test]"]
|
|
@@ -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,325 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"blob_sha": "sha1",
|
|
4
|
+
"file_path": "base.less",
|
|
5
|
+
"kind": "comment",
|
|
6
|
+
"name": "",
|
|
7
|
+
"scope": "",
|
|
8
|
+
"language": "less",
|
|
9
|
+
"file_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
|
+
"id": "71698a6c624fc960"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"blob_sha": "sha1",
|
|
23
|
+
"file_path": "base.less",
|
|
24
|
+
"kind": "variable",
|
|
25
|
+
"name": "@bg",
|
|
26
|
+
"scope": "",
|
|
27
|
+
"language": "less",
|
|
28
|
+
"file_language": "less",
|
|
29
|
+
"content": "@bg: #ffffff;",
|
|
30
|
+
"line_start": 3,
|
|
31
|
+
"line_end": 3,
|
|
32
|
+
"metadata": {
|
|
33
|
+
"module": "",
|
|
34
|
+
"names": "",
|
|
35
|
+
"dots": "",
|
|
36
|
+
"language_hint": ""
|
|
37
|
+
},
|
|
38
|
+
"id": "837abe811d55f219"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"blob_sha": "sha1",
|
|
42
|
+
"file_path": "less.less",
|
|
43
|
+
"kind": "comment",
|
|
44
|
+
"name": "",
|
|
45
|
+
"scope": "",
|
|
46
|
+
"language": "less",
|
|
47
|
+
"file_language": "less",
|
|
48
|
+
"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.",
|
|
49
|
+
"line_start": 1,
|
|
50
|
+
"line_end": 5,
|
|
51
|
+
"metadata": {
|
|
52
|
+
"module": "",
|
|
53
|
+
"names": "",
|
|
54
|
+
"dots": "",
|
|
55
|
+
"language_hint": ""
|
|
56
|
+
},
|
|
57
|
+
"id": "8209659e6455d986"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"blob_sha": "sha1",
|
|
61
|
+
"file_path": "less.less",
|
|
62
|
+
"kind": "import",
|
|
63
|
+
"name": "@import \"base\";",
|
|
64
|
+
"scope": "",
|
|
65
|
+
"language": "less",
|
|
66
|
+
"file_language": "less",
|
|
67
|
+
"content": "@import \"base\";",
|
|
68
|
+
"line_start": 7,
|
|
69
|
+
"line_end": 7,
|
|
70
|
+
"metadata": {
|
|
71
|
+
"module": "base",
|
|
72
|
+
"names": "",
|
|
73
|
+
"dots": "",
|
|
74
|
+
"language_hint": ""
|
|
75
|
+
},
|
|
76
|
+
"id": "f048740420fb950f"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"blob_sha": "sha1",
|
|
80
|
+
"file_path": "less.less",
|
|
81
|
+
"kind": "variable",
|
|
82
|
+
"name": "@primary",
|
|
83
|
+
"scope": "",
|
|
84
|
+
"language": "less",
|
|
85
|
+
"file_language": "less",
|
|
86
|
+
"content": "@primary: #333;",
|
|
87
|
+
"line_start": 9,
|
|
88
|
+
"line_end": 9,
|
|
89
|
+
"metadata": {
|
|
90
|
+
"module": "",
|
|
91
|
+
"names": "",
|
|
92
|
+
"dots": "",
|
|
93
|
+
"language_hint": ""
|
|
94
|
+
},
|
|
95
|
+
"id": "90cc2ea8356e9258"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"blob_sha": "sha1",
|
|
99
|
+
"file_path": "less.less",
|
|
100
|
+
"kind": "variable",
|
|
101
|
+
"name": "@spacing",
|
|
102
|
+
"scope": "",
|
|
103
|
+
"language": "less",
|
|
104
|
+
"file_language": "less",
|
|
105
|
+
"content": "@spacing: 8px;",
|
|
106
|
+
"line_start": 10,
|
|
107
|
+
"line_end": 10,
|
|
108
|
+
"metadata": {
|
|
109
|
+
"module": "",
|
|
110
|
+
"names": "",
|
|
111
|
+
"dots": "",
|
|
112
|
+
"language_hint": ""
|
|
113
|
+
},
|
|
114
|
+
"id": "dfa4fcd6bb9ca8dc"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"blob_sha": "sha1",
|
|
118
|
+
"file_path": "less.less",
|
|
119
|
+
"kind": "function",
|
|
120
|
+
"name": "rounded",
|
|
121
|
+
"scope": "",
|
|
122
|
+
"language": "less",
|
|
123
|
+
"file_language": "less",
|
|
124
|
+
"content": ".rounded(@radius: 4px) {\n border-radius: @radius;\n}",
|
|
125
|
+
"line_start": 12,
|
|
126
|
+
"line_end": 14,
|
|
127
|
+
"metadata": {
|
|
128
|
+
"module": "",
|
|
129
|
+
"names": "",
|
|
130
|
+
"dots": "",
|
|
131
|
+
"language_hint": ""
|
|
132
|
+
},
|
|
133
|
+
"id": "f966c2712450d388"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"blob_sha": "sha1",
|
|
137
|
+
"file_path": "less.less",
|
|
138
|
+
"kind": "class",
|
|
139
|
+
"name": ".greeter",
|
|
140
|
+
"scope": "",
|
|
141
|
+
"language": "less",
|
|
142
|
+
"file_language": "less",
|
|
143
|
+
"content": ".greeter {\n color: @primary;\n padding: @spacing;\n .rounded(8px);\n .greeting-label {\n text-transform: uppercase;\n }\n}",
|
|
144
|
+
"line_start": 16,
|
|
145
|
+
"line_end": 23,
|
|
146
|
+
"metadata": {
|
|
147
|
+
"module": "",
|
|
148
|
+
"names": "",
|
|
149
|
+
"dots": "",
|
|
150
|
+
"language_hint": ""
|
|
151
|
+
},
|
|
152
|
+
"id": "3c04530906d60e4d"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"blob_sha": "sha1",
|
|
156
|
+
"file_path": "less.less",
|
|
157
|
+
"kind": "class",
|
|
158
|
+
"name": ".greeting-label",
|
|
159
|
+
"scope": ".greeter",
|
|
160
|
+
"language": "less",
|
|
161
|
+
"file_language": "less",
|
|
162
|
+
"content": ".greeting-label {\n text-transform: uppercase;\n }",
|
|
163
|
+
"line_start": 20,
|
|
164
|
+
"line_end": 22,
|
|
165
|
+
"metadata": {
|
|
166
|
+
"module": "",
|
|
167
|
+
"names": "",
|
|
168
|
+
"dots": "",
|
|
169
|
+
"language_hint": ""
|
|
170
|
+
},
|
|
171
|
+
"id": "852720c757a85ba8"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"blob_sha": "sha1",
|
|
175
|
+
"file_path": "less.less",
|
|
176
|
+
"kind": "class",
|
|
177
|
+
"name": "",
|
|
178
|
+
"scope": "",
|
|
179
|
+
"language": "less",
|
|
180
|
+
"file_language": "less",
|
|
181
|
+
"content": "@media (max-width: 600px) {\n .greeter {\n font-size: 14px;\n }\n}",
|
|
182
|
+
"line_start": 25,
|
|
183
|
+
"line_end": 29,
|
|
184
|
+
"metadata": {
|
|
185
|
+
"module": "",
|
|
186
|
+
"names": "",
|
|
187
|
+
"dots": "",
|
|
188
|
+
"language_hint": ""
|
|
189
|
+
},
|
|
190
|
+
"id": "e0f22662ab1ffe7b"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"blob_sha": "sha1",
|
|
194
|
+
"file_path": "less.less",
|
|
195
|
+
"kind": "class",
|
|
196
|
+
"name": ".greeter",
|
|
197
|
+
"scope": "",
|
|
198
|
+
"language": "less",
|
|
199
|
+
"file_language": "less",
|
|
200
|
+
"content": ".greeter {\n font-size: 14px;\n }",
|
|
201
|
+
"line_start": 26,
|
|
202
|
+
"line_end": 28,
|
|
203
|
+
"metadata": {
|
|
204
|
+
"module": "",
|
|
205
|
+
"names": "",
|
|
206
|
+
"dots": "",
|
|
207
|
+
"language_hint": ""
|
|
208
|
+
},
|
|
209
|
+
"id": "a81bc1863fd8b29c"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"blob_sha": "sha1",
|
|
213
|
+
"file_path": "less.less",
|
|
214
|
+
"kind": "class",
|
|
215
|
+
"name": "greeting-fade",
|
|
216
|
+
"scope": "",
|
|
217
|
+
"language": "less",
|
|
218
|
+
"file_language": "less",
|
|
219
|
+
"content": "@keyframes greeting-fade {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}",
|
|
220
|
+
"line_start": 31,
|
|
221
|
+
"line_end": 38,
|
|
222
|
+
"metadata": {
|
|
223
|
+
"module": "",
|
|
224
|
+
"names": "",
|
|
225
|
+
"dots": "",
|
|
226
|
+
"language_hint": ""
|
|
227
|
+
},
|
|
228
|
+
"id": "a20a92b7069da8d3"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"blob_sha": "sha1",
|
|
232
|
+
"file_path": "less.less",
|
|
233
|
+
"kind": "import",
|
|
234
|
+
"name": "@import \"partials/dark.less\";",
|
|
235
|
+
"scope": "",
|
|
236
|
+
"language": "less",
|
|
237
|
+
"file_language": "less",
|
|
238
|
+
"content": "@import \"partials/dark.less\";",
|
|
239
|
+
"line_start": 40,
|
|
240
|
+
"line_end": 40,
|
|
241
|
+
"metadata": {
|
|
242
|
+
"module": "partials/dark.less",
|
|
243
|
+
"names": "",
|
|
244
|
+
"dots": "",
|
|
245
|
+
"language_hint": ""
|
|
246
|
+
},
|
|
247
|
+
"id": "1a7586aaf6a8d9af"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"blob_sha": "sha1",
|
|
251
|
+
"file_path": "partials/dark.less",
|
|
252
|
+
"kind": "comment",
|
|
253
|
+
"name": "",
|
|
254
|
+
"scope": "",
|
|
255
|
+
"language": "less",
|
|
256
|
+
"file_language": "less",
|
|
257
|
+
"content": "// Imported by less.less. Imports its own sibling by bare name, which only\n// resolves relative to this directory.",
|
|
258
|
+
"line_start": 1,
|
|
259
|
+
"line_end": 2,
|
|
260
|
+
"metadata": {
|
|
261
|
+
"module": "",
|
|
262
|
+
"names": "",
|
|
263
|
+
"dots": "",
|
|
264
|
+
"language_hint": ""
|
|
265
|
+
},
|
|
266
|
+
"id": "e0a8aefe746d1fe6"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"blob_sha": "sha1",
|
|
270
|
+
"file_path": "partials/dark.less",
|
|
271
|
+
"kind": "import",
|
|
272
|
+
"name": "@import \"tokens.less\";",
|
|
273
|
+
"scope": "",
|
|
274
|
+
"language": "less",
|
|
275
|
+
"file_language": "less",
|
|
276
|
+
"content": "@import \"tokens.less\";",
|
|
277
|
+
"line_start": 3,
|
|
278
|
+
"line_end": 3,
|
|
279
|
+
"metadata": {
|
|
280
|
+
"module": "tokens.less",
|
|
281
|
+
"names": "",
|
|
282
|
+
"dots": "",
|
|
283
|
+
"language_hint": ""
|
|
284
|
+
},
|
|
285
|
+
"id": "b8856ac1553fbc10"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"blob_sha": "sha1",
|
|
289
|
+
"file_path": "partials/dark.less",
|
|
290
|
+
"kind": "class",
|
|
291
|
+
"name": ".greeting--dark",
|
|
292
|
+
"scope": "",
|
|
293
|
+
"language": "less",
|
|
294
|
+
"file_language": "less",
|
|
295
|
+
"content": ".greeting--dark {\n color: @ink;\n}",
|
|
296
|
+
"line_start": 5,
|
|
297
|
+
"line_end": 7,
|
|
298
|
+
"metadata": {
|
|
299
|
+
"module": "",
|
|
300
|
+
"names": "",
|
|
301
|
+
"dots": "",
|
|
302
|
+
"language_hint": ""
|
|
303
|
+
},
|
|
304
|
+
"id": "97351d499b111481"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"blob_sha": "sha1",
|
|
308
|
+
"file_path": "partials/tokens.less",
|
|
309
|
+
"kind": "variable",
|
|
310
|
+
"name": "@ink",
|
|
311
|
+
"scope": "",
|
|
312
|
+
"language": "less",
|
|
313
|
+
"file_language": "less",
|
|
314
|
+
"content": "// Imported by partials/dark.less as a bare sibling.\n@ink: #eeeeee;",
|
|
315
|
+
"line_start": 1,
|
|
316
|
+
"line_end": 2,
|
|
317
|
+
"metadata": {
|
|
318
|
+
"module": "",
|
|
319
|
+
"names": "",
|
|
320
|
+
"dots": "",
|
|
321
|
+
"language_hint": ""
|
|
322
|
+
},
|
|
323
|
+
"id": "42c36ec05d16f246"
|
|
324
|
+
}
|
|
325
|
+
]
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
}
|
|
39
|
+
|
|
40
|
+
@import "partials/dark.less";
|
|
@@ -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.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/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
|