Skip to content

Commit 0c05091

Browse files
feat: implement missing methods
- Language.copy - Language.node_kind_is_supertype - Node.child_with_descendant - Node.field_name_for_named_child - Parser.logger - Parser.print_dot_graphs - Tree.copy - Tree.print_dot_graph
1 parent d16b54b commit 0c05091

25 files changed

+470
-196
lines changed

docs/classes/tree_sitter.Language.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,31 @@ Language
33

44
.. autoclass:: tree_sitter.Language
55

6-
.. versionchanged:: 0.23.0
7-
8-
The argument can now be a `capsule <https://docs.python.org/3/c-api/capsule.html>`_.
9-
106
Methods
117
-------
128

9+
.. automethod:: copy
10+
11+
.. versionadded:: 0.24.0
1312
.. automethod:: field_id_for_name
1413
.. automethod:: field_name_for_id
1514
.. automethod:: id_for_node_kind
1615
.. automethod:: lookahead_iterator
1716
.. automethod:: next_state
1817
.. automethod:: node_kind_for_id
1918
.. automethod:: node_kind_is_named
19+
.. automethod:: node_kind_is_supertype
20+
21+
.. versionadded:: 0.24.0
2022
.. automethod:: node_kind_is_visible
2123
.. automethod:: query
2224

2325
Special Methods
2426
---------------
2527

28+
.. automethod:: __copy__
29+
30+
.. versionadded:: 0.24.0
2631
.. automethod:: __eq__
2732
.. automethod:: __hash__
2833

docs/classes/tree_sitter.LogType.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
LogType
2+
=======
3+
4+
.. autoclass:: tree_sitter.LogType
5+
:show-inheritance:
6+
7+
.. versionadded:: 0.24.0
8+
9+
Members
10+
-------
11+
12+
.. autoattribute:: PARSE
13+
.. autoattribute:: LEX

docs/classes/tree_sitter.Node.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ Node
1111
.. automethod:: child_by_field_name
1212
.. automethod:: child_containing_descendant
1313

14-
.. versionadded:: 0.23.0
14+
.. deprecated:: 0.24.0
15+
Use :meth:`child_with_descendant` instead
16+
.. automethod:: child_with_descendant
17+
18+
.. versionadded:: 0.24.0
1519
.. automethod:: children_by_field_id
1620
.. automethod:: children_by_field_name
1721
.. automethod:: descendant_for_byte_range
1822
.. automethod:: descendant_for_point_range
1923
.. automethod:: edit
2024
.. automethod:: field_name_for_child
25+
.. automethod:: field_name_for_named_child
26+
27+
.. versionadded:: 0.24.0
2128
.. automethod:: named_child
2229
.. automethod:: named_descendant_for_byte_range
2330
.. automethod:: named_descendant_for_point_range

docs/classes/tree_sitter.Parser.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ Parser
77
-------
88

99
.. automethod:: parse
10+
.. automethod:: print_dot_graphs
1011

11-
.. versionchanged:: 0.23.0
12-
13-
No longer accepts a ``keep_text`` parameter.
12+
.. versionadded:: 0.24.0
1413
.. automethod:: reset
1514

1615
Attributes
1716
----------
1817

1918
.. autoattribute:: included_ranges
2019
.. autoattribute:: language
20+
.. autoattribute:: logger
21+
22+
.. versionadded:: 0.24.0
2123
.. autoattribute:: timeout_micros

docs/classes/tree_sitter.Query.rst

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,79 +25,31 @@ Query
2525
.. important::
2626

2727
Predicates cannot be used if the tree was parsed from a callback.
28-
29-
.. versionchanged:: 0.23.0
30-
31-
Range arguments removed, :class:`predicate <QueryPredicate>` argument added,
32-
return type changed to ``dict[str, list[Node]]``.
3328
.. automethod:: disable_capture
34-
35-
.. versionadded:: 0.23.0
3629
.. automethod:: disable_pattern
37-
38-
.. versionadded:: 0.23.0
3930
.. automethod:: end_byte_for_pattern
40-
41-
.. versionadded:: 0.23.0
4231
.. automethod:: is_pattern_guaranteed_at_step
43-
44-
.. versionadded:: 0.23.0
4532
.. automethod:: is_pattern_non_local
46-
47-
.. versionadded:: 0.23.0
4833
.. automethod:: is_pattern_rooted
49-
50-
.. versionadded:: 0.23.0
5134
.. automethod:: matches
5235

5336
.. important::
5437

5538
Predicates cannot be used if the tree was parsed from a callback.
56-
57-
.. versionchanged:: 0.23.0
58-
59-
Range arguments removed, :class:`predicate <QueryPredicate>` argument added,
60-
return type changed to ``list[tuple[int, dict[str, list[Node]]]]``.
6139
.. automethod:: pattern_assertions
62-
63-
.. versionadded:: 0.23.0
6440
.. automethod:: pattern_settings
65-
66-
.. versionadded:: 0.23.0
6741
.. automethod:: set_byte_range
68-
69-
.. versionadded:: 0.23.0
7042
.. automethod:: set_point_range
71-
72-
.. versionadded:: 0.23.0
7343
.. automethod:: start_byte_for_pattern
74-
75-
.. versionadded:: 0.23.0
7644
.. automethod:: set_match_limit
77-
78-
.. versionadded:: 0.23.0
7945
.. automethod:: set_max_start_depth
80-
81-
.. versionadded:: 0.23.0
8246
.. automethod:: set_timeout_micros
8347

84-
.. versionadded:: 0.23.1
85-
8648
Attributes
8749
----------
8850

8951
.. autoattribute:: capture_count
90-
91-
.. versionadded:: 0.23.0
9252
.. autoattribute:: did_exceed_match_limit
93-
94-
.. versionadded:: 0.23.0
9553
.. autoattribute:: match_limit
96-
97-
.. versionadded:: 0.23.0
9854
.. autoattribute:: pattern_count
99-
100-
.. versionadded:: 0.23.0
10155
.. autoattribute:: timeout_micros
102-
103-
.. versionadded:: 0.23.1

docs/classes/tree_sitter.QueryError.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ QueryError
33

44
.. autoclass:: tree_sitter.QueryError
55
:show-inheritance:
6-
7-
.. versionadded:: 0.23.0

docs/classes/tree_sitter.QueryPredicate.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ QueryPredicate
44
.. autoclass:: tree_sitter.QueryPredicate
55
:show-inheritance:
66

7-
.. versionadded:: 0.23.0
8-
97
Special Methods
108
---------------
119

docs/classes/tree_sitter.Tree.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,26 @@ Tree
77
-------
88

99
.. automethod:: changed_ranges
10+
.. automethod:: copy
11+
12+
.. versionadded:: 0.24.0
1013
.. automethod:: edit
14+
.. automethod:: print_dot_graph
15+
16+
.. versionadded:: 0.24.0
1117
.. automethod:: root_node_with_offset
1218
.. automethod:: walk
1319

20+
Special Methods
21+
---------------
22+
23+
.. automethod:: __copy__
24+
25+
.. versionadded:: 0.24.0
26+
1427
Attributes
1528
----------
1629

1730
.. autoattribute:: included_ranges
1831
.. autoattribute:: language
19-
20-
.. versionadded:: 0.23.0
2132
.. autoattribute:: root_node

docs/classes/tree_sitter.TreeCursor.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@ TreeCursor
1010
.. automethod:: goto_descendant
1111
.. automethod:: goto_first_child
1212
.. automethod:: goto_first_child_for_byte
13-
14-
.. versionchanged:: 0.23.0
15-
16-
Returns the child index instead of a `bool`.
1713
.. automethod:: goto_first_child_for_point
18-
19-
.. versionchanged:: 0.23.0
20-
21-
Returns the child index instead of a `bool`.
2214
.. automethod:: goto_last_child
2315
.. automethod:: goto_next_sibling
2416
.. automethod:: goto_parent

docs/conf.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717
"sphinx.ext.intersphinx",
1818
"sphinx.ext.githubpages",
1919
]
20-
source_suffix = ".rst"
20+
source_suffix = {
21+
".rst": "restructuredtext"
22+
}
2123
master_doc = "index"
2224
language = "en"
23-
needs_sphinx = "7.3"
25+
needs_sphinx = "7.4"
2426
templates_path = ["_templates"]
2527

2628
intersphinx_mapping = {
27-
"python": ("https://docs.python.org/3.9/", None),
29+
"python": ("https://docs.python.org/3.10/", None),
2830
}
2931

3032
autoclass_content = "class"
@@ -54,7 +56,7 @@
5456
html_favicon = "_static/favicon.png"
5557

5658

57-
special_doc = regex("\S*self[^.]+")
59+
special_doc = regex(r"\S*self[^.]+")
5860

5961

6062
def process_signature(_app, _what, name, _obj, _options, _signature, return_annotation):
@@ -68,6 +70,8 @@ def process_signature(_app, _what, name, _obj, _options, _signature, return_anno
6870
return "(start_point, end_point, start_byte, end_byte)", return_annotation
6971
if name == "tree_sitter.QueryPredicate":
7072
return None, return_annotation
73+
if name == "tree_sitter.LogType":
74+
return None, return_annotation
7175

7276

7377
def process_docstring(_app, what, name, _obj, _options, lines):
@@ -83,6 +87,8 @@ def process_docstring(_app, what, name, _obj, _options, lines):
8387
def process_bases(_app, name, _obj, _options, bases):
8488
if name == "tree_sitter.Point":
8589
bases[-1] = ":class:`~typing.NamedTuple`"
90+
if name == "tree_sitter.LogType":
91+
bases[-1] = ":class:`~enum.IntEnum`"
8692
if name == "tree_sitter.LookaheadIterator":
8793
bases[-1] = ":class:`~collections.abc.Iterator`"
8894

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Classes
3030
:nosignatures:
3131

3232
tree_sitter.Language
33+
tree_sitter.LogType
3334
tree_sitter.LookaheadIterator
3435
tree_sitter.Node
3536
tree_sitter.Parser

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ name = "Max Brunsfeld"
3030
email = "maxbrunsfeld@gmail.com"
3131

3232
[project.optional-dependencies]
33-
docs = ["sphinx~=7.3", "sphinx-book-theme"]
33+
docs = ["sphinx~=7.4", "sphinx-book-theme"]
3434
tests = [
3535
"tree-sitter-html>=0.23.0",
3636
"tree-sitter-javascript>=0.23.0",

0 commit comments

Comments
 (0)