Skip to content

Commit b1bd1a7

Browse files
committed
📄 Add LICENSE
1 parent e37a2ef commit b1bd1a7

9 files changed

Lines changed: 770 additions & 48 deletions

File tree

.readthedocs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# https://docs.readthedocs.io/en/stable/config-file/v2.html
2+
---
3+
version: 2
4+
5+
sphinx:
6+
configuration: docs/conf.py
7+
8+
build:
9+
os: ubuntu-22.04
10+
tools:
11+
python: "3"
12+
13+
formats:
14+
- htmlzip
15+
16+
python:
17+
install:
18+
- requirements: docs/requirements.txt

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,16 @@ This project provides:
55
- Language bindings for [tree-sitter-highlight](https://crates.io/crates/tree-sitter-highlight).
66
- [python](crates/py-tree-sitter-highlight)
77
- [lua](crates/lua-tree-sitter-highlight)
8+
- [nodejs](crates/js-tree-sitter-highlight): TODO
89
- Some packages to use tree-sitter to highlight
910
- [sphinx](https://github.com/sphinx-doc/sphinx):
1011
[sphinxcontrib-tree-sitter](packages/sphinxcontrib-tree-sitter)
1112
- [ldoc](https://github.com/lunarmodules/ldoc):
1213
[texcat](https://texrocks.readthedocs.io/en/latest/topics/texcat.md.html)
13-
- [LaTeX](https://www.latex-project.org/): also
14+
- [pandoc](http://github.com/pandoc/pandoc):
1415
[texcat](https://texrocks.readthedocs.io/en/latest/topics/texcat.md.html)
15-
- [pandoc](http://github.com/pandoc/pandoc): also
16+
- [LaTeX](https://www.latex-project.org/):
1617
[texcat](https://texrocks.readthedocs.io/en/latest/topics/texcat.md.html)
18+
- [hexo](https://github.com/hexojs/hexo): TODO
1719
- [jekyll](https://github.com/jekyll/jekyll): TODO
1820
- [typst](https://github.com/typst/typst): TODO
19-
20-
## Bench
21-
22-
<!-- markdownlint-disable MD013 -->
23-
24-
```bash
25-
$ hyperfine -Nw10 'python -m sphinxcontrib.tree_sitter pyproject.toml' 'texcat pyproject.toml' 'tree-sitter highlight pyproject.toml' 'pygmentize pyproject.toml' 'bat pyproject.toml'
26-
Benchmark 1: python -m sphinxcontrib.tree_sitter pyproject.toml
27-
Time (mean ± σ): 397.4 ms ± 64.9 ms [User: 338.5 ms, System: 50.8 ms]
28-
Range (min … max): 335.9 ms … 503.8 ms 10 runs
29-
30-
Benchmark 2: texcat pyproject.toml
31-
Time (mean ± σ): 1.782 s ± 0.041 s [User: 1.174 s, System: 0.600 s]
32-
Range (min … max): 1.746 s … 1.884 s 10 runs
33-
34-
Benchmark 3: tree-sitter highlight pyproject.toml
35-
Time (mean ± σ): 6.2 ms ± 0.4 ms [User: 2.7 ms, System: 3.1 ms]
36-
Range (min … max): 5.5 ms … 8.3 ms 394 runs
37-
38-
Benchmark 4: pygmentize pyproject.toml
39-
Time (mean ± σ): 262.4 ms ± 2.6 ms [User: 236.6 ms, System: 23.0 ms]
40-
Range (min … max): 258.9 ms … 268.5 ms 11 runs
41-
42-
Benchmark 5: bat pyproject.toml
43-
Time (mean ± σ): 12.6 ms ± 0.6 ms [User: 10.4 ms, System: 5.7 ms]
44-
Range (min … max): 11.6 ms … 14.9 ms 223 runs
45-
46-
Summary
47-
tree-sitter highlight pyproject.toml ran
48-
2.04 ± 0.17 times faster than bat pyproject.toml
49-
42.38 ± 2.87 times faster than pygmentize pyproject.toml
50-
64.18 ± 11.32 times faster than python -m sphinxcontrib.tree_sitter pyproject.toml
51-
287.79 ± 20.36 times faster than texcat pyproject.toml
52-
```

docs/conf.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
)
3333

3434
with open(PROJECT_FILE, "rb") as f:
35-
data = tomllib.load(f)
36-
project = data["project"]
37-
author = project["authors"][0]["name"]
38-
project = project["name"]
35+
data: dict = tomllib.load(f)
36+
project: dict = data["project"]
37+
author: str = project["authors"][0]["name"]
38+
project: str = project["name"]
3939

4040
# -- General configuration ---------------------------------------------------
4141

@@ -52,6 +52,9 @@
5252
]
5353

5454
myst_heading_anchors = 3
55+
myst_title_to_header = True
56+
myst_enable_extensions = ["tasklist"]
57+
todo_include_todos = True
5558

5659
# Add any paths that contain templates here, relative to this directory.
5760
templates_path = ["_templates"]
@@ -66,10 +69,10 @@
6669

6770
# The theme to use for HTML and HTML Help pages. See the documentation for
6871
# a list of builtin themes.
69-
#
72+
html_theme = "furo"
7073

7174
# Add any paths that contain custom static files (such as style sheets) here,
7275
# relative to this directory. They are copied after the builtin static files,
7376
# so a file named "default.css" will overwrite the builtin "default.css".
7477
# html_static_path = ["_static"]
75-
html_favicon = "https://www.sphinx-doc.org/en/master/_static/favicon.svg"
78+
html_favicon = "https://tree-sitter.github.io/tree-sitter/favicon.png"

docs/index.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<!-- markdownlint-disable MD041-->
22

3+
```{toctree}
4+
---
5+
hidden:
6+
glob:
7+
caption: resources
8+
---
9+
resources/*
10+
```
11+
312
```{toctree}
413
---
514
hidden:
@@ -16,8 +25,8 @@ search
1625
```{include} ../crates/py-tree-sitter-highlight/README.md
1726
```
1827

19-
```{include} ../packages/sphinxcontrib-tree-sitter/README.md
28+
```{include} ../crates/lua-tree-sitter-highlight/README.md
2029
```
2130

22-
```{include} ../crates/lua-tree-sitter-highlight/README.md
31+
```{include} ../packages/sphinxcontrib-tree-sitter/README.md
2332
```

docs/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env -S pip install -r
2+
3+
-e packages/sphinxcontrib-tree-sitter[docs]

docs/resources/bench.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Bench
2+
3+
Installed parsers:
4+
5+
- tree-sitter: 1
6+
- py-tree-sitter: 5
7+
- lua-tree-sitter: 338
8+
9+
<!-- markdownlint-disable MD013 -->
10+
11+
```bash
12+
$ hyperfine -Nw10 'python -m sphinxcontrib.tree_sitter pyproject.toml' 'texcat pyproject.toml' 'tree-sitter highlight pyproject.toml' 'pygmentize pyproject.toml' 'bat pyproject.toml'
13+
Benchmark 1: python -m sphinxcontrib.tree_sitter pyproject.toml
14+
Time (mean ± σ): 397.4 ms ± 64.9 ms [User: 338.5 ms, System: 50.8 ms]
15+
Range (min … max): 335.9 ms … 503.8 ms 10 runs
16+
17+
Benchmark 2: texcat pyproject.toml
18+
Time (mean ± σ): 1.782 s ± 0.041 s [User: 1.174 s, System: 0.600 s]
19+
Range (min … max): 1.746 s … 1.884 s 10 runs
20+
21+
Benchmark 3: tree-sitter highlight pyproject.toml
22+
Time (mean ± σ): 6.2 ms ± 0.4 ms [User: 2.7 ms, System: 3.1 ms]
23+
Range (min … max): 5.5 ms … 8.3 ms 394 runs
24+
25+
Benchmark 4: pygmentize pyproject.toml
26+
Time (mean ± σ): 262.4 ms ± 2.6 ms [User: 236.6 ms, System: 23.0 ms]
27+
Range (min … max): 258.9 ms … 268.5 ms 11 runs
28+
29+
Benchmark 5: bat pyproject.toml
30+
Time (mean ± σ): 12.6 ms ± 0.6 ms [User: 10.4 ms, System: 5.7 ms]
31+
Range (min … max): 11.6 ms … 14.9 ms 223 runs
32+
33+
Summary
34+
tree-sitter highlight pyproject.toml ran
35+
2.04 ± 0.17 times faster than bat pyproject.toml
36+
42.38 ± 2.87 times faster than pygmentize pyproject.toml
37+
64.18 ± 11.32 times faster than python -m sphinxcontrib.tree_sitter pyproject.toml
38+
287.79 ± 20.36 times faster than texcat pyproject.toml
39+
```

packages/sphinxcontrib-tree-sitter/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
Use tree-sitter to highlight code blocks.
44

5+
## Examples
6+
7+
- [lsp-tree-sitter](https://lsp-tree-sitter.readthedocs.io/)
8+
- This website itself.
9+
510
## Usage
611

712
### CLI
813

9-
```sh
14+
```bash
1015
python -m sphinxcontrib.tree_sitter /the/path/of/a/file
1116
```
1217

@@ -40,7 +45,7 @@ xdg-open _readthedocs/html/index.html
4045

4146
### markdown-it-py
4247

43-
```python
48+
``````python
4449
from markdown_it import MarkdownIt
4550
from sphinxcontrib.tree_sitter.mdit_py_plugin import tree_sitter_plugin
4651

@@ -51,4 +56,4 @@ def f():
5156
print("Hello")
5257
```
5358
""")
54-
```
59+
``````

packages/sphinxcontrib-tree-sitter/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ homepage = "https://github.com/sphinx-contrib/tree-sitter-highlight"
1717

1818
[project.optional-dependencies]
1919
dev = [
20-
"myst-parser>=4",
2120
"pytest-cov>=7.1.0",
21+
]
22+
docs = [
23+
"furo>=2025.12.19",
24+
"myst-parser>=4",
2225
"tree-sitter-bash>=0.25",
2326
"tree-sitter-comment>=0.3.0",
2427
"tree-sitter-lua>=0.5.0",

0 commit comments

Comments
 (0)