Skip to content

Commit 6420821

Browse files
authored
chore: Update readme, add more languages (#7)
1 parent c4ae59f commit 6420821

7 files changed

Lines changed: 79 additions & 17 deletions

File tree

README.md

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
# semble-grammars
1+
<h1 align="center">
2+
semble-grammars<br/>
3+
<sub>Prebuilt tree-sitter grammars for Semble</sub>
4+
</h1>
5+
6+
<div align="center">
7+
<h2>
8+
<a href="https://pypi.org/project/semble-grammars/"><img src="https://img.shields.io/pypi/v/semble-grammars?color=%23007ec6&label=pypi%20package" alt="Package version"></a>
9+
<a href="https://github.com/MinishLab/semble-grammars/blob/main/LICENSE">
10+
<img src="https://img.shields.io/badge/license-MIT-green" alt="License - MIT">
11+
</a>
12+
</h2>
13+
</div>
214

315
Compiled [tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammars for
416
[Semble](https://github.com/MinishLab/semble).
@@ -7,6 +19,14 @@ The package installs a platform-specific grammar archive and extracts individual
719
libraries to a local cache on first use. It does not access the network at
820
runtime.
921

22+
## Installation
23+
24+
```bash
25+
pip install semble-grammars
26+
```
27+
28+
## Usage
29+
1030
```python
1131
from semble_grammars import get_parser
1232

@@ -18,24 +38,33 @@ tree = parser.parse(b"def hello(): pass")
1838
macOS arm64 and x86-64, Linux arm64 and x86-64, and Windows arm64 and x86-64.
1939

2040
<details>
21-
<summary>Included grammars (75)</summary>
41+
<summary>Included grammars (77)</summary>
2242

2343
The canonical names accepted by `get_parser()` are:
2444

25-
`asciidoc`, `astro`, `bash`, `c`, `clojure`, `cmake`, `cpp`, `csharp`, `css`,
26-
`dart`, `dockerfile`, `dtd`, `elixir`, `embedded_template`, `erlang`, `fortran`,
27-
`gitignore`, `go`, `gotmpl`, `graphql`, `groovy`, `haskell`, `hcl`, `html`,
28-
`ini`, `java`, `javascript`, `jinja2`, `json`, `json5`, `jsonc`, `jsonnet`,
29-
`julia`, `just`, `kdl`, `kotlin`, `latex`, `lua`, `make`, `markdown`,
30-
`markdown_inline`, `nix`, `objc`, `ocaml`, `org`, `perl`, `php`, `php_only`,
31-
`powershell`, `properties`, `proto`, `python`, `r`, `racket`, `rst`, `ruby`,
32-
`rust`, `scala`, `scheme`, `scss`, `solidity`, `sql`, `starlark`, `svelte`,
33-
`swift`, `toml`, `tsx`, `typescript`, `typst`, `vim`, `vue`, `wat`, `xml`,
34-
`yaml`, `zig`.
35-
36-
`py` is an alias for `python`, and `terraform` is an alias for `hcl`.
45+
`asciidoc`, `astro`, `bash`, `batch`, `c`, `clojure`, `cmake`, `cpp`,
46+
`csharp`, `css`, `dart`, `dockerfile`, `dtd`, `elixir`, `embedded_template`,
47+
`erlang`, `fortran`, `gitignore`, `go`, `gotmpl`, `graphql`, `groovy`,
48+
`haskell`, `hcl`, `heex`, `html`, `ini`, `java`, `javascript`, `jinja2`,
49+
`json`, `json5`, `jsonc`, `jsonnet`, `julia`, `just`, `kdl`, `kotlin`,
50+
`latex`, `lua`, `make`, `markdown`, `markdown_inline`, `nix`, `objc`,
51+
`ocaml`, `org`, `perl`, `php`, `php_only`, `powershell`, `properties`,
52+
`proto`, `python`, `r`, `racket`, `rst`, `ruby`, `rust`, `scala`, `scheme`,
53+
`scss`, `solidity`, `sql`, `starlark`, `svelte`, `swift`, `toml`, `tsx`,
54+
`typescript`, `typst`, `vim`, `vue`, `wat`, `xml`, `yaml`, `zig`.
55+
56+
`py` is an alias for `python`, `terraform` is an alias for `hcl`,
57+
`embeddedtemplate` is an alias for `embedded_template`, and `zsh` is an alias
58+
for `bash`.
3759
</details>
3860

61+
The MIT license above covers `semble-grammars`' own code. Each bundled grammar is a
62+
separate upstream work with its own license; see
63+
[`THIRD_PARTY_NOTICES.md`](src/semble_grammars/grammars/THIRD_PARTY_NOTICES.md) for the
64+
full list.
65+
66+
## Building from source
67+
3968
Build grammars from the pinned sources in
4069
[`sources.json`](src/semble_grammars/grammars/sources.json):
4170

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "semble-grammars"
7-
description = "Locally-cached tree-sitter grammar bundle for Semble, with no runtime downloads."
8-
authors = [{name = "MinishLab", email = "info@minishlab.com"}]
7+
description = "Prebuilt tree-sitter grammars for Semble"
8+
authors = [{name = "Thomas van Dongen", email = "thomasvdongen@proton.me"}, { name = "Stéphan Tulkens", email = "stephantul@gmail.com"}]
99
readme = { file = "README.md", content-type = "text/markdown" }
1010
dynamic = ["version"]
1111
license = "MIT"

src/semble_grammars/grammars/THIRD_PARTY_NOTICES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ full license and notice text of each.
1010
| asciidoc | https://github.com/cathaysia/tree-sitter-asciidoc | `e0710115e7b060ce6681b5182a49a792813006f1` | Apache-2.0 |
1111
| astro | https://github.com/virchau13/tree-sitter-astro | `213f6e6973d9b456c6e50e86f19f66877e7ef0ee` | MIT |
1212
| bash | https://github.com/tree-sitter/tree-sitter-bash | `a06c2e4415e9bc0346c6b86d401879ffb44058f7` (v0.25.1) | MIT |
13+
| batch | https://github.com/wharflab/tree-sitter-batch | `f477847c89b7db79b0d5e3527ba39318bf054e2f` (v0.9.0) | MIT |
1314
| c | https://github.com/tree-sitter/tree-sitter-c | `b780e47fc780ddc8da13afa35a3f4ed5c157823d` (v0.24.2) | MIT |
1415
| clojure | https://github.com/sogaiu/tree-sitter-clojure | `3a1ace906c151dd631cf6f149b5083f2b60e6a9e` (v0.0.13) | CC0-1.0 |
1516
| cmake | https://github.com/uyha/tree-sitter-cmake | `ca627bb5828616b6246aafdc3c3222789e728e37` (v0.7.4) | MIT |
@@ -30,6 +31,7 @@ full license and notice text of each.
3031
| groovy | https://github.com/murtaza64/tree-sitter-groovy | `deb0dcf8c4544f07564060f6e9b9f6e4b0bfc27d` | MIT |
3132
| haskell | https://github.com/tree-sitter/tree-sitter-haskell | `0975ef72fc3c47b530309ca93937d7d143523628` | MIT |
3233
| hcl | https://github.com/tree-sitter-grammars/tree-sitter-hcl | `fad991865fee927dd1de5e172fb3f08ac674d914` (v1.2.0) | Apache-2.0 |
34+
| heex | https://github.com/phoenixframework/tree-sitter-heex | `5842537f734d7c12685bf27d6005313e3e5a47a0` (v0.9.0) | MIT |
3335
| html | https://github.com/tree-sitter/tree-sitter-html | `5a5ca8551a179998360b4a4ca2c0f366a35acc03` (v0.23.2) | MIT |
3436
| ini | https://github.com/justinmk/tree-sitter-ini | `f0285fe577ad298ad79f8633e643ad60646e3027` (v1.4.0) | Apache-2.0 |
3537
| java | https://github.com/tree-sitter/tree-sitter-java | `94703d5a6bed02b98e438d7cad1136c01a60ba2c` (v0.23.5) | MIT |

src/semble_grammars/grammars/sources.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,5 +679,23 @@
679679
"src/parser.c",
680680
"src/scanner.c"
681681
]
682+
},
683+
"batch": {
684+
"repository": "https://github.com/wharflab/tree-sitter-batch",
685+
"commit": "f477847c89b7db79b0d5e3527ba39318bf054e2f",
686+
"ref": "v0.9.0",
687+
"spdx_license": "MIT",
688+
"sources": [
689+
"src/parser.c"
690+
]
691+
},
692+
"heex": {
693+
"repository": "https://github.com/phoenixframework/tree-sitter-heex",
694+
"commit": "5842537f734d7c12685bf27d6005313e3e5a47a0",
695+
"ref": "v0.9.0",
696+
"spdx_license": "MIT",
697+
"sources": [
698+
"src/parser.c"
699+
]
682700
}
683701
}

src/semble_grammars/loader.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"py": "python",
1919
# Terraform files are valid HCL; there is no separate compiled grammar.
2020
"terraform": "hcl",
21+
"embeddedtemplate": "embedded_template",
22+
# Zsh is largely a superset of POSIX shell; there is no separate compiled grammar.
23+
"zsh": "bash",
2124
}
2225

2326
_OS_NAMES = {"darwin": "macos", "linux": "linux", "windows": "windows"}

src/semble_grammars/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.1"
1+
__version__ = "0.1.2"

tests/test_loader.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
("python", b"def foo(:\n", True),
2121
("json", b'{"a": [1, 2, 3]}', False),
2222
("sql", b"SELECT * FROM foo WHERE x = 1;", False),
23+
("batch", b"@echo off\nset FOO=bar\n", False),
24+
("heex", b"<div><%= @name %></div>\n", False),
2325
],
2426
)
2527
def test_get_parser_parses_bundled_languages(name, source, expect_error):
@@ -32,6 +34,14 @@ def test_terraform_is_an_alias_for_hcl():
3234
assert get_language("terraform") == get_language("hcl")
3335

3436

37+
def test_embeddedtemplate_is_an_alias_for_embedded_template():
38+
assert get_language("embeddedtemplate") == get_language("embedded_template")
39+
40+
41+
def test_zsh_is_an_alias_for_bash():
42+
assert get_language("zsh") == get_language("bash")
43+
44+
3545
def test_unknown_language_raises_with_available_languages_listed():
3646
with pytest.raises(LanguageNotFoundError, match="nonexistent"):
3747
get_parser("nonexistent")

0 commit comments

Comments
 (0)