rbtr-lang-vue 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_vue-2026.9.0.dev1/LICENSE +21 -0
- rbtr_lang_vue-2026.9.0.dev1/PKG-INFO +70 -0
- rbtr_lang_vue-2026.9.0.dev1/README.md +43 -0
- rbtr_lang_vue-2026.9.0.dev1/pyproject.toml +71 -0
- rbtr_lang_vue-2026.9.0.dev1/pyproject.toml.orig +65 -0
- rbtr_lang_vue-2026.9.0.dev1/src/rbtr_lang_vue/__init__.py +0 -0
- rbtr_lang_vue-2026.9.0.dev1/src/rbtr_lang_vue/plugin.py +38 -0
- rbtr_lang_vue-2026.9.0.dev1/src/rbtr_lang_vue/py.typed +0 -0
- rbtr_lang_vue-2026.9.0.dev1/src/rbtr_lang_vue/tests/__init__.py +0 -0
- rbtr_lang_vue-2026.9.0.dev1/src/rbtr_lang_vue/tests/__snapshots__/test_samples/test_edges_match_snapshot.json +3 -0
- rbtr_lang_vue-2026.9.0.dev1/src/rbtr_lang_vue/tests/__snapshots__/test_samples/test_extraction_matches_snapshot.json +192 -0
- rbtr_lang_vue-2026.9.0.dev1/src/rbtr_lang_vue/tests/samples/vue/Counter.vue +35 -0
- rbtr_lang_vue-2026.9.0.dev1/src/rbtr_lang_vue/tests/samples/vue/store.ts +5 -0
- rbtr_lang_vue-2026.9.0.dev1/src/rbtr_lang_vue/tests/test_samples.py +86 -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,70 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rbtr-lang-vue
|
|
3
|
+
Version: 2026.9.0.dev1
|
|
4
|
+
Summary: rbtr — Vue language plugin (thin; reuses rbtr-lang-svelte's SFC machinery)
|
|
5
|
+
Keywords: code-search,code-index,tree-sitter,static-analysis,semantic-search,developer-tools,vue
|
|
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-svelte==2026.9.0.dev1
|
|
19
|
+
Requires-Dist: tree-sitter-language-pack
|
|
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-vue#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-vue
|
|
29
|
+
|
|
30
|
+
Vue support for [rbtr]. Optional plugin — install with
|
|
31
|
+
`pip install rbtr[vue]`.
|
|
32
|
+
|
|
33
|
+
[rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
|
|
34
|
+
[rbtr-lang-svelte]: https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-svelte#readme
|
|
35
|
+
|
|
36
|
+
## What it ingests
|
|
37
|
+
|
|
38
|
+
`.vue` single-file components. Vue has the same `<script>`/`<style>`/template
|
|
39
|
+
shape as Svelte, so this package reuses the SFC chunker and injection query
|
|
40
|
+
from [rbtr-lang-svelte]: the markup template becomes one
|
|
41
|
+
host **doc-section** chunk, a comment above that markup is its own chunk, and
|
|
42
|
+
the `<script>`/`<style>` blocks are delegated to their embedded language.
|
|
43
|
+
|
|
44
|
+
## Chunks produced
|
|
45
|
+
|
|
46
|
+
```vue
|
|
47
|
+
<script setup lang="ts">
|
|
48
|
+
import { store } from "./store" // → import (typescript)
|
|
49
|
+
const count = ref(0) // → variable "count" (typescript)
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<template>
|
|
53
|
+
<button>{{ count }}</button> <!-- → doc_section "Counter" (vue host) -->
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<style lang="scss">
|
|
57
|
+
.btn { color: red; } // → class ".btn" (scss)
|
|
58
|
+
</style>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Embedded / injected chunks
|
|
62
|
+
|
|
63
|
+
`<script lang="ts">` → TypeScript (bare → JavaScript); `<style lang="scss">` →
|
|
64
|
+
SCSS (`lang="less"` → Less, bare → CSS). These run only when the corresponding
|
|
65
|
+
plugin (`rbtr-lang-javascript`, `rbtr-lang-css`) is installed.
|
|
66
|
+
|
|
67
|
+
## Grammar & dependencies
|
|
68
|
+
|
|
69
|
+
The Vue grammar is bundled in `tree-sitter-language-pack`. Depends on
|
|
70
|
+
`rbtr-lang-svelte` for the shared SFC chunker and injection query.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# rbtr-lang-vue
|
|
2
|
+
|
|
3
|
+
Vue support for [rbtr]. Optional plugin — install with
|
|
4
|
+
`pip install rbtr[vue]`.
|
|
5
|
+
|
|
6
|
+
[rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
|
|
7
|
+
[rbtr-lang-svelte]: https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-svelte#readme
|
|
8
|
+
|
|
9
|
+
## What it ingests
|
|
10
|
+
|
|
11
|
+
`.vue` single-file components. Vue has the same `<script>`/`<style>`/template
|
|
12
|
+
shape as Svelte, so this package reuses the SFC chunker and injection query
|
|
13
|
+
from [rbtr-lang-svelte]: the markup template becomes one
|
|
14
|
+
host **doc-section** chunk, a comment above that markup is its own chunk, and
|
|
15
|
+
the `<script>`/`<style>` blocks are delegated to their embedded language.
|
|
16
|
+
|
|
17
|
+
## Chunks produced
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import { store } from "./store" // → import (typescript)
|
|
22
|
+
const count = ref(0) // → variable "count" (typescript)
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<button>{{ count }}</button> <!-- → doc_section "Counter" (vue host) -->
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<style lang="scss">
|
|
30
|
+
.btn { color: red; } // → class ".btn" (scss)
|
|
31
|
+
</style>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Embedded / injected chunks
|
|
35
|
+
|
|
36
|
+
`<script lang="ts">` → TypeScript (bare → JavaScript); `<style lang="scss">` →
|
|
37
|
+
SCSS (`lang="less"` → Less, bare → CSS). These run only when the corresponding
|
|
38
|
+
plugin (`rbtr-lang-javascript`, `rbtr-lang-css`) is installed.
|
|
39
|
+
|
|
40
|
+
## Grammar & dependencies
|
|
41
|
+
|
|
42
|
+
The Vue grammar is bundled in `tree-sitter-language-pack`. Depends on
|
|
43
|
+
`rbtr-lang-svelte` for the shared SFC chunker and injection query.
|
|
@@ -0,0 +1,71 @@
|
|
|
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_vue"
|
|
7
|
+
|
|
8
|
+
[tool.uv.sources.rbtr]
|
|
9
|
+
workspace = true
|
|
10
|
+
|
|
11
|
+
[tool.uv.sources.rbtr-lang-svelte]
|
|
12
|
+
workspace = true
|
|
13
|
+
|
|
14
|
+
[tool.uv.sources.rbtr-lang-javascript]
|
|
15
|
+
workspace = true
|
|
16
|
+
|
|
17
|
+
[tool.uv.sources.rbtr-lang-scss]
|
|
18
|
+
workspace = true
|
|
19
|
+
|
|
20
|
+
[project]
|
|
21
|
+
name = "rbtr-lang-vue"
|
|
22
|
+
version = "2026.9.0-dev1"
|
|
23
|
+
description = "rbtr — Vue language plugin (thin; reuses rbtr-lang-svelte's SFC machinery)"
|
|
24
|
+
readme = "README.md"
|
|
25
|
+
license = "MIT"
|
|
26
|
+
license-files = ["LICENSE"]
|
|
27
|
+
keywords = [
|
|
28
|
+
"code-search",
|
|
29
|
+
"code-index",
|
|
30
|
+
"tree-sitter",
|
|
31
|
+
"static-analysis",
|
|
32
|
+
"semantic-search",
|
|
33
|
+
"developer-tools",
|
|
34
|
+
"vue",
|
|
35
|
+
]
|
|
36
|
+
classifiers = [
|
|
37
|
+
"Development Status :: 4 - Beta",
|
|
38
|
+
"Intended Audience :: Developers",
|
|
39
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
40
|
+
"Programming Language :: Python :: 3.13",
|
|
41
|
+
"Topic :: Software Development :: Libraries",
|
|
42
|
+
"Topic :: Text Processing :: Indexing",
|
|
43
|
+
"Typing :: Typed",
|
|
44
|
+
]
|
|
45
|
+
requires-python = ">=3.13"
|
|
46
|
+
dependencies = [
|
|
47
|
+
"rbtr==2026.9.0-dev1",
|
|
48
|
+
"rbtr-lang-svelte==2026.9.0-dev1",
|
|
49
|
+
"tree-sitter-language-pack",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[[project.authors]]
|
|
53
|
+
name = "Alejandro Giacometti"
|
|
54
|
+
email = "alejandro.giacometti@gmail.com"
|
|
55
|
+
|
|
56
|
+
[project.urls]
|
|
57
|
+
Homepage = "https://github.com/janrito/rbtr"
|
|
58
|
+
Repository = "https://github.com/janrito/rbtr"
|
|
59
|
+
Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-vue#readme"
|
|
60
|
+
Issues = "https://github.com/janrito/rbtr/issues"
|
|
61
|
+
Changelog = "https://github.com/janrito/rbtr/releases"
|
|
62
|
+
|
|
63
|
+
[project.entry-points."rbtr.languages"]
|
|
64
|
+
vue = "rbtr_lang_vue.plugin:vue"
|
|
65
|
+
|
|
66
|
+
[dependency-groups]
|
|
67
|
+
dev = [
|
|
68
|
+
"rbtr[test]",
|
|
69
|
+
"rbtr-lang-javascript",
|
|
70
|
+
"rbtr-lang-scss",
|
|
71
|
+
]
|
|
@@ -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_vue"
|
|
7
|
+
# No source-exclude: the plugin's tests, samples, and snapshots ship with
|
|
8
|
+
# the wheel (they are the language's golden record).
|
|
9
|
+
|
|
10
|
+
[project]
|
|
11
|
+
name = "rbtr-lang-vue"
|
|
12
|
+
version = "2026.9.0-dev1"
|
|
13
|
+
description = "rbtr — Vue language plugin (thin; reuses rbtr-lang-svelte's SFC machinery)"
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
license = "MIT"
|
|
16
|
+
license-files = ["LICENSE"]
|
|
17
|
+
authors = [
|
|
18
|
+
{ name = "Alejandro Giacometti", email = "alejandro.giacometti@gmail.com" },
|
|
19
|
+
]
|
|
20
|
+
keywords = [
|
|
21
|
+
"code-search",
|
|
22
|
+
"code-index",
|
|
23
|
+
"tree-sitter",
|
|
24
|
+
"static-analysis",
|
|
25
|
+
"semantic-search",
|
|
26
|
+
"developer-tools",
|
|
27
|
+
"vue",
|
|
28
|
+
]
|
|
29
|
+
classifiers = [
|
|
30
|
+
"Development Status :: 4 - Beta",
|
|
31
|
+
"Intended Audience :: Developers",
|
|
32
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
33
|
+
"Programming Language :: Python :: 3.13",
|
|
34
|
+
"Topic :: Software Development :: Libraries",
|
|
35
|
+
"Topic :: Text Processing :: Indexing",
|
|
36
|
+
"Typing :: Typed",
|
|
37
|
+
]
|
|
38
|
+
requires-python = ">=3.13"
|
|
39
|
+
dependencies = [
|
|
40
|
+
"rbtr==2026.9.0-dev1",
|
|
41
|
+
"rbtr-lang-svelte==2026.9.0-dev1",
|
|
42
|
+
"tree-sitter-language-pack", # Vue grammar (bundled, hermetic)
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://github.com/janrito/rbtr"
|
|
47
|
+
Repository = "https://github.com/janrito/rbtr"
|
|
48
|
+
Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-vue#readme"
|
|
49
|
+
Issues = "https://github.com/janrito/rbtr/issues"
|
|
50
|
+
Changelog = "https://github.com/janrito/rbtr/releases"
|
|
51
|
+
|
|
52
|
+
[project.entry-points."rbtr.languages"]
|
|
53
|
+
# The value resolves to the language's `LanguageRegistration` (named by its
|
|
54
|
+
# id) — see the rbtr ARCHITECTURE "External plugins" note.
|
|
55
|
+
vue = "rbtr_lang_vue.plugin:vue"
|
|
56
|
+
|
|
57
|
+
[tool.uv.sources]
|
|
58
|
+
rbtr = { workspace = true }
|
|
59
|
+
rbtr-lang-svelte = { workspace = true }
|
|
60
|
+
rbtr-lang-javascript = { workspace = true }
|
|
61
|
+
rbtr-lang-scss = { workspace = true }
|
|
62
|
+
|
|
63
|
+
[dependency-groups]
|
|
64
|
+
# The sample embeds lang="ts" and lang="scss" blocks (scss pulls css).
|
|
65
|
+
dev = ["rbtr[test]", "rbtr-lang-javascript", "rbtr-lang-scss"]
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Vue language plugin.
|
|
2
|
+
|
|
3
|
+
`.vue` single-file components have the same `<script>`/`<style>`/template
|
|
4
|
+
shape as Svelte, so they reuse the SFC chunker (`chunk_sfc`) and injection
|
|
5
|
+
query from `rbtr-lang-svelte`. Only the grammar differs: Vue's is bundled in
|
|
6
|
+
`tree-sitter-language-pack`, kept out of a plain Svelte install by living
|
|
7
|
+
behind this separate package.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from typing import TYPE_CHECKING
|
|
13
|
+
|
|
14
|
+
from rbtr.languages.registration import LanguageRegistration, load_query
|
|
15
|
+
from rbtr_lang_svelte.plugin import chunk_sfc
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from tree_sitter import Language
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _vue_grammar() -> Language:
|
|
22
|
+
"""Load the Vue grammar from the bundled language pack."""
|
|
23
|
+
import tree_sitter_language_pack # deferred: heavy bundled native grammars
|
|
24
|
+
|
|
25
|
+
return tree_sitter_language_pack.get_language("vue")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Reuses the SFC injection query shipped in rbtr-lang-svelte (cached, so this
|
|
29
|
+
# and svelte's own load read the file once).
|
|
30
|
+
vue = LanguageRegistration(
|
|
31
|
+
id="vue",
|
|
32
|
+
extensions=frozenset({".vue"}),
|
|
33
|
+
grammar_factory=_vue_grammar,
|
|
34
|
+
injection_query=load_query("rbtr_lang_svelte", "injections"),
|
|
35
|
+
extraction_serial=2,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
vue.chunker(chunk_sfc)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"blob_sha": "sha1",
|
|
4
|
+
"file_path": "Counter.vue",
|
|
5
|
+
"kind": "doc_section",
|
|
6
|
+
"name": "Counter",
|
|
7
|
+
"scope": "",
|
|
8
|
+
"language": "vue",
|
|
9
|
+
"file_language": "vue",
|
|
10
|
+
"content": "<template>\n <button class=\"counter\" @click=\"increment\">{{ store.count }}</button>\n</template>",
|
|
11
|
+
"line_start": 33,
|
|
12
|
+
"line_end": 35,
|
|
13
|
+
"metadata": {
|
|
14
|
+
"module": "",
|
|
15
|
+
"names": "",
|
|
16
|
+
"dots": "",
|
|
17
|
+
"language_hint": ""
|
|
18
|
+
},
|
|
19
|
+
"id": "383d4211ee508e85"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"blob_sha": "sha1",
|
|
23
|
+
"file_path": "Counter.vue",
|
|
24
|
+
"kind": "comment",
|
|
25
|
+
"name": "",
|
|
26
|
+
"scope": "",
|
|
27
|
+
"language": "vue",
|
|
28
|
+
"file_language": "vue",
|
|
29
|
+
"content": "<!--\n Vue single-file component.\n\n The SFC plugin delegates <script> to TypeScript and <style> to SCSS.\n This comment is itself a chunk, so a component's own explanation of\n what it is for stays searchable.\n-->",
|
|
30
|
+
"line_start": 1,
|
|
31
|
+
"line_end": 7,
|
|
32
|
+
"metadata": {
|
|
33
|
+
"module": "",
|
|
34
|
+
"names": "",
|
|
35
|
+
"dots": "",
|
|
36
|
+
"language_hint": ""
|
|
37
|
+
},
|
|
38
|
+
"id": "b8108f5642e5ab1d"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"blob_sha": "sha1",
|
|
42
|
+
"file_path": "Counter.vue",
|
|
43
|
+
"kind": "comment",
|
|
44
|
+
"name": "",
|
|
45
|
+
"scope": "",
|
|
46
|
+
"language": "typescript",
|
|
47
|
+
"file_language": "vue",
|
|
48
|
+
"content": "// Vue single-file component.\n//\n// The SFC plugin delegates the <script setup> block to TypeScript and\n// the <style> block to SCSS, reusing the same chunker as Svelte. The\n// template is not extracted.",
|
|
49
|
+
"line_start": 10,
|
|
50
|
+
"line_end": 14,
|
|
51
|
+
"metadata": {
|
|
52
|
+
"module": "",
|
|
53
|
+
"names": "",
|
|
54
|
+
"dots": "",
|
|
55
|
+
"language_hint": ""
|
|
56
|
+
},
|
|
57
|
+
"id": "10a55ab379567fb3"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"blob_sha": "sha1",
|
|
61
|
+
"file_path": "Counter.vue",
|
|
62
|
+
"kind": "import",
|
|
63
|
+
"name": "import { makeStore } from \"./store\";",
|
|
64
|
+
"scope": "",
|
|
65
|
+
"language": "typescript",
|
|
66
|
+
"file_language": "vue",
|
|
67
|
+
"content": "import { makeStore } from \"./store\";",
|
|
68
|
+
"line_start": 15,
|
|
69
|
+
"line_end": 15,
|
|
70
|
+
"metadata": {
|
|
71
|
+
"module": "store",
|
|
72
|
+
"names": "makeStore",
|
|
73
|
+
"dots": "1",
|
|
74
|
+
"language_hint": ""
|
|
75
|
+
},
|
|
76
|
+
"id": "2829a0c60e534b3e"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"blob_sha": "sha1",
|
|
80
|
+
"file_path": "Counter.vue",
|
|
81
|
+
"kind": "variable",
|
|
82
|
+
"name": "store",
|
|
83
|
+
"scope": "",
|
|
84
|
+
"language": "typescript",
|
|
85
|
+
"file_language": "vue",
|
|
86
|
+
"content": "store = makeStore()",
|
|
87
|
+
"line_start": 17,
|
|
88
|
+
"line_end": 17,
|
|
89
|
+
"metadata": {
|
|
90
|
+
"module": "",
|
|
91
|
+
"names": "",
|
|
92
|
+
"dots": "",
|
|
93
|
+
"language_hint": ""
|
|
94
|
+
},
|
|
95
|
+
"id": "4c8308057f92d8a6"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"blob_sha": "sha1",
|
|
99
|
+
"file_path": "Counter.vue",
|
|
100
|
+
"kind": "function",
|
|
101
|
+
"name": "increment",
|
|
102
|
+
"scope": "",
|
|
103
|
+
"language": "typescript",
|
|
104
|
+
"file_language": "vue",
|
|
105
|
+
"content": "function increment(): void {\n store.count += 1;\n}",
|
|
106
|
+
"line_start": 19,
|
|
107
|
+
"line_end": 21,
|
|
108
|
+
"metadata": {
|
|
109
|
+
"module": "",
|
|
110
|
+
"names": "",
|
|
111
|
+
"dots": "",
|
|
112
|
+
"language_hint": ""
|
|
113
|
+
},
|
|
114
|
+
"id": "648d9d1f6c623121"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"blob_sha": "sha1",
|
|
118
|
+
"file_path": "Counter.vue",
|
|
119
|
+
"kind": "variable",
|
|
120
|
+
"name": "$accent",
|
|
121
|
+
"scope": "",
|
|
122
|
+
"language": "scss",
|
|
123
|
+
"file_language": "vue",
|
|
124
|
+
"content": "$accent: #00aa77;",
|
|
125
|
+
"line_start": 25,
|
|
126
|
+
"line_end": 25,
|
|
127
|
+
"metadata": {
|
|
128
|
+
"module": "",
|
|
129
|
+
"names": "",
|
|
130
|
+
"dots": "",
|
|
131
|
+
"language_hint": ""
|
|
132
|
+
},
|
|
133
|
+
"id": "cebdec667e5d1547"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"blob_sha": "sha1",
|
|
137
|
+
"file_path": "Counter.vue",
|
|
138
|
+
"kind": "class",
|
|
139
|
+
"name": ".counter",
|
|
140
|
+
"scope": "",
|
|
141
|
+
"language": "scss",
|
|
142
|
+
"file_language": "vue",
|
|
143
|
+
"content": ".counter {\n color: $accent;\n font-weight: bold;\n }",
|
|
144
|
+
"line_start": 27,
|
|
145
|
+
"line_end": 30,
|
|
146
|
+
"metadata": {
|
|
147
|
+
"module": "",
|
|
148
|
+
"names": "",
|
|
149
|
+
"dots": "",
|
|
150
|
+
"language_hint": ""
|
|
151
|
+
},
|
|
152
|
+
"id": "c41a0c5fc46325f9"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"blob_sha": "sha1",
|
|
156
|
+
"file_path": "store.ts",
|
|
157
|
+
"kind": "comment",
|
|
158
|
+
"name": "",
|
|
159
|
+
"scope": "",
|
|
160
|
+
"language": "typescript",
|
|
161
|
+
"file_language": "typescript",
|
|
162
|
+
"content": "// Imported by Counter.vue's <script setup> block.",
|
|
163
|
+
"line_start": 1,
|
|
164
|
+
"line_end": 1,
|
|
165
|
+
"metadata": {
|
|
166
|
+
"module": "",
|
|
167
|
+
"names": "",
|
|
168
|
+
"dots": "",
|
|
169
|
+
"language_hint": ""
|
|
170
|
+
},
|
|
171
|
+
"id": "b0eec444d8e60c22"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"blob_sha": "sha1",
|
|
175
|
+
"file_path": "store.ts",
|
|
176
|
+
"kind": "function",
|
|
177
|
+
"name": "makeStore",
|
|
178
|
+
"scope": "",
|
|
179
|
+
"language": "typescript",
|
|
180
|
+
"file_language": "typescript",
|
|
181
|
+
"content": "function makeStore(): { count: number } {\n return { count: 0 };\n}",
|
|
182
|
+
"line_start": 3,
|
|
183
|
+
"line_end": 5,
|
|
184
|
+
"metadata": {
|
|
185
|
+
"module": "",
|
|
186
|
+
"names": "",
|
|
187
|
+
"dots": "",
|
|
188
|
+
"language_hint": ""
|
|
189
|
+
},
|
|
190
|
+
"id": "a264a8c3d2ecd498"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Vue single-file component.
|
|
3
|
+
|
|
4
|
+
The SFC plugin delegates <script> to TypeScript and <style> to SCSS.
|
|
5
|
+
This comment is itself a chunk, so a component's own explanation of
|
|
6
|
+
what it is for stays searchable.
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
// Vue single-file component.
|
|
11
|
+
//
|
|
12
|
+
// The SFC plugin delegates the <script setup> block to TypeScript and
|
|
13
|
+
// the <style> block to SCSS, reusing the same chunker as Svelte. The
|
|
14
|
+
// template is not extracted.
|
|
15
|
+
import { makeStore } from "./store";
|
|
16
|
+
|
|
17
|
+
const store = makeStore();
|
|
18
|
+
|
|
19
|
+
function increment(): void {
|
|
20
|
+
store.count += 1;
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<style lang="scss">
|
|
25
|
+
$accent: #00aa77;
|
|
26
|
+
|
|
27
|
+
.counter {
|
|
28
|
+
color: $accent;
|
|
29
|
+
font-weight: bold;
|
|
30
|
+
}
|
|
31
|
+
</style>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<button class="counter" @click="increment">{{ store.count }}</button>
|
|
35
|
+
</template>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Vue sample extraction: the `samples/vue/` project through the real pipeline."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
from tree_sitter import Parser
|
|
10
|
+
|
|
11
|
+
from rbtr.domain.models import Chunk, ChunkKind, Edge
|
|
12
|
+
from rbtr.git import FileEntry
|
|
13
|
+
from rbtr.languages.edges import build_resolution_map, infer_import_edges
|
|
14
|
+
from rbtr.languages.extract import extract_file
|
|
15
|
+
from rbtr.languages.manager import get_manager
|
|
16
|
+
from rbtr.testing import assert_document_fully_chunked, render_edges
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from syrupy.assertion import SnapshotAssertion
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.fixture
|
|
23
|
+
def project() -> list[tuple[str, str]]:
|
|
24
|
+
root = Path(__file__).parent / "samples" / "vue"
|
|
25
|
+
return [
|
|
26
|
+
(str(p.relative_to(root)), p.read_text()) for p in sorted(root.rglob("*")) if p.is_file()
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@pytest.fixture
|
|
31
|
+
def chunks(project: list[tuple[str, str]]) -> list[Chunk]:
|
|
32
|
+
manager = get_manager()
|
|
33
|
+
out: list[Chunk] = []
|
|
34
|
+
for path, text in project:
|
|
35
|
+
lang = manager.detect_language(path) or "vue"
|
|
36
|
+
out.extend(extract_file(FileEntry(path, "sha1", text.encode()), lang))
|
|
37
|
+
return out
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.fixture
|
|
41
|
+
def edges(project: list[tuple[str, str]], chunks: list[Chunk]) -> list[Edge]:
|
|
42
|
+
manager = get_manager()
|
|
43
|
+
repo_files = {path for path, _ in project}
|
|
44
|
+
return infer_import_edges(chunks, repo_files, build_resolution_map(manager))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_emits_expected_kinds(chunks: list[Chunk]) -> None:
|
|
48
|
+
"""The `<script lang="ts">` and blocks are delegated to TypeScript/SCSS; the template is a host chunk."""
|
|
49
|
+
kinds = {c.kind for c in chunks}
|
|
50
|
+
assert {
|
|
51
|
+
ChunkKind.FUNCTION,
|
|
52
|
+
ChunkKind.VARIABLE,
|
|
53
|
+
ChunkKind.DOC_SECTION,
|
|
54
|
+
ChunkKind.IMPORT,
|
|
55
|
+
} <= kinds
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_parses_cleanly(project: list[tuple[str, str]]) -> None:
|
|
59
|
+
manager = get_manager()
|
|
60
|
+
for path, text in project:
|
|
61
|
+
grammar = manager.grammar(manager.detect_language(path) or "vue")
|
|
62
|
+
assert grammar is not None
|
|
63
|
+
assert not Parser(grammar).parse(text.encode()).root_node.has_error, path
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_extraction_matches_snapshot(chunks: list[Chunk], snapshot_json: SnapshotAssertion) -> None:
|
|
67
|
+
assert chunks == snapshot_json
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_edges_match_snapshot(
|
|
71
|
+
chunks: list[Chunk], edges: list[Edge], snapshot_json: SnapshotAssertion
|
|
72
|
+
) -> None:
|
|
73
|
+
assert render_edges(edges, chunks) == snapshot_json
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_every_block_of_every_document_is_chunked(
|
|
77
|
+
project: list[tuple[str, str]], chunks: list[Chunk]
|
|
78
|
+
) -> None:
|
|
79
|
+
"""A chunker owns the whole document, so no top-level block is dropped."""
|
|
80
|
+
manager = get_manager()
|
|
81
|
+
for path, text in project:
|
|
82
|
+
if manager.detect_language(path) != "vue":
|
|
83
|
+
continue
|
|
84
|
+
grammar = manager.grammar("vue")
|
|
85
|
+
assert grammar is not None
|
|
86
|
+
assert_document_fully_chunked(path, text, chunks, grammar)
|