mkdocstrings-matlab 0.9.4__tar.gz → 0.9.6__tar.gz

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.
Files changed (91) hide show
  1. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/CHANGELOG.md +24 -0
  2. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/PKG-INFO +2 -2
  3. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/usage/configuration/headings.md +5 -3
  4. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/pyproject.toml +2 -2
  5. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/scripts/copy_and_update_python_templates.py +3 -2
  6. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/__init__.py +4 -3
  7. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/collect.py +8 -11
  8. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/enums.py +1 -1
  9. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/handler.py +8 -8
  10. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/models.py +10 -4
  11. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/treesitter.py +71 -56
  12. mkdocstrings_matlab-0.9.6/test/playground.py +7 -0
  13. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/.github/CODEOWNERS +0 -0
  14. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/.github/workflows/docs.yaml +0 -0
  15. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/.github/workflows/qualify.yaml +0 -0
  16. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/.github/workflows/release.yaml +0 -0
  17. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/.github/workflows/update-templates.yaml +0 -0
  18. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/.gitignore +0 -0
  19. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/.python-version +0 -0
  20. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/.vscode/launch.json +0 -0
  21. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/.vscode/settings.json +0 -0
  22. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/LICENSE +0 -0
  23. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/README.md +0 -0
  24. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/api.md +0 -0
  25. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/changelog.md +0 -0
  26. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/credits.md +0 -0
  27. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/debug.py +2 -2
  28. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/img/preview_dark.png +0 -0
  29. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/img/preview_light.png +0 -0
  30. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/index.md +0 -0
  31. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/license.md +0 -0
  32. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/logo.png +0 -0
  33. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/logo.svg +0 -0
  34. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/overrides/main.html +0 -0
  35. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/overrides/partials/toc-item.html +0 -0
  36. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+module/+submodule/Contents.m +0 -0
  37. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+module/+submodule/subfunction.m +0 -0
  38. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+module/aClass.m +0 -0
  39. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+module/do_something.m +0 -0
  40. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+module/module.md +0 -0
  41. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+module/readme.md +0 -0
  42. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mymembers/BaseClass.m +0 -0
  43. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mymembers/Contents.m +0 -0
  44. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mymembers/ThisClass.m +0 -0
  45. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mymembers/mymembers.md +0 -0
  46. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mymembers/this_function.m +0 -0
  47. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mynamespace/classA.m +0 -0
  48. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mynamespace/classB.m +0 -0
  49. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mynamespace/mynamespace.md +0 -0
  50. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mynamespace/myscript.m +0 -0
  51. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mynamespace/readme.md +0 -0
  52. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+mynamespace/typed_function.m +0 -0
  53. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+undocumented/ClassWithoutDocstring.m +0 -0
  54. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+undocumented/function_with_docstring.m +0 -0
  55. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+undocumented/function_without_docstring.m +0 -0
  56. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/+undocumented/undocumented.md +0 -0
  57. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/Class.m +0 -0
  58. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/OtherClass.m +0 -0
  59. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/Thing.m +0 -0
  60. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/do_output.m +0 -0
  61. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/do_something.m +0 -0
  62. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/do_varargin.m +0 -0
  63. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/myClass.m +0 -0
  64. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/myParent.m +0 -0
  65. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/myfunction.m +0 -0
  66. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/snippets/print_hello.m +0 -0
  67. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/stylesheets/extra.css +0 -0
  68. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/usage/configuration/docstrings.md +0 -0
  69. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/usage/configuration/general.md +0 -0
  70. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/usage/configuration/members.md +0 -0
  71. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/usage/configuration/signatures.md +0 -0
  72. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/usage/docstrings/google.md +0 -0
  73. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/usage/docstrings/numpy.md +0 -0
  74. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/usage/docstrings/sphinx.md +0 -0
  75. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/docs/usage/index.md +0 -0
  76. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/logo.svg +0 -0
  77. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/mkdocs.yml +0 -0
  78. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/renovate.json +0 -0
  79. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/requirements.lock +0 -0
  80. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/py.typed +0 -0
  81. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/children.html.jinja +0 -0
  82. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/docstring/namespaces.html.jinja +0 -0
  83. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/docstring/properties.html.jinja +0 -0
  84. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/folder.html.jinja +0 -0
  85. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/namespace.html.jinja +0 -0
  86. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/property.html.jinja +0 -0
  87. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/script.html.jinja +0 -0
  88. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/style.css +0 -0
  89. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/summary/namespaces.html.jinja +0 -0
  90. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/summary/properties.html.jinja +0 -0
  91. {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.6}/src/mkdocstrings_handlers/matlab/templates/material/summary.html.jinja +0 -0
@@ -1,6 +1,30 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v0.9.6 (2025-02-14)
5
+
6
+ ### Bug Fixes
7
+
8
+ - **deps**: Update dependency mkdocstrings to v0.28.0
9
+ ([#70](https://github.com/watermarkhu/mkdocstrings-matlab/pull/70),
10
+ [`5b512ab`](https://github.com/watermarkhu/mkdocstrings-matlab/commit/5b512abd5656187ad888f5edf4a99aa9bff24141))
11
+
12
+ Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
13
+
14
+
15
+ ## v0.9.5 (2025-02-02)
16
+
17
+ ### Bug Fixes
18
+
19
+ - Handle line continuations gracefully
20
+ ([#68](https://github.com/watermarkhu/mkdocstrings-matlab/pull/68),
21
+ [`8a32df0`](https://github.com/watermarkhu/mkdocstrings-matlab/commit/8a32df08f7ae8c4356db186e55d1ecdd3d537850))
22
+
23
+ * handle line continuations gracefully
24
+
25
+ * Update headings.md
26
+
27
+
4
28
  ## v0.9.4 (2025-02-01)
5
29
 
6
30
  ### Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocstrings-matlab
3
- Version: 0.9.4
3
+ Version: 0.9.6
4
4
  Summary: A MATLAB handler for mkdocstrings
5
5
  Author-email: Mark Hu <watermarkhu@gmail.com>
6
6
  License: MIT
@@ -23,7 +23,7 @@ Classifier: Typing :: Typed
23
23
  Requires-Python: >=3.10
24
24
  Requires-Dist: charset-normalizer==3.4.1
25
25
  Requires-Dist: mkdocstrings-python==1.13.0
26
- Requires-Dist: mkdocstrings==0.27.0
26
+ Requires-Dist: mkdocstrings==0.28.0
27
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
@@ -521,11 +521,13 @@ plugins:
521
521
  Show the symbol type in headings.
522
522
 
523
523
  This option will prefix headings with
524
- <code class="doc-symbol doc-symbol-attribute"></code>,
524
+ <code class="doc-symbol doc-symbol-property"></code>,
525
525
  <code class="doc-symbol doc-symbol-function"></code>,
526
526
  <code class="doc-symbol doc-symbol-method"></code>,
527
- <code class="doc-symbol doc-symbol-class"></code> or
528
- <code class="doc-symbol doc-symbol-module"></code> types.
527
+ <code class="doc-symbol doc-symbol-class"></code>,
528
+ <code class="doc-symbol doc-symbol-script"></code>,
529
+ <code class="doc-symbol doc-symbol-namespace"></code> or.
530
+ <code class="doc-symbol doc-symbol-folder"></code> types.
529
531
  See also [`show_symbol_type_toc`][show_symbol_type_toc].
530
532
 
531
533
  ```yaml title="in mkdocs.yml (global configuration)"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mkdocstrings-matlab"
3
- version = "0.9.4"
3
+ version = "0.9.6"
4
4
  description = "A MATLAB handler for mkdocstrings"
5
5
  authors = [
6
6
  { name = "Mark Hu", email = "watermarkhu@gmail.com" }
@@ -9,7 +9,7 @@ license = { text = "MIT" }
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  dependencies = [
12
- "mkdocstrings==0.27.0",
12
+ "mkdocstrings==0.28.0",
13
13
  "mkdocstrings-python==1.13.0",
14
14
  "charset-normalizer==3.4.1",
15
15
  "tree-sitter==0.24.0",
@@ -1,9 +1,10 @@
1
1
  """A script to copy the modules and attributes templates from
2
2
  the python handler to the matlab handler and update the names"""
3
3
 
4
- from mkdocstrings_handlers.python.handler import PythonHandler
5
- from pathlib import Path
6
4
  import re
5
+ from pathlib import Path
6
+
7
+ from mkdocstrings_handlers.python.handler import PythonHandler
7
8
 
8
9
  # Get the templates directory of the python handler
9
10
  pythonHandler = PythonHandler("python", "material")
@@ -1,9 +1,10 @@
1
1
  """MATLAB handler for mkdocstrings."""
2
2
 
3
- from mkdocstrings_handlers.matlab.handler import get_handler
4
- from mkdocstrings_handlers.matlab import collect, handler, models, treesitter
3
+ from _griffe.docstrings import google, numpy
5
4
  from _griffe.enumerations import DocstringSectionKind
6
- from _griffe.docstrings import numpy, google
5
+
6
+ from mkdocstrings_handlers.matlab import collect, handler, models, treesitter
7
+ from mkdocstrings_handlers.matlab.handler import get_handler
7
8
 
8
9
  __all__ = ["get_handler", "collect", "handler", "models", "treesitter"]
9
10
 
@@ -3,35 +3,35 @@
3
3
  from collections import defaultdict, deque
4
4
  from copy import copy, deepcopy
5
5
  from pathlib import Path
6
- from typing import Any, Mapping, Sequence, Callable, TypeVar
6
+ from typing import Any, Callable, Mapping, Sequence, TypeVar
7
7
 
8
- from _griffe.collections import LinesCollection as GLC, ModulesCollection
8
+ from _griffe.collections import LinesCollection as GLC
9
+ from _griffe.collections import ModulesCollection
9
10
  from _griffe.docstrings.models import (
11
+ DocstringParameter,
12
+ DocstringReturn,
10
13
  DocstringSectionOtherParameters,
11
14
  DocstringSectionParameters,
12
15
  DocstringSectionReturns,
13
- DocstringParameter,
14
- DocstringReturn,
15
16
  )
16
17
  from _griffe.enumerations import DocstringSectionKind
17
18
  from _griffe.expressions import Expr
18
19
 
19
20
  from mkdocstrings_handlers.matlab.enums import ParameterKind
20
21
  from mkdocstrings_handlers.matlab.models import (
21
- _ParentGrabber,
22
22
  Class,
23
23
  Classfolder,
24
24
  Docstring,
25
25
  DocstringSectionText,
26
- Function,
27
26
  Folder,
27
+ Function,
28
28
  MatlabMixin,
29
29
  Namespace,
30
30
  PathMixin,
31
+ _ParentGrabber,
31
32
  )
32
33
  from mkdocstrings_handlers.matlab.treesitter import FileParser
33
34
 
34
-
35
35
  PathType = TypeVar("PathType", bound=PathMixin)
36
36
 
37
37
  __all__ = ["LinesCollection", "PathCollection"]
@@ -198,7 +198,6 @@ class PathCollection(ModulesCollection):
198
198
  elif self._config_path is not None and "/" in identifier:
199
199
  absolute_path = (self._config_path / Path(identifier)).resolve()
200
200
  if absolute_path.exists():
201
-
202
201
  if absolute_path.suffix:
203
202
  path, member = absolute_path.parent, absolute_path.stem
204
203
  else:
@@ -549,9 +548,7 @@ class PathCollection(ModulesCollection):
549
548
  ]:
550
549
  if member.parent.is_relative_to(self._config_path):
551
550
  if member.parent not in self._folders:
552
- self._folders[member.parent] = LazyModel(
553
- member.parent, self
554
- )
551
+ self._folders[member.parent] = LazyModel(member.parent, self)
555
552
  else:
556
553
  pass # TODO: Issue warning?
557
554
 
@@ -1,5 +1,4 @@
1
1
  from enum import Enum
2
- from _griffe.enumerations import Kind as GriffeKind
3
2
 
4
3
 
5
4
  class Kind(str, Enum):
@@ -7,6 +6,7 @@ class Kind(str, Enum):
7
6
  An enumeration representing different kinds of MATLAB code elements.
8
7
  This enumeration is a subclass of the Griffe `Kind` enumeration, and extends it with additional values.
9
8
  """
9
+
10
10
  MODULE = "module"
11
11
  """Modules."""
12
12
  CLASS = "class"
@@ -1,18 +1,18 @@
1
1
  """The mkdocstrings handler for processing MATLAB code documentation."""
2
2
 
3
- from pathlib import Path
3
+ import re
4
4
  from collections import ChainMap
5
+ from pathlib import Path
6
+ from pprint import pprint
7
+ from typing import Any, ClassVar, Mapping
8
+
5
9
  from jinja2.loaders import FileSystemLoader
6
10
  from markdown import Markdown
7
11
  from mkdocs.exceptions import PluginError
8
- from mkdocstrings.handlers.base import BaseHandler, CollectorItem, CollectionError
9
- from mkdocstrings_handlers.python import rendering
10
- from typing import Any, ClassVar, Mapping
11
- from pprint import pprint
12
-
13
- import re
12
+ from mkdocstrings.handlers.base import BaseHandler, CollectionError, CollectorItem
14
13
 
15
14
  from mkdocstrings_handlers.matlab.collect import LinesCollection, PathCollection
15
+ from mkdocstrings_handlers.python import rendering
16
16
 
17
17
 
18
18
  class MatlabHandler(BaseHandler):
@@ -363,7 +363,7 @@ class MatlabHandler(BaseHandler):
363
363
  except SyntaxError as ex:
364
364
  msg = str(ex)
365
365
  if ex.text:
366
- msg += ':\n' + ex.text
366
+ msg += ":\n" + ex.text
367
367
  raise CollectionError(msg) from ex
368
368
  except Exception as ex:
369
369
  raise CollectionError(str(ex)) from ex
@@ -153,12 +153,16 @@ class MatlabObject(Object):
153
153
 
154
154
  @property
155
155
  def scripts(self) -> dict[str, "Script"]:
156
- return {name: member for name, member in self.all_members.items() if member.kind is Kind.SCRIPT} # type: ignore[misc]
156
+ return {
157
+ name: member
158
+ for name, member in self.all_members.items()
159
+ if member.kind is Kind.SCRIPT
160
+ } # type: ignore[misc]
157
161
 
158
162
  @property
159
163
  def is_script(self) -> bool:
160
164
  return False
161
-
165
+
162
166
  @property
163
167
  def is_namespace(self) -> bool:
164
168
  return False
@@ -288,7 +292,8 @@ class Script(MatlabMixin, PathMixin, MatlabObject):
288
292
  This class inherits from `PathMixin` and `MatlabObject` to provide
289
293
  functionality specific to MATLAB scripts.
290
294
  """
291
- kind = Kind.SCRIPT # type: ignore
295
+
296
+ kind = Kind.SCRIPT # type: ignore
292
297
 
293
298
  def __init__(self, *args: Any, **kwargs: Any) -> None:
294
299
  super().__init__(*args, **kwargs)
@@ -298,6 +303,7 @@ class Script(MatlabMixin, PathMixin, MatlabObject):
298
303
  def is_script(self) -> bool:
299
304
  return True
300
305
 
306
+
301
307
  class Class(MatlabMixin, PathMixin, GriffeClass, MatlabObject):
302
308
  """
303
309
  Represents a MATLAB class with additional properties and methods for handling
@@ -458,7 +464,7 @@ class Property(MatlabMixin, Attribute, MatlabObject):
458
464
  private = self.Access != AccessEnum.public
459
465
  get_private = self.GetAccess != AccessEnum.public
460
466
  return private or get_private
461
-
467
+
462
468
  @property
463
469
  def is_private(self) -> bool:
464
470
  return self.Private or self.Hidden
@@ -1,15 +1,15 @@
1
1
  """Tree-sitter queries to extract information from MATLAB files."""
2
2
 
3
+ import textwrap
3
4
  from collections import OrderedDict
4
- from typing import Any
5
-
6
- from tree_sitter import Language, Parser, Node
7
- import tree_sitter_matlab as tsmatlab
8
-
9
5
  from pathlib import Path
6
+ from typing import Any
10
7
 
11
8
  import charset_normalizer
9
+ import tree_sitter_matlab as tsmatlab
10
+ from tree_sitter import Language, Node, Parser
12
11
 
12
+ from mkdocstrings_handlers.matlab.enums import ParameterKind
13
13
  from mkdocstrings_handlers.matlab.models import (
14
14
  AccessEnum,
15
15
  Class,
@@ -17,13 +17,11 @@ from mkdocstrings_handlers.matlab.models import (
17
17
  Docstring,
18
18
  Function,
19
19
  MatlabMixin,
20
- Parameters,
21
20
  Parameter,
21
+ Parameters,
22
22
  Property,
23
23
  Script,
24
24
  )
25
- from mkdocstrings_handlers.matlab.enums import ParameterKind
26
-
27
25
 
28
26
  __all__ = ["FileParser"]
29
27
 
@@ -32,44 +30,52 @@ LANGUAGE = Language(tsmatlab.language())
32
30
 
33
31
  PARSER = Parser(LANGUAGE)
34
32
 
35
- FILE_QUERY = LANGUAGE.query("""(source_file
33
+ FILE_QUERY = LANGUAGE.query("""(source_file .
36
34
  (comment)* @header .
37
- (function_definition)? @function .
38
- (class_definition)? @class
35
+ [
36
+ (function_definition) @function
37
+ (class_definition) @class
38
+ ]?
39
39
  )
40
40
  """)
41
41
 
42
42
 
43
43
  FUNCTION_QUERY = LANGUAGE.query("""(function_definition .
44
- ("function") .
44
+ ("function")
45
45
  (function_output .
46
46
  [
47
47
  (identifier) @output
48
48
  (multioutput_variable .
49
- ((identifier) @output (",")?)*
49
+ [
50
+ (identifier) @output
51
+ _
52
+ ]*
50
53
  )
51
54
  ]
52
- )? .
55
+ )?
53
56
  [
54
57
  ("set.") @setter
55
58
  ("get.") @getter
56
- ]? .
57
- (identifier) @name .
59
+ ]?
60
+ (identifier) @name
58
61
  (function_arguments .
59
- ((identifier) @input (",")?)*
60
- )? .
61
- (comment)* @docstring .
62
+ [
63
+ (identifier) @input
64
+ _
65
+ ]*
66
+ )?
67
+ (comment)* @docstring
62
68
  (arguments_statement)* @arguments
63
69
  )""")
64
70
 
65
71
 
66
72
  ARGUMENTS_QUERY = LANGUAGE.query("""(arguments_statement .
67
- ("arguments") .
73
+ ("arguments")
68
74
  (attributes
69
75
  (identifier) @attributes
70
- )? .
71
- (comment)? .
72
- ("\\n")? .
76
+ )?
77
+ (comment)?
78
+ ("\\n")?
73
79
  (property)+ @arguments
74
80
  )""")
75
81
 
@@ -82,22 +88,22 @@ PROPERTY_QUERY = LANGUAGE.query("""(property .
82
88
  (".") .
83
89
  (identifier) @name
84
90
  )
85
- ] .
86
- (dimensions)? @dimensions .
87
- (identifier)? @class .
88
- (validation_functions)? @validators .
91
+ ]
92
+ (dimensions)? @dimensions
93
+ (identifier)? @class
94
+ (validation_functions)? @validators
89
95
  (default_value
90
- ("=") .
96
+ ("=")
91
97
  _+ @default
92
- )? .
98
+ )?
93
99
  (comment)* @comment
94
100
  )""")
95
101
 
96
102
 
97
103
  ATTRIBUTE_QUERY = LANGUAGE.query("""(attribute
98
- (identifier) @name .
104
+ (identifier) @name
99
105
  (
100
- ("=") .
106
+ ("=")
101
107
  _+ @value
102
108
  )?
103
109
  )""")
@@ -106,13 +112,13 @@ ATTRIBUTE_QUERY = LANGUAGE.query("""(attribute
106
112
  CLASS_QUERY = LANGUAGE.query("""("classdef" .
107
113
  (attributes
108
114
  (attribute) @attributes
109
- )? .
110
- (identifier) @name .
115
+ )?
116
+ (identifier) @name
111
117
  (superclasses
112
118
  (property_name) @bases
113
119
  )? .
114
- (comment)* @docstring .
115
- ("\\n")? .
120
+ (comment)* @docstring
121
+ ("\\n")?
116
122
  [
117
123
  (comment)
118
124
  (methods) @methods
@@ -165,12 +171,9 @@ def _dedent(lines: list[str]) -> list[str]:
165
171
  Returns:
166
172
  list[str]: A list of strings with the common leading whitespace removed from each line.
167
173
  """
168
- indents = [len(line) - len(line.lstrip()) for line in lines if line.strip()]
169
- indent = min(indents) if indents else 0
170
- if indent == 0:
171
- return lines
172
- else:
173
- return [line[indent:] if line.strip() else line for line in lines]
174
+ text = "\n".join(lines)
175
+ dedented_text = textwrap.dedent(text)
176
+ return dedented_text.split("\n")
174
177
 
175
178
 
176
179
  class FileParser(object):
@@ -248,12 +251,14 @@ class FileParser(object):
248
251
 
249
252
  return model
250
253
  except Exception as ex:
251
- syntax_error = SyntaxError(f"Error parsing Matlab file")
254
+ syntax_error = SyntaxError("Error parsing Matlab file")
252
255
  syntax_error.filename = str(self.filepath)
253
256
  if self._node is not None:
254
257
  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)
258
+ indentation = " " * self._node.start_point.column
259
+ syntax_error.text = indentation + self._node.text.decode(
260
+ self.encoding
261
+ )
257
262
  syntax_error.lineno = self._node.start_point.row + 1
258
263
  syntax_error.offset = self._node.start_point.column + 1
259
264
  syntax_error.end_lineno = self._node.end_point.row + 1
@@ -428,7 +433,9 @@ class FileParser(object):
428
433
 
429
434
  return (key, value)
430
435
 
431
- def _parse_function(self, node: Node, method: bool = False, **kwargs: Any) -> Function:
436
+ def _parse_function(
437
+ self, node: Node, method: bool = False, **kwargs: Any
438
+ ) -> Function:
432
439
  """
433
440
  Parse a function node and return a Function model.
434
441
 
@@ -610,11 +617,19 @@ class FileParser(object):
610
617
  if nodes is None:
611
618
  return None
612
619
  elif isinstance(nodes, list):
613
-
614
620
  # Ensure that if there is a gap between subsequent comment nodes, only the first block is considered
615
- if gaps := (end.start_point.row - start.end_point.row for (start, end) in zip(nodes[:-1], nodes[1:])):
616
- first_gap_index = next((i for i, gap in enumerate(gaps) if gap > 1), None)
617
- nodes = nodes[:first_gap_index+1] if first_gap_index is not None else nodes
621
+ if gaps := (
622
+ end.start_point.row - start.end_point.row
623
+ for (start, end) in zip(nodes[:-1], nodes[1:])
624
+ ):
625
+ first_gap_index = next(
626
+ (i for i, gap in enumerate(gaps) if gap > 1), None
627
+ )
628
+ nodes = (
629
+ nodes[: first_gap_index + 1]
630
+ if first_gap_index is not None
631
+ else nodes
632
+ )
618
633
 
619
634
  lineno = nodes[0].range.start_point.row + 1
620
635
  endlineno = nodes[-1].range.end_point.row + 1
@@ -640,13 +655,13 @@ class FileParser(object):
640
655
 
641
656
  # Exclude all pragma's
642
657
  if line in [
643
- '%#codegen',
644
- '%#eml',
645
- '%#external',
646
- '%#exclude',
647
- '%#function',
648
- '%#ok',
649
- '%#mex',
658
+ "%#codegen",
659
+ "%#eml",
660
+ "%#external",
661
+ "%#exclude",
662
+ "%#function",
663
+ "%#ok",
664
+ "%#mex",
650
665
  ]:
651
666
  continue
652
667
 
@@ -0,0 +1,7 @@
1
+ from pathlib import Path
2
+
3
+ from mkdocstrings_handlers.matlab.treesitter import FileParser
4
+
5
+ file = Path(__file__).parent.parent / "docs" / "snippets" / "+mynamespace" / "typed_function.m"
6
+ parser = FileParser(file.resolve())
7
+ parser.parse()
@@ -1,8 +1,8 @@
1
+ import os
1
2
  from contextlib import contextmanager
2
- from mkdocs.commands import serve
3
3
  from pathlib import Path
4
4
 
5
- import os
5
+ from mkdocs.commands import serve
6
6
 
7
7
 
8
8
  @contextmanager