tree-sitter-ghactions 0.1.2__cp310-abi3-musllinux_1_2_x86_64.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.
- tree_sitter_ghactions/__init__.py +53 -0
- tree_sitter_ghactions/__init__.pyi +10 -0
- tree_sitter_ghactions/_binding.abi3.so +0 -0
- tree_sitter_ghactions/binding.c +32 -0
- tree_sitter_ghactions/py.typed +0 -0
- tree_sitter_ghactions/queries/highlights.scm +83 -0
- tree_sitter_ghactions-0.1.2.dist-info/METADATA +75 -0
- tree_sitter_ghactions-0.1.2.dist-info/RECORD +10 -0
- tree_sitter_ghactions-0.1.2.dist-info/WHEEL +5 -0
- tree_sitter_ghactions-0.1.2.dist-info/top_level.txt +2 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
"""Parser for Github Actions expressions"""
|
2
|
+
|
3
|
+
from importlib.resources import files as _files
|
4
|
+
|
5
|
+
from ._binding import language
|
6
|
+
|
7
|
+
|
8
|
+
def _get_query(name, file):
|
9
|
+
query = _files(f"{__package__}.queries") / file
|
10
|
+
globals()[name] = query.read_text()
|
11
|
+
return globals()[name]
|
12
|
+
|
13
|
+
|
14
|
+
def __getattr__(name):
|
15
|
+
# NOTE: uncomment these to include any queries that this grammar contains:
|
16
|
+
|
17
|
+
if name == "HIGHLIGHTS_QUERY":
|
18
|
+
return _get_query("HIGHLIGHTS_QUERY", "highlights.scm")
|
19
|
+
# if name == "INJECTIONS_QUERY":
|
20
|
+
# return _get_query("INJECTIONS_QUERY", "injections.scm")
|
21
|
+
# if name == "LOCALS_QUERY":
|
22
|
+
# return _get_query("LOCALS_QUERY", "locals.scm")
|
23
|
+
# if name == "TAGS_QUERY":
|
24
|
+
# return _get_query("TAGS_QUERY", "tags.scm")
|
25
|
+
|
26
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
27
|
+
|
28
|
+
|
29
|
+
__all__ = [
|
30
|
+
"language",
|
31
|
+
"HIGHLIGHTS_QUERY",
|
32
|
+
# "INJECTIONS_QUERY",
|
33
|
+
# "LOCALS_QUERY",
|
34
|
+
# "TAGS_QUERY",
|
35
|
+
]
|
36
|
+
|
37
|
+
|
38
|
+
def __dir__():
|
39
|
+
return sorted(
|
40
|
+
__all__
|
41
|
+
+ [
|
42
|
+
"__all__",
|
43
|
+
"__builtins__",
|
44
|
+
"__cached__",
|
45
|
+
"__doc__",
|
46
|
+
"__file__",
|
47
|
+
"__loader__",
|
48
|
+
"__name__",
|
49
|
+
"__package__",
|
50
|
+
"__path__",
|
51
|
+
"__spec__",
|
52
|
+
]
|
53
|
+
)
|
Binary file
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#include <Python.h>
|
2
|
+
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
4
|
+
|
5
|
+
TSLanguage *tree_sitter_ghactions(void);
|
6
|
+
|
7
|
+
static PyObject *_binding_language(PyObject *Py_UNUSED(self),
|
8
|
+
PyObject *Py_UNUSED(args)) {
|
9
|
+
return PyCapsule_New(tree_sitter_ghactions(), "tree_sitter.Language", NULL);
|
10
|
+
}
|
11
|
+
|
12
|
+
static struct PyModuleDef_Slot slots[] = {
|
13
|
+
#ifdef Py_GIL_DISABLED
|
14
|
+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
|
15
|
+
#endif
|
16
|
+
{0, NULL}};
|
17
|
+
|
18
|
+
static PyMethodDef methods[] = {
|
19
|
+
{"language", _binding_language, METH_NOARGS,
|
20
|
+
"Get the tree-sitter language for this grammar."},
|
21
|
+
{NULL, NULL, 0, NULL}};
|
22
|
+
|
23
|
+
static struct PyModuleDef module = {
|
24
|
+
.m_base = PyModuleDef_HEAD_INIT,
|
25
|
+
.m_name = "_binding",
|
26
|
+
.m_doc = NULL,
|
27
|
+
.m_size = 0,
|
28
|
+
.m_methods = methods,
|
29
|
+
.m_slots = slots,
|
30
|
+
};
|
31
|
+
|
32
|
+
PyMODINIT_FUNC PyInit__binding(void) { return PyModuleDef_Init(&module); }
|
File without changes
|
@@ -0,0 +1,83 @@
|
|
1
|
+
; note: all highlights are set to priority 101, for compatibility with bash injections in yaml
|
2
|
+
([
|
3
|
+
"${{"
|
4
|
+
"}}"
|
5
|
+
] @keyword
|
6
|
+
(#set! priority 101))
|
7
|
+
|
8
|
+
([
|
9
|
+
"&&"
|
10
|
+
"||"
|
11
|
+
"=="
|
12
|
+
"!="
|
13
|
+
"<"
|
14
|
+
"<="
|
15
|
+
">"
|
16
|
+
">="
|
17
|
+
"+"
|
18
|
+
"-"
|
19
|
+
"!"
|
20
|
+
] @operator
|
21
|
+
(#set! priority 101))
|
22
|
+
|
23
|
+
([
|
24
|
+
"("
|
25
|
+
")"
|
26
|
+
"["
|
27
|
+
"]"
|
28
|
+
] @punctuation.bracket
|
29
|
+
(#set! priority 101))
|
30
|
+
|
31
|
+
([
|
32
|
+
","
|
33
|
+
"."
|
34
|
+
] @punctuation.delimiter
|
35
|
+
(#set! priority 101))
|
36
|
+
|
37
|
+
("*" @punctuation.special
|
38
|
+
(#set! priority 101))
|
39
|
+
|
40
|
+
((number) @number
|
41
|
+
(#set! priority 101))
|
42
|
+
|
43
|
+
((identifier) @variable
|
44
|
+
(#set! priority 101))
|
45
|
+
|
46
|
+
; https://docs.github.com/en/actions/reference/workflows-and-actions/contexts
|
47
|
+
(dereference_expression
|
48
|
+
object: (identifier) @module.builtin
|
49
|
+
(#any-of? @module.builtin
|
50
|
+
"github" "env" "vars" "job" "jobs" "steps" "runner" "secrets" "strategy" "matrix" "needs"
|
51
|
+
"inputs")
|
52
|
+
(#set! priority 101))
|
53
|
+
|
54
|
+
((dereference_expression
|
55
|
+
property: (identifier) @property)
|
56
|
+
(#set! priority 101))
|
57
|
+
|
58
|
+
((function_call
|
59
|
+
name: (identifier) @function.call)
|
60
|
+
(#set! priority 101))
|
61
|
+
|
62
|
+
; https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#functions
|
63
|
+
((function_call
|
64
|
+
name: (identifier) @function.builtin
|
65
|
+
(#any-of? @function.builtin
|
66
|
+
"contains" "startsWith" "endsWith" "format" "join" "toJSON" "fromJSON" "hashFiles" "success"
|
67
|
+
"always" "cancelled" "failure"))
|
68
|
+
(#set! priority 101))
|
69
|
+
|
70
|
+
([
|
71
|
+
(true)
|
72
|
+
(false)
|
73
|
+
] @boolean
|
74
|
+
(#set! priority 101))
|
75
|
+
|
76
|
+
((null) @constant.builtin
|
77
|
+
(#set! priority 101))
|
78
|
+
|
79
|
+
((string) @string
|
80
|
+
(#set! priority 101))
|
81
|
+
|
82
|
+
((escape) @string.escape
|
83
|
+
(#set! priority 101))
|
@@ -0,0 +1,75 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: tree-sitter-ghactions
|
3
|
+
Version: 0.1.2
|
4
|
+
Summary: Parser for Github Actions expressions
|
5
|
+
Author-email: Robert Muir <rmuir@apache.org>
|
6
|
+
License: MIT
|
7
|
+
Project-URL: Homepage, https://github.com/rmuir/tree-sitter-ghactions
|
8
|
+
Keywords: incremental,parsing,tree-sitter,github,actions
|
9
|
+
Classifier: Intended Audience :: Developers
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
11
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
12
|
+
Classifier: Typing :: Typed
|
13
|
+
Requires-Python: >=3.10
|
14
|
+
Description-Content-Type: text/markdown
|
15
|
+
Provides-Extra: core
|
16
|
+
Requires-Dist: tree-sitter~=0.25; extra == "core"
|
17
|
+
|
18
|
+
# tree-sitter-ghactions
|
19
|
+
|
20
|
+
Github Actions expressions grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter)
|
21
|
+
|
22
|
+
## Features
|
23
|
+
|
24
|
+
* Parses Github Action's expressions: `${{ ... }}`
|
25
|
+
* Plays well with `bash` injections in YAML documents
|
26
|
+
* Passes parsing tests from [actionlint](https://github.com/rhysd/actionlint)
|
27
|
+
|
28
|
+
## Neovim Installation (for use in your editor)
|
29
|
+
|
30
|
+
1. Install [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/tree/main)
|
31
|
+
|
32
|
+
2. Configure autocmd for a custom parser:
|
33
|
+
|
34
|
+
```lua
|
35
|
+
-- custom parsers
|
36
|
+
vim.api.nvim_create_autocmd('User', {
|
37
|
+
pattern = 'TSUpdate',
|
38
|
+
callback = function()
|
39
|
+
require('nvim-treesitter.parsers').ghactions = {
|
40
|
+
install_info = {
|
41
|
+
url = 'https://github.com/rmuir/tree-sitter-ghactions',
|
42
|
+
queries = 'queries',
|
43
|
+
},
|
44
|
+
}
|
45
|
+
end,
|
46
|
+
})
|
47
|
+
```
|
48
|
+
|
49
|
+
3. Configure yaml injection in `~/.config/nvim/queries/yaml/injections.scm`:
|
50
|
+
```tsq
|
51
|
+
; extends
|
52
|
+
|
53
|
+
; github actions
|
54
|
+
([
|
55
|
+
(string_scalar)
|
56
|
+
(block_scalar)
|
57
|
+
(double_quote_scalar)
|
58
|
+
(single_quote_scalar)
|
59
|
+
] @injection.content
|
60
|
+
(#lua-match? @injection.content "[$]{{.*}}")
|
61
|
+
(#set! injection.language "ghactions"))
|
62
|
+
```
|
63
|
+
|
64
|
+
4. Run `:TSUpdate` from neovim.
|
65
|
+
|
66
|
+
NOTE: these instructions are based upon the `main` branch of `nvim-treesitter`.
|
67
|
+
|
68
|
+
## Bindings Installation (for development)
|
69
|
+
|
70
|
+
Bindings are published to `pypi`, `npm`, and `crates.io` as `tree-sitter-ghactions`.
|
71
|
+
Wasm and source code artifacts are published to [GitHub releases](https://github.com/rmuir/tree-sitter-ghactions/releases)
|
72
|
+
|
73
|
+
## Screenshot of highlights
|
74
|
+
|
75
|
+

|
@@ -0,0 +1,10 @@
|
|
1
|
+
tree_sitter_ghactions/__init__.py,sha256=CvrVfL3drWmCCF9umgQ-Q6XlVTV-ez90wrb-o8tV-yo,1286
|
2
|
+
tree_sitter_ghactions/__init__.pyi,sha256=A4sjCd_1pfiO7sWEnEjeKpZC2ximaBTNAhQX7OuSF2Y,245
|
3
|
+
tree_sitter_ghactions/_binding.abi3.so,sha256=-kcOI79nhFdw7NiezbKOFuiNzXSMCbLtI6cGm9UTA3E,44696
|
4
|
+
tree_sitter_ghactions/binding.c,sha256=0awVAXQAOfAxpD1ztUzMUYyoU53i7oG2U_tB0NdQ2YE,869
|
5
|
+
tree_sitter_ghactions/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
tree_sitter_ghactions/queries/highlights.scm,sha256=teqXPqTc2R_uUyILMnRBx3sYITIuCLBqfcdUpIWAKi4,1546
|
7
|
+
tree_sitter_ghactions-0.1.2.dist-info/METADATA,sha256=m-ltix8RxIGiZZYEBA2UGys5RZcdDm7GESXxU5YOUeY,2252
|
8
|
+
tree_sitter_ghactions-0.1.2.dist-info/WHEEL,sha256=RLTeeIVGGszrHIp46_PGEkqkg0ZOBqBbIDNIwOdtd7A,111
|
9
|
+
tree_sitter_ghactions-0.1.2.dist-info/top_level.txt,sha256=bxtb4PZqFiemjR4iQZ1pgQlgmcOMsMKJm22F4Gqm_MQ,31
|
10
|
+
tree_sitter_ghactions-0.1.2.dist-info/RECORD,,
|