mkdocstrings-matlab 0.9.2__py3-none-any.whl → 0.9.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mkdocstrings_handlers/matlab/handler.py +9 -1
- mkdocstrings_handlers/matlab/treesitter.py +47 -18
- {mkdocstrings_matlab-0.9.2.dist-info → mkdocstrings_matlab-0.9.4.dist-info}/METADATA +2 -2
- {mkdocstrings_matlab-0.9.2.dist-info → mkdocstrings_matlab-0.9.4.dist-info}/RECORD +6 -6
- {mkdocstrings_matlab-0.9.2.dist-info → mkdocstrings_matlab-0.9.4.dist-info}/WHEEL +0 -0
- {mkdocstrings_matlab-0.9.2.dist-info → mkdocstrings_matlab-0.9.4.dist-info}/licenses/LICENSE +0 -0
@@ -358,7 +358,15 @@ class MatlabHandler(BaseHandler):
|
|
358
358
|
raise CollectionError("Empty identifier")
|
359
359
|
|
360
360
|
final_config = ChainMap(config, self.default_config) # type: ignore[arg-type]
|
361
|
-
|
361
|
+
try:
|
362
|
+
model = self.paths.resolve(identifier, config=final_config)
|
363
|
+
except SyntaxError as ex:
|
364
|
+
msg = str(ex)
|
365
|
+
if ex.text:
|
366
|
+
msg += ':\n' + ex.text
|
367
|
+
raise CollectionError(msg) from ex
|
368
|
+
except Exception as ex:
|
369
|
+
raise CollectionError(str(ex)) from ex
|
362
370
|
if model is None:
|
363
371
|
raise CollectionError(f"Identifier '{identifier}' not found")
|
364
372
|
return model
|
@@ -198,6 +198,7 @@ class FileParser(object):
|
|
198
198
|
self.encoding: str = result.encoding if result else "utf-8"
|
199
199
|
with open(filepath, "rb") as f:
|
200
200
|
self._content: bytes = f.read()
|
201
|
+
self._node: Node | None = None
|
201
202
|
|
202
203
|
@property
|
203
204
|
def content(self):
|
@@ -226,26 +227,38 @@ class FileParser(object):
|
|
226
227
|
Raises:
|
227
228
|
ValueError: If the file could not be parsed.
|
228
229
|
"""
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
230
|
+
try:
|
231
|
+
tree = PARSER.parse(self._content)
|
232
|
+
cursor = tree.walk()
|
233
|
+
|
234
|
+
if cursor.node is None:
|
235
|
+
raise ValueError(f"The file {self.filepath} could not be parsed.")
|
236
|
+
captures = FILE_QUERY.captures(cursor.node)
|
237
|
+
if "function" in captures:
|
238
|
+
model = self._parse_function(captures["function"][0], **kwargs)
|
239
|
+
elif "class" in captures:
|
240
|
+
model = self._parse_class(captures["class"][0], **kwargs)
|
241
|
+
else:
|
242
|
+
model = Script(self.filepath.stem, filepath=self.filepath, **kwargs)
|
242
243
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
244
|
+
if not model.docstring:
|
245
|
+
model.docstring = self._comment_docstring(
|
246
|
+
captures.get("header", None), parent=model
|
247
|
+
)
|
247
248
|
|
248
|
-
|
249
|
+
return model
|
250
|
+
except Exception as ex:
|
251
|
+
syntax_error = SyntaxError(f"Error parsing Matlab file")
|
252
|
+
syntax_error.filename = str(self.filepath)
|
253
|
+
if self._node is not None:
|
254
|
+
if self._node.text is not None:
|
255
|
+
indentation = ' ' * self._node.start_point.column
|
256
|
+
syntax_error.text = indentation + self._node.text.decode(self.encoding)
|
257
|
+
syntax_error.lineno = self._node.start_point.row + 1
|
258
|
+
syntax_error.offset = self._node.start_point.column + 1
|
259
|
+
syntax_error.end_lineno = self._node.end_point.row + 1
|
260
|
+
syntax_error.end_offset = self._node.end_point.column + 1
|
261
|
+
raise syntax_error from ex
|
249
262
|
|
250
263
|
def _parse_class(self, node: Node, **kwargs: Any) -> Class:
|
251
264
|
"""
|
@@ -262,6 +275,7 @@ class FileParser(object):
|
|
262
275
|
Returns:
|
263
276
|
Class: The parsed Class or Classfolder model.
|
264
277
|
"""
|
278
|
+
self._node = node
|
265
279
|
saved_kwargs = {key: value for key, value in kwargs.items()}
|
266
280
|
captures = CLASS_QUERY.captures(node)
|
267
281
|
|
@@ -401,6 +415,7 @@ class FileParser(object):
|
|
401
415
|
The value is `True` if no value is specified,
|
402
416
|
otherwise it is the parsed value which can be a boolean or a string.
|
403
417
|
"""
|
418
|
+
self._node = node
|
404
419
|
captures = ATTRIBUTE_QUERY.captures(node)
|
405
420
|
|
406
421
|
key = self._first_from_capture(captures, "name")
|
@@ -429,6 +444,7 @@ class FileParser(object):
|
|
429
444
|
KeyError: If required captures are missing from the node.
|
430
445
|
|
431
446
|
"""
|
447
|
+
self._node = node
|
432
448
|
captures: dict = FUNCTION_QUERY.matches(node)[0][1]
|
433
449
|
|
434
450
|
input_names = self._decode_from_capture(captures, "input")
|
@@ -529,6 +545,7 @@ class FileParser(object):
|
|
529
545
|
Returns:
|
530
546
|
str: The decoded text of the node. If the node or its text is None, returns an empty string.
|
531
547
|
"""
|
548
|
+
self._node = node
|
532
549
|
return (
|
533
550
|
node.text.decode(self.encoding)
|
534
551
|
if node is not None and node.text is not None
|
@@ -621,6 +638,18 @@ class FileParser(object):
|
|
621
638
|
except StopIteration:
|
622
639
|
break
|
623
640
|
|
641
|
+
# Exclude all pragma's
|
642
|
+
if line in [
|
643
|
+
'%#codegen',
|
644
|
+
'%#eml',
|
645
|
+
'%#external',
|
646
|
+
'%#exclude',
|
647
|
+
'%#function',
|
648
|
+
'%#ok',
|
649
|
+
'%#mex',
|
650
|
+
]:
|
651
|
+
continue
|
652
|
+
|
624
653
|
if "--8<--" in line:
|
625
654
|
continue
|
626
655
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mkdocstrings-matlab
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.4
|
4
4
|
Summary: A MATLAB handler for mkdocstrings
|
5
5
|
Author-email: Mark Hu <watermarkhu@gmail.com>
|
6
6
|
License: MIT
|
@@ -24,7 +24,7 @@ Requires-Python: >=3.10
|
|
24
24
|
Requires-Dist: charset-normalizer==3.4.1
|
25
25
|
Requires-Dist: mkdocstrings-python==1.13.0
|
26
26
|
Requires-Dist: mkdocstrings==0.27.0
|
27
|
-
Requires-Dist: tree-sitter-matlab==1.0.
|
27
|
+
Requires-Dist: tree-sitter-matlab==1.0.4
|
28
28
|
Requires-Dist: tree-sitter==0.24.0
|
29
29
|
Description-Content-Type: text/markdown
|
30
30
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
mkdocstrings_handlers/matlab/__init__.py,sha256=w5R9cGtqeJF0GUP_Jc_ad8FnS4FpbutnmHvzVRlohPM,1124
|
2
2
|
mkdocstrings_handlers/matlab/collect.py,sha256=6GkAwKor11Hm9QvKr6cKSHuylpoMF4Y3c8_myKiYOdE,29677
|
3
3
|
mkdocstrings_handlers/matlab/enums.py,sha256=Lzc8MLar-uMoKplT5LxF1lXNBfjHc9MCTe2b0mJMc10,1540
|
4
|
-
mkdocstrings_handlers/matlab/handler.py,sha256=
|
4
|
+
mkdocstrings_handlers/matlab/handler.py,sha256=TK3a19O-m668qtnf7r1bRRI9TVWm3vZf1LnOj1e8uQw,19988
|
5
5
|
mkdocstrings_handlers/matlab/models.py,sha256=2kMF7dyg5nPAzJt9G48IVtNAAq8K6xyKCBDDZHOBtUQ,19614
|
6
6
|
mkdocstrings_handlers/matlab/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
mkdocstrings_handlers/matlab/treesitter.py,sha256=
|
7
|
+
mkdocstrings_handlers/matlab/treesitter.py,sha256=lnpnwNOb22FvS7mykG3qs5rd5aPwvRJplHqOqC1vDbE,23526
|
8
8
|
mkdocstrings_handlers/matlab/templates/material/children.html.jinja,sha256=xF_J8afiIciWTP1GBhGAGWXe36wl0zJBKCwa2uDQFbU,7409
|
9
9
|
mkdocstrings_handlers/matlab/templates/material/folder.html.jinja,sha256=cWgaQH4EDFgL3eEIv0NRwRXYvtn9pp4tW7ntv3X2nM8,4076
|
10
10
|
mkdocstrings_handlers/matlab/templates/material/namespace.html.jinja,sha256=a7Ya3YuN3hNEvqb_aG5Yr3QCuFYv6UhX5B26Gx2-tUQ,4099
|
@@ -16,7 +16,7 @@ mkdocstrings_handlers/matlab/templates/material/docstring/namespaces.html.jinja,
|
|
16
16
|
mkdocstrings_handlers/matlab/templates/material/docstring/properties.html.jinja,sha256=9ckdYymLlB5sflwYEaEPAQLJuVWF8nezMCV5JnanXVA,4165
|
17
17
|
mkdocstrings_handlers/matlab/templates/material/summary/namespaces.html.jinja,sha256=0vVlUB6oh-A7cpXbuDLOQLxTubyb_DisdOKm062WNMs,650
|
18
18
|
mkdocstrings_handlers/matlab/templates/material/summary/properties.html.jinja,sha256=nyPaELf9qPCxJQFxK1MWYK4fPwsk5VESh9xKHLtd-XE,643
|
19
|
-
mkdocstrings_matlab-0.9.
|
20
|
-
mkdocstrings_matlab-0.9.
|
21
|
-
mkdocstrings_matlab-0.9.
|
22
|
-
mkdocstrings_matlab-0.9.
|
19
|
+
mkdocstrings_matlab-0.9.4.dist-info/METADATA,sha256=W9LPT-q7GNykt82svRB4X6B86mmm7b5GvNikRM2Jh6Y,4736
|
20
|
+
mkdocstrings_matlab-0.9.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
21
|
+
mkdocstrings_matlab-0.9.4.dist-info/licenses/LICENSE,sha256=TZQpwBuA3KLH56--XDAY2Qwo9gGdxeTITYhMOylmYhg,743
|
22
|
+
mkdocstrings_matlab-0.9.4.dist-info/RECORD,,
|
File without changes
|
{mkdocstrings_matlab-0.9.2.dist-info → mkdocstrings_matlab-0.9.4.dist-info}/licenses/LICENSE
RENAMED
File without changes
|