Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: loggers and dot graphs #305

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python: ["3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, macos-13, windows-latest]
runs-on: ${{matrix.os}}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
uses: pypa/[email protected]
env:
CIBW_ARCHS: ${{matrix.cibw_arch}}
CIBW_SKIP: pp*
CIBW_SKIP: "pp* *-musllinux_aarch64"
CIBW_TEST_SKIP: "*-*linux_aarch64 *-macosx_x86_64 *-win_arm64"
- name: Upload wheels
uses: actions/upload-artifact@v4
Expand Down
13 changes: 9 additions & 4 deletions docs/classes/tree_sitter.Language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,31 @@ Language

.. autoclass:: tree_sitter.Language

.. versionchanged:: 0.23.0

The argument can now be a `capsule <https://docs.python.org/3/c-api/capsule.html>`_.

Methods
-------

.. automethod:: copy

.. versionadded:: 0.24.0
.. automethod:: field_id_for_name
.. automethod:: field_name_for_id
.. automethod:: id_for_node_kind
.. automethod:: lookahead_iterator
.. automethod:: next_state
.. automethod:: node_kind_for_id
.. automethod:: node_kind_is_named
.. automethod:: node_kind_is_supertype

.. versionadded:: 0.24.0
.. automethod:: node_kind_is_visible
.. automethod:: query

Special Methods
---------------

.. automethod:: __copy__

.. versionadded:: 0.24.0
.. automethod:: __eq__
.. automethod:: __hash__

Expand Down
13 changes: 13 additions & 0 deletions docs/classes/tree_sitter.LogType.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
LogType
=======

.. autoclass:: tree_sitter.LogType
:show-inheritance:

.. versionadded:: 0.24.0

Members
-------

.. autoattribute:: PARSE
.. autoattribute:: LEX
9 changes: 8 additions & 1 deletion docs/classes/tree_sitter.Node.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ Node
.. automethod:: child_by_field_name
.. automethod:: child_containing_descendant

.. versionadded:: 0.23.0
.. deprecated:: 0.24.0
Use :meth:`child_with_descendant` instead
.. automethod:: child_with_descendant

.. versionadded:: 0.24.0
.. automethod:: children_by_field_id
.. automethod:: children_by_field_name
.. automethod:: descendant_for_byte_range
.. automethod:: descendant_for_point_range
.. automethod:: edit
.. automethod:: field_name_for_child
.. automethod:: field_name_for_named_child

.. versionadded:: 0.24.0
.. automethod:: named_child
.. automethod:: named_descendant_for_byte_range
.. automethod:: named_descendant_for_point_range
Expand Down
8 changes: 5 additions & 3 deletions docs/classes/tree_sitter.Parser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ Parser
-------

.. automethod:: parse
.. automethod:: print_dot_graphs

.. versionchanged:: 0.23.0

No longer accepts a ``keep_text`` parameter.
.. versionadded:: 0.24.0
.. automethod:: reset

Attributes
----------

.. autoattribute:: included_ranges
.. autoattribute:: language
.. autoattribute:: logger

.. versionadded:: 0.24.0
.. autoattribute:: timeout_micros
48 changes: 0 additions & 48 deletions docs/classes/tree_sitter.Query.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,79 +25,31 @@ Query
.. important::

Predicates cannot be used if the tree was parsed from a callback.

.. versionchanged:: 0.23.0

Range arguments removed, :class:`predicate <QueryPredicate>` argument added,
return type changed to ``dict[str, list[Node]]``.
.. automethod:: disable_capture

.. versionadded:: 0.23.0
.. automethod:: disable_pattern

.. versionadded:: 0.23.0
.. automethod:: end_byte_for_pattern

.. versionadded:: 0.23.0
.. automethod:: is_pattern_guaranteed_at_step

.. versionadded:: 0.23.0
.. automethod:: is_pattern_non_local

.. versionadded:: 0.23.0
.. automethod:: is_pattern_rooted

.. versionadded:: 0.23.0
.. automethod:: matches

.. important::

Predicates cannot be used if the tree was parsed from a callback.

.. versionchanged:: 0.23.0

Range arguments removed, :class:`predicate <QueryPredicate>` argument added,
return type changed to ``list[tuple[int, dict[str, list[Node]]]]``.
.. automethod:: pattern_assertions

.. versionadded:: 0.23.0
.. automethod:: pattern_settings

.. versionadded:: 0.23.0
.. automethod:: set_byte_range

.. versionadded:: 0.23.0
.. automethod:: set_point_range

.. versionadded:: 0.23.0
.. automethod:: start_byte_for_pattern

.. versionadded:: 0.23.0
.. automethod:: set_match_limit

.. versionadded:: 0.23.0
.. automethod:: set_max_start_depth

.. versionadded:: 0.23.0
.. automethod:: set_timeout_micros

.. versionadded:: 0.23.1

Attributes
----------

.. autoattribute:: capture_count

.. versionadded:: 0.23.0
.. autoattribute:: did_exceed_match_limit

.. versionadded:: 0.23.0
.. autoattribute:: match_limit

.. versionadded:: 0.23.0
.. autoattribute:: pattern_count

.. versionadded:: 0.23.0
.. autoattribute:: timeout_micros

.. versionadded:: 0.23.1
2 changes: 0 additions & 2 deletions docs/classes/tree_sitter.QueryError.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ QueryError

.. autoclass:: tree_sitter.QueryError
:show-inheritance:

.. versionadded:: 0.23.0
2 changes: 0 additions & 2 deletions docs/classes/tree_sitter.QueryPredicate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ QueryPredicate
.. autoclass:: tree_sitter.QueryPredicate
:show-inheritance:

.. versionadded:: 0.23.0

Special Methods
---------------

Expand Down
15 changes: 13 additions & 2 deletions docs/classes/tree_sitter.Tree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@ Tree
-------

.. automethod:: changed_ranges
.. automethod:: copy

.. versionadded:: 0.24.0
.. automethod:: edit
.. automethod:: print_dot_graph

.. versionadded:: 0.24.0
.. automethod:: root_node_with_offset
.. automethod:: walk

Special Methods
---------------

.. automethod:: __copy__

.. versionadded:: 0.24.0

Attributes
----------

.. autoattribute:: included_ranges
.. autoattribute:: language

.. versionadded:: 0.23.0
.. autoattribute:: root_node
8 changes: 0 additions & 8 deletions docs/classes/tree_sitter.TreeCursor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ TreeCursor
.. automethod:: goto_descendant
.. automethod:: goto_first_child
.. automethod:: goto_first_child_for_byte

.. versionchanged:: 0.23.0

Returns the child index instead of a `bool`.
.. automethod:: goto_first_child_for_point

.. versionchanged:: 0.23.0

Returns the child index instead of a `bool`.
.. automethod:: goto_last_child
.. automethod:: goto_next_sibling
.. automethod:: goto_parent
Expand Down
14 changes: 10 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
"sphinx.ext.intersphinx",
"sphinx.ext.githubpages",
]
source_suffix = ".rst"
source_suffix = {
".rst": "restructuredtext"
}
master_doc = "index"
language = "en"
needs_sphinx = "7.3"
needs_sphinx = "7.4"
templates_path = ["_templates"]

intersphinx_mapping = {
"python": ("https://docs.python.org/3.9/", None),
"python": ("https://docs.python.org/3.10/", None),
}

autoclass_content = "class"
Expand Down Expand Up @@ -54,7 +56,7 @@
html_favicon = "_static/favicon.png"


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


def process_signature(_app, _what, name, _obj, _options, _signature, return_annotation):
Expand All @@ -68,6 +70,8 @@ def process_signature(_app, _what, name, _obj, _options, _signature, return_anno
return "(start_point, end_point, start_byte, end_byte)", return_annotation
if name == "tree_sitter.QueryPredicate":
return None, return_annotation
if name == "tree_sitter.LogType":
return None, return_annotation


def process_docstring(_app, what, name, _obj, _options, lines):
Expand All @@ -83,6 +87,8 @@ def process_docstring(_app, what, name, _obj, _options, lines):
def process_bases(_app, name, _obj, _options, bases):
if name == "tree_sitter.Point":
bases[-1] = ":class:`~typing.NamedTuple`"
if name == "tree_sitter.LogType":
bases[-1] = ":class:`~enum.IntEnum`"
if name == "tree_sitter.LookaheadIterator":
bases[-1] = ":class:`~collections.abc.Iterator`"

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Classes
:nosignatures:

tree_sitter.Language
tree_sitter.LogType
tree_sitter.LookaheadIterator
tree_sitter.Node
tree_sitter.Parser
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
"Topic :: Text Processing :: Linguistic",
"Typing :: Typed",
]
requires-python = ">=3.9"
requires-python = ">=3.10"
readme = "README.md"

[project.urls]
Expand All @@ -30,7 +30,7 @@ name = "Max Brunsfeld"
email = "[email protected]"

[project.optional-dependencies]
docs = ["sphinx~=7.3", "sphinx-book-theme"]
docs = ["sphinx~=7.4", "sphinx-book-theme"]
tests = [
"tree-sitter-html>=0.23.0",
"tree-sitter-javascript>=0.23.0",
Expand All @@ -40,7 +40,7 @@ tests = [
]

[tool.ruff]
target-version = "py39"
target-version = "py310"
line-length = 100
indent-width = 4
extend-exclude = [
Expand Down
Loading
Loading