mkdocstrings-matlab 0.9.6__py3-none-any.whl → 1.0.0__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/__init__.py +26 -3
- mkdocstrings_handlers/matlab/config.py +885 -0
- mkdocstrings_handlers/matlab/handler.py +155 -299
- mkdocstrings_handlers/matlab/logger.py +111 -0
- mkdocstrings_handlers/matlab/rendering.py +818 -0
- mkdocstrings_handlers/matlab/templates/material/attributes.html.jinja +25 -0
- mkdocstrings_handlers/matlab/templates/material/backlinks.html.jinja +17 -0
- mkdocstrings_handlers/matlab/templates/material/children.html.jinja +70 -62
- mkdocstrings_handlers/matlab/templates/material/class.html.jinja +236 -0
- mkdocstrings_handlers/matlab/templates/material/docstring/admonition.html.jinja +20 -0
- mkdocstrings_handlers/matlab/templates/material/docstring/classes.html.jinja +85 -0
- mkdocstrings_handlers/matlab/templates/material/docstring/examples.html.jinja +27 -0
- mkdocstrings_handlers/matlab/templates/material/docstring/functions.html.jinja +91 -0
- mkdocstrings_handlers/matlab/templates/material/docstring/input_arguments.html.jinja +171 -0
- mkdocstrings_handlers/matlab/templates/material/docstring/name_value_arguments.html.jinja +166 -0
- mkdocstrings_handlers/matlab/templates/material/docstring/namespaces.html.jinja +5 -6
- mkdocstrings_handlers/matlab/templates/material/docstring/output_arguments.html.jinja +152 -0
- mkdocstrings_handlers/matlab/templates/material/docstring/properties.html.jinja +25 -26
- mkdocstrings_handlers/matlab/templates/material/docstring.html.jinja +53 -0
- mkdocstrings_handlers/matlab/templates/material/expression.html.jinja +55 -0
- mkdocstrings_handlers/matlab/templates/material/folder.html.jinja +31 -39
- mkdocstrings_handlers/matlab/templates/material/function.html.jinja +148 -0
- mkdocstrings_handlers/matlab/templates/material/language.html.jinja +18 -0
- mkdocstrings_handlers/matlab/templates/material/languages/en.html.jinja +38 -0
- mkdocstrings_handlers/matlab/templates/material/languages/ja.html.jinja +38 -0
- mkdocstrings_handlers/matlab/templates/material/languages/zh.html.jinja +38 -0
- mkdocstrings_handlers/matlab/templates/material/namespace.html.jinja +32 -38
- mkdocstrings_handlers/matlab/templates/material/property.html.jinja +39 -35
- mkdocstrings_handlers/matlab/templates/material/script.html.jinja +3 -25
- mkdocstrings_handlers/matlab/templates/material/signature.html.jinja +105 -0
- mkdocstrings_handlers/matlab/templates/material/style.css +179 -4
- mkdocstrings_handlers/matlab/templates/material/summary/classes.html.jinja +25 -0
- mkdocstrings_handlers/matlab/templates/material/summary/functions.html.jinja +25 -0
- mkdocstrings_handlers/matlab/templates/material/summary/namespaces.html.jinja +17 -13
- mkdocstrings_handlers/matlab/templates/material/summary/properties.html.jinja +17 -13
- mkdocstrings_handlers/matlab/templates/material/summary.html.jinja +6 -6
- {mkdocstrings_matlab-0.9.6.dist-info → mkdocstrings_matlab-1.0.0.dist-info}/METADATA +17 -19
- mkdocstrings_matlab-1.0.0.dist-info/RECORD +41 -0
- mkdocstrings_handlers/matlab/collect.py +0 -783
- mkdocstrings_handlers/matlab/enums.py +0 -54
- mkdocstrings_handlers/matlab/models.py +0 -633
- mkdocstrings_handlers/matlab/treesitter.py +0 -707
- mkdocstrings_matlab-0.9.6.dist-info/RECORD +0 -22
- {mkdocstrings_matlab-0.9.6.dist-info → mkdocstrings_matlab-1.0.0.dist-info}/WHEEL +0 -0
- {mkdocstrings_matlab-0.9.6.dist-info → mkdocstrings_matlab-1.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
# This module contains the logger used throughout Griffe.
|
2
|
+
# The logger is actually a wrapper around the standard Python logger.
|
3
|
+
# We wrap it so that it is easier for other downstream libraries to patch it.
|
4
|
+
# For example, mkdocstrings-python patches the logger to relocate it as a child
|
5
|
+
# of `mkdocs.plugins` so that it fits in the MkDocs logging configuration.
|
6
|
+
#
|
7
|
+
# We use a single, global logger because our public API is exposed in a single module, `griffe`.
|
8
|
+
# Extensions however should use their own logger, which is why we provide the `get_logger` function.
|
9
|
+
|
10
|
+
from __future__ import annotations
|
11
|
+
|
12
|
+
import logging
|
13
|
+
from contextlib import contextmanager
|
14
|
+
from typing import TYPE_CHECKING, Any, Callable, ClassVar
|
15
|
+
|
16
|
+
if TYPE_CHECKING:
|
17
|
+
from collections.abc import Iterator
|
18
|
+
|
19
|
+
|
20
|
+
class Logger:
|
21
|
+
_default_logger: Any = logging.getLogger
|
22
|
+
_instances: ClassVar[dict[str, Logger]] = {}
|
23
|
+
|
24
|
+
def __init__(self, name: str) -> None:
|
25
|
+
# Default logger that can be patched by third-party.
|
26
|
+
self._logger = self.__class__._default_logger(name)
|
27
|
+
|
28
|
+
def __getattr__(self, name: str) -> Any:
|
29
|
+
# Forward everything to the logger.
|
30
|
+
return getattr(self._logger, name)
|
31
|
+
|
32
|
+
@contextmanager
|
33
|
+
def disable(self) -> Iterator[None]:
|
34
|
+
"""Temporarily disable logging."""
|
35
|
+
old_level = self._logger.level
|
36
|
+
self._logger.setLevel(100)
|
37
|
+
try:
|
38
|
+
yield
|
39
|
+
finally:
|
40
|
+
self._logger.setLevel(old_level)
|
41
|
+
|
42
|
+
@classmethod
|
43
|
+
def _get(cls, name: str = "griffe") -> Logger:
|
44
|
+
if name not in cls._instances:
|
45
|
+
cls._instances[name] = cls(name)
|
46
|
+
return cls._instances[name]
|
47
|
+
|
48
|
+
@classmethod
|
49
|
+
def _patch_loggers(cls, get_logger_func: Callable) -> None:
|
50
|
+
# Patch current instances.
|
51
|
+
for name, instance in cls._instances.items():
|
52
|
+
instance._logger = get_logger_func(name)
|
53
|
+
|
54
|
+
# Future instances will be patched as well.
|
55
|
+
cls._default_logger = get_logger_func
|
56
|
+
|
57
|
+
|
58
|
+
logger: Logger = Logger._get()
|
59
|
+
"""Our global logger, used throughout the library.
|
60
|
+
|
61
|
+
Griffe's output and error messages are logging messages.
|
62
|
+
|
63
|
+
Griffe provides the [`patch_loggers`][griffe.patch_loggers]
|
64
|
+
function so dependent libraries can patch Griffe loggers as they see fit.
|
65
|
+
|
66
|
+
For example, to fit in the MkDocs logging configuration
|
67
|
+
and prefix each log message with the module name:
|
68
|
+
|
69
|
+
```python
|
70
|
+
import logging
|
71
|
+
from griffe import patch_loggers
|
72
|
+
|
73
|
+
|
74
|
+
class LoggerAdapter(logging.LoggerAdapter):
|
75
|
+
def __init__(self, prefix, logger):
|
76
|
+
super().__init__(logger, {})
|
77
|
+
self.prefix = prefix
|
78
|
+
|
79
|
+
def process(self, msg, kwargs):
|
80
|
+
return f"{self.prefix}: {msg}", kwargs
|
81
|
+
|
82
|
+
|
83
|
+
def get_logger(name):
|
84
|
+
logger = logging.getLogger(f"mkdocs.plugins.{name}")
|
85
|
+
return LoggerAdapter(name, logger)
|
86
|
+
|
87
|
+
|
88
|
+
patch_loggers(get_logger)
|
89
|
+
```
|
90
|
+
"""
|
91
|
+
|
92
|
+
|
93
|
+
def get_logger(name: str = "griffe") -> Logger:
|
94
|
+
"""Create and return a new logger instance.
|
95
|
+
|
96
|
+
Parameters:
|
97
|
+
name: The logger name.
|
98
|
+
|
99
|
+
Returns:
|
100
|
+
The logger.
|
101
|
+
"""
|
102
|
+
return Logger._get(name)
|
103
|
+
|
104
|
+
|
105
|
+
def patch_loggers(get_logger_func: Callable[[str], Any]) -> None:
|
106
|
+
"""Patch Griffe logger and Griffe extensions' loggers.
|
107
|
+
|
108
|
+
Parameters:
|
109
|
+
get_logger_func: A function accepting a name as parameter and returning a logger.
|
110
|
+
"""
|
111
|
+
Logger._patch_loggers(get_logger_func)
|