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

Tree-Sitter based parser. #261

Merged
merged 45 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c6d889f
[WIP] Work on writing a parser using the textmate grammar backend. …
apozharski Jul 18, 2024
b7bc006
Hack for object hierarchy
apozharski Jul 7, 2024
4e60a76
Initial hack to get enumerations to work
apozharski Jul 9, 2024
e5384da
better classdef parsing including changes to MATLAB-language-grammar …
apozharski Jul 19, 2024
fee6d03
parse function docstring
apozharski Jul 22, 2024
e75155f
extract function parser
apozharski Jul 22, 2024
597ab64
initial work
apozharski Jul 22, 2024
54899fb
finish integrating mat_textmate_parser with mat_types
apozharski Jul 23, 2024
3c8c18e
[skip-ci] some minor changes
apozharski Jul 24, 2024
bf1e6a2
initial work on a tree sitter based parser
apozharski Jul 24, 2024
3090fa5
nearly finished with tree-sitter implementation
apozharski Jul 25, 2024
b0d603e
everything but events working
apozharski Jul 27, 2024
f12b0a4
working events
apozharski Jul 27, 2024
522e690
exit early if query returns for block with no elements
apozharski Jul 27, 2024
1c07f16
integrating tree-sitter parser into mat_types
apozharski Jul 27, 2024
9f3297a
fixing default value parsing
apozharski Jul 27, 2024
c6d8f4a
some test fixes and requires tree-sitter
apozharski Aug 14, 2024
b349ea7
rm textmate parser on this branch
apozharski Aug 14, 2024
4c92632
also install tree-sitter
apozharski Aug 14, 2024
22f2779
bump required tree-sitter
apozharski Aug 14, 2024
c5b8d38
tree-sitter version bump
apozharski Aug 14, 2024
2c235f8
dealing with tree-sitter version diffs to maintain py 3.8 compatibility
apozharski Aug 14, 2024
2f36c14
ML_LANG versions
apozharski Aug 14, 2024
c55b5d1
a better attributes query
apozharski Aug 15, 2024
46c0e41
Ci: Test on Sphinx 8 / Dev. (#259)
joeced Jul 24, 2024
cf88ba4
Fixing nearly all tests in test_parse_mfile
apozharski Aug 15, 2024
e12307b
fix a _lot_ of autodoc
apozharski Aug 15, 2024
f1ea4f5
temporarily point to tree-sitter-matlab branch on apozharski fork
apozharski Aug 16, 2024
64b2ce2
fix old property syntax + update tests
apozharski Aug 16, 2024
a892a14
fixing test_autodoc and test_matlabify, only comment and line continu…
apozharski Aug 16, 2024
a2eae1b
fixing the last of the tests
apozharski Aug 19, 2024
3189e28
remove dead code
apozharski Aug 19, 2024
86b0fa6
address PR comments made by @joeced
apozharski Sep 5, 2024
d3b8ace
fix
apozharski Sep 5, 2024
ae5c357
lint
apozharski Sep 5, 2024
952af04
fix typo in __all__
apozharski Sep 5, 2024
d4e64f2
remove Pygments dependencies
apozharski Sep 5, 2024
7da1e65
py-tree-sitter v0.23.0 has a breaking change for Query.match()
apozharski Sep 5, 2024
a48c236
remove duplicat entry in yaml
apozharski Sep 5, 2024
1dfa6c7
fix spec printing
apozharski Sep 5, 2024
d182b9c
minor fixes for arg block parsing and a test
apozharski Sep 8, 2024
aa078e1
fix bug regarding output block argument parsing and add test
apozharski Sep 8, 2024
4b3fb89
remove print and fix test_matlabify
apozharski Sep 8, 2024
6314661
remove textmate from dev-reqs
apozharski Sep 8, 2024
63781e3
fix typo
apozharski Sep 18, 2024
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
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
with open("README.rst", "r") as f_readme:
long_desc = f_readme.read()

requires = ["Sphinx>=4.0.0", "Pygments>=2.0.1"]
requires = [
"Sphinx>=4.0.0",
"tree-sitter-matlab>=1.0.2",
"tree-sitter>=0.21.3,<0.23.0",
]

setup(
name="sphinxcontrib-matlabdomain",
Expand Down
45 changes: 38 additions & 7 deletions sphinxcontrib/mat_documenters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
MatFunction,
MatClass,
MatProperty,
MatEnumeration,
MatMethod,
MatScript,
MatException,
Expand Down Expand Up @@ -555,6 +556,9 @@ def member_is_friend_of(member, friends):
else:
return False

def member_is_enum(member):
return isinstance(member, MatEnumeration)

ret = []

# search for members in source code too
Expand Down Expand Up @@ -637,7 +641,7 @@ def member_is_friend_of(member, friends):
isattr = True
else:
# ignore undocumented members if :undoc-members: is not given
keep = has_doc or self.options.undoc_members
keep = has_doc or self.options.undoc_members or member_is_enum(member)

# give the user a chance to decide whether this member
# should be skipped
Expand All @@ -656,7 +660,6 @@ def member_is_friend_of(member, friends):

if keep:
ret.append((membername, member, isattr))

return ret

def document_members(self, all_members=False):
Expand Down Expand Up @@ -1229,11 +1232,19 @@ def document_members(self, all_members=False):
for (membername, member) in filtered_members
if isinstance(member, MatMethod) and member.name != member.cls.name
]
# create list of enums
enum_names = [
membername
for (membername, member) in filtered_members
if isinstance(member, MatEnumeration)
]
# create list of other members
other_names = [
membername
for (membername, member) in filtered_members
if not isinstance(member, MatMethod) and not isinstance(member, MatProperty)
if not isinstance(member, MatMethod)
and not isinstance(member, MatProperty)
and not isinstance(member, MatEnumeration)
# exclude parent modules with names matching members (as in Myclass.Myclass)
and not (hasattr(member, "module") and member.name == member.module)
]
Expand All @@ -1255,6 +1266,12 @@ def document_members(self, all_members=False):
for (membername, member) in members
if not isinstance(member, MatMethod) or member.name == member.cls.name
]
# create list of members that are not properties
non_enums = [
membername
for (membername, member) in members
if not isinstance(member, MatEnumeration)
]
# create list of members that are not non-constructor methods
non_other = [
membername
Expand All @@ -1281,6 +1298,10 @@ def document_members(self, all_members=False):
"Property Summary", non_properties, all_members
)

# enumss
if enum_names:
self.document_member_section("Enumeration Values", non_enums, all_members)

# methods
if meth_names:
self.document_member_section("Method Summary", non_methods, all_members)
Expand Down Expand Up @@ -1359,10 +1380,11 @@ def format_args(self):
is_ctor = self.object.cls.name == self.object.name

if self.object.args:
if self.object.args[0] in ("obj", "self") and not is_ctor:
return "(" + ", ".join(self.object.args[1:]) + ")"
arglist = list(self.object.args.keys())
if arglist[0] in ("obj", "self") and not is_ctor:
return "(" + ", ".join(arglist[1:]) + ")"
else:
return "(" + ", ".join(self.object.args) + ")"
return "(" + ", ".join(arglist) + ")"

def document_members(self, all_members=False):
pass
Expand Down Expand Up @@ -1453,7 +1475,16 @@ def add_directive_header(self, sig):
obj_default = " = " + obj_default

if self.env.config.matlab_show_property_specs:
obj_default = self.object.specs + obj_default
prop_spec = ""
if self.object.size is not None:
prop_spec = prop_spec + "(" + ",".join(self.object.size) + ")"
if self.object.type is not None:
prop_spec = prop_spec + " " + self.object.type
if self.object.validators is not None:
prop_spec = (
prop_spec + " {" + ",".join(self.object.validators) + "}"
)
obj_default = prop_spec + obj_default

self.add_line(" :annotation: " + obj_default, "<autodoc>")
elif self.options.annotation is SUPPRESS:
Expand Down
88 changes: 0 additions & 88 deletions sphinxcontrib/mat_parser.py

This file was deleted.

Loading
Loading