mkdocstrings-matlab 0.9.4__tar.gz → 0.9.5__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.
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/CHANGELOG.md +13 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/PKG-INFO +1 -1
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/configuration/headings.md +5 -3
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/pyproject.toml +1 -1
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/scripts/copy_and_update_python_templates.py +3 -2
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/__init__.py +4 -3
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/collect.py +8 -11
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/enums.py +1 -1
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/handler.py +8 -8
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/models.py +10 -4
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/treesitter.py +71 -56
- mkdocstrings_matlab-0.9.5/test/playground.py +7 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/.github/CODEOWNERS +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/.github/workflows/docs.yaml +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/.github/workflows/qualify.yaml +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/.github/workflows/release.yaml +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/.github/workflows/update-templates.yaml +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/.gitignore +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/.python-version +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/.vscode/launch.json +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/.vscode/settings.json +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/LICENSE +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/README.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/api.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/changelog.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/credits.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/debug.py +2 -2
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/img/preview_dark.png +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/img/preview_light.png +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/index.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/license.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/logo.png +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/logo.svg +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/overrides/main.html +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/overrides/partials/toc-item.html +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+module/+submodule/Contents.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+module/+submodule/subfunction.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+module/aClass.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+module/do_something.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+module/module.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+module/readme.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mymembers/BaseClass.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mymembers/Contents.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mymembers/ThisClass.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mymembers/mymembers.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mymembers/this_function.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mynamespace/classA.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mynamespace/classB.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mynamespace/mynamespace.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mynamespace/myscript.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mynamespace/readme.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mynamespace/typed_function.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+undocumented/ClassWithoutDocstring.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+undocumented/function_with_docstring.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+undocumented/function_without_docstring.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+undocumented/undocumented.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/Class.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/OtherClass.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/Thing.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/do_output.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/do_something.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/do_varargin.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/myClass.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/myParent.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/myfunction.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/print_hello.m +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/stylesheets/extra.css +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/configuration/docstrings.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/configuration/general.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/configuration/members.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/configuration/signatures.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/docstrings/google.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/docstrings/numpy.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/docstrings/sphinx.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/index.md +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/logo.svg +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/mkdocs.yml +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/renovate.json +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/requirements.lock +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/py.typed +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/children.html.jinja +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/docstring/namespaces.html.jinja +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/docstring/properties.html.jinja +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/folder.html.jinja +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/namespace.html.jinja +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/property.html.jinja +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/script.html.jinja +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/style.css +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/summary/namespaces.html.jinja +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/summary/properties.html.jinja +0 -0
- {mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/templates/material/summary.html.jinja +0 -0
@@ -1,6 +1,19 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
3
|
|
4
|
+
## v0.9.5 (2025-02-02)
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
- Handle line continuations gracefully
|
9
|
+
([#68](https://github.com/watermarkhu/mkdocstrings-matlab/pull/68),
|
10
|
+
[`8a32df0`](https://github.com/watermarkhu/mkdocstrings-matlab/commit/8a32df08f7ae8c4356db186e55d1ecdd3d537850))
|
11
|
+
|
12
|
+
* handle line continuations gracefully
|
13
|
+
|
14
|
+
* Update headings.md
|
15
|
+
|
16
|
+
|
4
17
|
## v0.9.4 (2025-02-01)
|
5
18
|
|
6
19
|
### Bug Fixes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/configuration/headings.md
RENAMED
@@ -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-
|
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
|
528
|
-
<code class="doc-symbol doc-symbol-
|
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)"
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/scripts/copy_and_update_python_templates.py
RENAMED
@@ -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")
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/__init__.py
RENAMED
@@ -1,9 +1,10 @@
|
|
1
1
|
"""MATLAB handler for mkdocstrings."""
|
2
2
|
|
3
|
-
from
|
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
|
-
|
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
|
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/collect.py
RENAMED
@@ -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,
|
6
|
+
from typing import Any, Callable, Mapping, Sequence, TypeVar
|
7
7
|
|
8
|
-
from _griffe.collections import LinesCollection as GLC
|
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
|
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/enums.py
RENAMED
@@ -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"
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/handler.py
RENAMED
@@ -1,18 +1,18 @@
|
|
1
1
|
"""The mkdocstrings handler for processing MATLAB code documentation."""
|
2
2
|
|
3
|
-
|
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,
|
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 +=
|
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
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/models.py
RENAMED
@@ -153,12 +153,16 @@ class MatlabObject(Object):
|
|
153
153
|
|
154
154
|
@property
|
155
155
|
def scripts(self) -> dict[str, "Script"]:
|
156
|
-
return {
|
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
|
-
|
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
|
-
|
38
|
-
|
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
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
169
|
-
|
170
|
-
|
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(
|
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 =
|
256
|
-
syntax_error.text = indentation + self._node.text.decode(
|
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(
|
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 := (
|
616
|
-
|
617
|
-
|
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
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
658
|
+
"%#codegen",
|
659
|
+
"%#eml",
|
660
|
+
"%#external",
|
661
|
+
"%#exclude",
|
662
|
+
"%#function",
|
663
|
+
"%#ok",
|
664
|
+
"%#mex",
|
650
665
|
]:
|
651
666
|
continue
|
652
667
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/.github/workflows/update-templates.yaml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/overrides/partials/toc-item.html
RENAMED
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+module/+submodule/Contents.m
RENAMED
File without changes
|
File without changes
|
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+module/do_something.m
RENAMED
File without changes
|
File without changes
|
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mymembers/BaseClass.m
RENAMED
File without changes
|
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mymembers/ThisClass.m
RENAMED
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mymembers/mymembers.md
RENAMED
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mymembers/this_function.m
RENAMED
File without changes
|
File without changes
|
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mynamespace/mynamespace.md
RENAMED
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mynamespace/myscript.m
RENAMED
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mynamespace/readme.md
RENAMED
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+mynamespace/typed_function.m
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/snippets/+undocumented/undocumented.md
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/configuration/docstrings.md
RENAMED
File without changes
|
File without changes
|
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/docs/usage/configuration/signatures.md
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{mkdocstrings_matlab-0.9.4 → mkdocstrings_matlab-0.9.5}/src/mkdocstrings_handlers/matlab/py.typed
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|