mkdocstrings-matlab 0.9.7__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.
Files changed (45) hide show
  1. mkdocstrings_handlers/matlab/__init__.py +26 -3
  2. mkdocstrings_handlers/matlab/config.py +885 -0
  3. mkdocstrings_handlers/matlab/handler.py +155 -296
  4. mkdocstrings_handlers/matlab/logger.py +111 -0
  5. mkdocstrings_handlers/matlab/rendering.py +818 -0
  6. mkdocstrings_handlers/matlab/templates/material/attributes.html.jinja +25 -0
  7. mkdocstrings_handlers/matlab/templates/material/backlinks.html.jinja +17 -0
  8. mkdocstrings_handlers/matlab/templates/material/children.html.jinja +70 -62
  9. mkdocstrings_handlers/matlab/templates/material/class.html.jinja +236 -0
  10. mkdocstrings_handlers/matlab/templates/material/docstring/admonition.html.jinja +20 -0
  11. mkdocstrings_handlers/matlab/templates/material/docstring/classes.html.jinja +85 -0
  12. mkdocstrings_handlers/matlab/templates/material/docstring/examples.html.jinja +27 -0
  13. mkdocstrings_handlers/matlab/templates/material/docstring/functions.html.jinja +91 -0
  14. mkdocstrings_handlers/matlab/templates/material/docstring/input_arguments.html.jinja +171 -0
  15. mkdocstrings_handlers/matlab/templates/material/docstring/name_value_arguments.html.jinja +166 -0
  16. mkdocstrings_handlers/matlab/templates/material/docstring/namespaces.html.jinja +5 -6
  17. mkdocstrings_handlers/matlab/templates/material/docstring/output_arguments.html.jinja +152 -0
  18. mkdocstrings_handlers/matlab/templates/material/docstring/properties.html.jinja +25 -26
  19. mkdocstrings_handlers/matlab/templates/material/docstring.html.jinja +53 -0
  20. mkdocstrings_handlers/matlab/templates/material/expression.html.jinja +55 -0
  21. mkdocstrings_handlers/matlab/templates/material/folder.html.jinja +31 -39
  22. mkdocstrings_handlers/matlab/templates/material/function.html.jinja +148 -0
  23. mkdocstrings_handlers/matlab/templates/material/language.html.jinja +18 -0
  24. mkdocstrings_handlers/matlab/templates/material/languages/en.html.jinja +38 -0
  25. mkdocstrings_handlers/matlab/templates/material/languages/ja.html.jinja +38 -0
  26. mkdocstrings_handlers/matlab/templates/material/languages/zh.html.jinja +38 -0
  27. mkdocstrings_handlers/matlab/templates/material/namespace.html.jinja +32 -38
  28. mkdocstrings_handlers/matlab/templates/material/property.html.jinja +39 -35
  29. mkdocstrings_handlers/matlab/templates/material/script.html.jinja +3 -25
  30. mkdocstrings_handlers/matlab/templates/material/signature.html.jinja +105 -0
  31. mkdocstrings_handlers/matlab/templates/material/style.css +179 -4
  32. mkdocstrings_handlers/matlab/templates/material/summary/classes.html.jinja +25 -0
  33. mkdocstrings_handlers/matlab/templates/material/summary/functions.html.jinja +25 -0
  34. mkdocstrings_handlers/matlab/templates/material/summary/namespaces.html.jinja +17 -13
  35. mkdocstrings_handlers/matlab/templates/material/summary/properties.html.jinja +17 -13
  36. mkdocstrings_handlers/matlab/templates/material/summary.html.jinja +6 -6
  37. {mkdocstrings_matlab-0.9.7.dist-info → mkdocstrings_matlab-1.0.0.dist-info}/METADATA +17 -19
  38. mkdocstrings_matlab-1.0.0.dist-info/RECORD +41 -0
  39. mkdocstrings_handlers/matlab/collect.py +0 -783
  40. mkdocstrings_handlers/matlab/enums.py +0 -54
  41. mkdocstrings_handlers/matlab/models.py +0 -633
  42. mkdocstrings_handlers/matlab/treesitter.py +0 -707
  43. mkdocstrings_matlab-0.9.7.dist-info/RECORD +0 -22
  44. {mkdocstrings_matlab-0.9.7.dist-info → mkdocstrings_matlab-1.0.0.dist-info}/WHEEL +0 -0
  45. {mkdocstrings_matlab-0.9.7.dist-info → mkdocstrings_matlab-1.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,885 @@
1
+ """Configuration and options dataclasses."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ import sys
7
+ from dataclasses import field, fields
8
+ from typing import TYPE_CHECKING, Annotated, Any, Literal
9
+
10
+ from mkdocstrings import get_logger
11
+
12
+ # YORE: EOL 3.10: Replace block with line 2.
13
+ if sys.version_info >= (3, 11):
14
+ from typing import Self
15
+ else:
16
+ from typing_extensions import Self
17
+
18
+
19
+ logger = get_logger(__name__)
20
+
21
+
22
+ try:
23
+ # When Pydantic is available, use it to validate options (done automatically).
24
+ # Users can therefore opt into validation by installing Pydantic in development/CI.
25
+ # When building the docs to deploy them, Pydantic is not required anymore.
26
+
27
+ # When building our own docs, Pydantic is always installed (see `docs` group in `pyproject.toml`)
28
+ # to allow automatic generation of a JSON Schema. The JSON Schema is then referenced by mkdocstrings,
29
+ # which is itself referenced by mkdocs-material's schema system. For example in VSCode:
30
+ #
31
+ # "yaml.schemas": {
32
+ # "https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml"
33
+ # }
34
+ import pydantic
35
+
36
+ if getattr(pydantic, "__version__", "1.").startswith("1."):
37
+ raise ImportError # noqa: TRY301
38
+
39
+ from inspect import cleandoc
40
+
41
+ from pydantic import Field as BaseField
42
+ from pydantic.dataclasses import dataclass
43
+
44
+ _base_url = "https://watermarkhu.nl/mkdocstrings-matlab/latest/usage/"
45
+
46
+ def Field( # noqa: N802, D103
47
+ *args: Any,
48
+ description: str,
49
+ group: Literal["general", "headings", "members", "docstrings", "signatures"] | None = None,
50
+ parent: str | None = None,
51
+ **kwargs: Any,
52
+ ) -> None:
53
+ def _add_markdown_description(schema: dict[str, Any]) -> None:
54
+ url = f"{_base_url}/{f'configuration/{group}/' if group else ''}#{parent or schema['title']}"
55
+ schema["markdownDescription"] = f"[DOCUMENTATION]({url})\n\n{schema['description']}"
56
+
57
+ return BaseField(
58
+ *args,
59
+ description=cleandoc(description),
60
+ field_title_generator=lambda name, _: name,
61
+ json_schema_extra=_add_markdown_description,
62
+ **kwargs,
63
+ )
64
+ except ImportError:
65
+ from dataclasses import dataclass
66
+
67
+ def Field(*args: Any, **kwargs: Any) -> None:
68
+ pass
69
+
70
+
71
+ if TYPE_CHECKING:
72
+ from collections.abc import MutableMapping
73
+
74
+
75
+ @dataclass(frozen=True, kw_only=True)
76
+ class GoogleStyleOptions:
77
+ """Google style docstring options."""
78
+
79
+ ignore_init_summary: Annotated[
80
+ bool,
81
+ Field(
82
+ group="docstrings",
83
+ parent="docstring_options",
84
+ description="Whether to ignore the summary in `__init__` methods' docstrings.",
85
+ ),
86
+ ] = False
87
+
88
+ returns_multiple_items: Annotated[
89
+ bool,
90
+ Field(
91
+ group="docstrings",
92
+ parent="docstring_options",
93
+ description="""Whether to parse multiple items in `Yields` and `Returns` sections.
94
+
95
+ When true, each item's continuation lines must be indented.
96
+ When false (single item), no further indentation is required.
97
+ """,
98
+ ),
99
+ ] = True
100
+
101
+ returns_named_value: Annotated[
102
+ bool,
103
+ Field(
104
+ group="docstrings",
105
+ parent="docstring_options",
106
+ description="""Whether to parse `Yields` and `Returns` section items as name and description, rather than type and description.
107
+
108
+ When true, type must be wrapped in parentheses: `(int): Description.`. Names are optional: `name (int): Description.`.
109
+ When false, parentheses are optional but the items cannot be named: `int: Description`.
110
+ """,
111
+ ),
112
+ ] = True
113
+
114
+ returns_type_in_property_summary: Annotated[
115
+ bool,
116
+ Field(
117
+ group="docstrings",
118
+ parent="docstring_options",
119
+ description="Whether to parse the return type of properties at the beginning of their summary: `str: Summary of the property`.",
120
+ ),
121
+ ] = False
122
+
123
+ receives_multiple_items: Annotated[
124
+ bool,
125
+ Field(
126
+ group="docstrings",
127
+ parent="docstring_options",
128
+ description="""Whether to parse multiple items in `Receives` sections.
129
+
130
+ When true, each item's continuation lines must be indented.
131
+ When false (single item), no further indentation is required.
132
+ """,
133
+ ),
134
+ ] = True
135
+
136
+ receives_named_value: Annotated[
137
+ bool,
138
+ Field(
139
+ group="docstrings",
140
+ parent="docstring_options",
141
+ description="""Whether to parse `Receives` section items as name and description, rather than type and description.
142
+
143
+ When true, type must be wrapped in parentheses: `(int): Description.`. Names are optional: `name (int): Description.`.
144
+ When false, parentheses are optional but the items cannot be named: `int: Description`.
145
+ """,
146
+ ),
147
+ ] = True
148
+
149
+ trim_doctest_flags: Annotated[
150
+ bool,
151
+ Field(
152
+ group="docstrings",
153
+ parent="docstring_options",
154
+ description="Whether to remove doctest flags from Python example blocks.",
155
+ ),
156
+ ] = True
157
+
158
+ warn_unknown_params: Annotated[
159
+ bool,
160
+ Field(
161
+ group="docstrings",
162
+ parent="docstring_options",
163
+ description="Warn about documented parameters not appearing in the signature.",
164
+ ),
165
+ ] = True
166
+
167
+
168
+ @dataclass(frozen=True, kw_only=True)
169
+ class NumpyStyleOptions:
170
+ """Numpy style docstring options."""
171
+
172
+ ignore_init_summary: Annotated[
173
+ bool,
174
+ Field(
175
+ group="docstrings",
176
+ parent="docstring_options",
177
+ description="Whether to ignore the summary in `__init__` methods' docstrings.",
178
+ ),
179
+ ] = False
180
+
181
+ trim_doctest_flags: Annotated[
182
+ bool,
183
+ Field(
184
+ group="docstrings",
185
+ parent="docstring_options",
186
+ description="Whether to remove doctest flags from Python example blocks.",
187
+ ),
188
+ ] = True
189
+
190
+ warn_unknown_params: Annotated[
191
+ bool,
192
+ Field(
193
+ group="docstrings",
194
+ parent="docstring_options",
195
+ description="Warn about documented parameters not appearing in the signature.",
196
+ ),
197
+ ] = True
198
+
199
+
200
+ @dataclass(frozen=True, kw_only=True)
201
+ class SphinxStyleOptions:
202
+ """Sphinx style docstring options."""
203
+
204
+
205
+ @dataclass(frozen=True, kw_only=True)
206
+ class PerStyleOptions:
207
+ """Per style options."""
208
+
209
+ google: Annotated[
210
+ GoogleStyleOptions,
211
+ Field(
212
+ group="docstrings",
213
+ parent="docstring_options",
214
+ description="Google-style options.",
215
+ ),
216
+ ] = field(default_factory=GoogleStyleOptions)
217
+
218
+ numpy: Annotated[
219
+ NumpyStyleOptions,
220
+ Field(
221
+ group="docstrings",
222
+ parent="docstring_options",
223
+ description="Numpydoc-style options.",
224
+ ),
225
+ ] = field(default_factory=NumpyStyleOptions)
226
+
227
+ sphinx: Annotated[
228
+ SphinxStyleOptions,
229
+ Field(
230
+ group="docstrings",
231
+ parent="docstring_options",
232
+ description="Sphinx-style options.",
233
+ ),
234
+ ] = field(default_factory=SphinxStyleOptions)
235
+
236
+ @classmethod
237
+ def from_data(cls, **data: Any) -> Self:
238
+ """Create an instance from a dictionary."""
239
+ if "google" in data:
240
+ data["google"] = GoogleStyleOptions(**data["google"])
241
+ if "numpy" in data:
242
+ data["numpy"] = NumpyStyleOptions(**data["numpy"])
243
+ if "sphinx" in data:
244
+ data["sphinx"] = SphinxStyleOptions(**data["sphinx"])
245
+ return cls(**data)
246
+
247
+
248
+ @dataclass(frozen=True, kw_only=True)
249
+ class AutoStyleOptions:
250
+ """Auto style docstring options."""
251
+
252
+ method: Annotated[
253
+ Literal["heuristics", "max_sections"],
254
+ Field(
255
+ group="docstrings",
256
+ parent="docstring_options",
257
+ description="The method to use to determine the docstring style.",
258
+ ),
259
+ ] = "heuristics"
260
+
261
+ style_order: Annotated[
262
+ list[str],
263
+ Field(
264
+ group="docstrings",
265
+ parent="docstring_options",
266
+ description="The order of the docstring styles to try.",
267
+ ),
268
+ ] = field(default_factory=lambda: ["sphinx", "google", "numpy"])
269
+
270
+ default: Annotated[
271
+ str | None,
272
+ Field(
273
+ group="docstrings",
274
+ parent="docstring_options",
275
+ description="The default docstring style to use if no other style is detected.",
276
+ ),
277
+ ] = None
278
+
279
+ per_style_options: Annotated[
280
+ PerStyleOptions,
281
+ Field(
282
+ group="docstrings",
283
+ parent="docstring_options",
284
+ description="Per-style options.",
285
+ ),
286
+ ] = field(default_factory=PerStyleOptions)
287
+
288
+ @classmethod
289
+ def from_data(cls, **data: Any) -> Self:
290
+ """Create an instance from a dictionary."""
291
+ if "per_style_options" in data:
292
+ data["per_style_options"] = PerStyleOptions.from_data(**data["per_style_options"])
293
+ return cls(**data)
294
+
295
+
296
+ @dataclass(frozen=True, kw_only=True)
297
+ class SummaryOption:
298
+ """Summary option."""
299
+
300
+ properties: Annotated[
301
+ bool,
302
+ Field(
303
+ group="members",
304
+ parent="summary",
305
+ description="Whether to render summaries of properties.",
306
+ ),
307
+ ] = False
308
+
309
+ functions: Annotated[
310
+ bool,
311
+ Field(
312
+ group="members",
313
+ parent="summary",
314
+ description="Whether to render summaries of functions (methods).",
315
+ ),
316
+ ] = False
317
+
318
+ classes: Annotated[
319
+ bool,
320
+ Field(
321
+ group="members",
322
+ parent="summary",
323
+ description="Whether to render summaries of classes.",
324
+ ),
325
+ ] = False
326
+
327
+ namespaces: Annotated[
328
+ bool,
329
+ Field(
330
+ group="members",
331
+ parent="summary",
332
+ description="Whether to render summaries of namespaces.",
333
+ ),
334
+ ] = False
335
+
336
+
337
+ @dataclass(frozen=True, kw_only=True)
338
+ class MatlabInputOptions:
339
+ """Accepted input options."""
340
+
341
+ docstring_options: Annotated[
342
+ GoogleStyleOptions | NumpyStyleOptions | SphinxStyleOptions | AutoStyleOptions | None,
343
+ Field(
344
+ group="docstrings",
345
+ description="""The options for the docstring parser.
346
+
347
+ See [docstring parsers](https://mkdocstrings.github.io/griffe/reference/docstrings/) and their options in Griffe docs.
348
+ """,
349
+ ),
350
+ ] = None
351
+
352
+ docstring_section_style: Annotated[
353
+ Literal["table", "list", "spacy"],
354
+ Field(
355
+ group="docstrings",
356
+ description="The style used to render docstring sections.",
357
+ ),
358
+ ] = "table"
359
+
360
+ docstring_style: Annotated[
361
+ Literal["auto", "google", "numpy", "sphinx"] | None,
362
+ Field(
363
+ group="docstrings",
364
+ description="The docstring style to use: `auto`, `google`, `numpy`, `sphinx`, or `None`.",
365
+ ),
366
+ ] = "google"
367
+
368
+ parse_arguments: Annotated[
369
+ bool,
370
+ Field(
371
+ group="docstrings",
372
+ description=" Whether to load inputs and output parameters based on argument validation blocks.",
373
+ ),
374
+ ] = True
375
+
376
+ filters: Annotated[
377
+ list[str],
378
+ Field(
379
+ group="members",
380
+ description="""A list of filters applied to filter objects based on their name.
381
+
382
+ A filter starting with `!` will exclude matching objects instead of including them.
383
+ The `members` option takes precedence over `filters` (filters will still be applied recursively
384
+ to lower members in the hierarchy).
385
+ """,
386
+ ),
387
+ ] = field(
388
+ default_factory=lambda: ["!^delete$|^disp$"],
389
+ )
390
+
391
+ group_by_category: Annotated[
392
+ bool,
393
+ Field(
394
+ group="members",
395
+ description="Group the object's children by categories: properties, classes, functions, and namespaces.",
396
+ ),
397
+ ] = True
398
+
399
+ heading: Annotated[
400
+ str,
401
+ Field(
402
+ group="headings",
403
+ description="A custom string to override the autogenerated heading of the root object.",
404
+ ),
405
+ ] = ""
406
+
407
+ heading_level: Annotated[
408
+ int,
409
+ Field(
410
+ group="headings",
411
+ description="The initial heading level to use.",
412
+ ),
413
+ ] = 2
414
+
415
+ hidden_members: Annotated[
416
+ bool | list[str],
417
+ Field(
418
+ group="members",
419
+ description="""A boolean, or an explicit list of hidden members to render.
420
+
421
+ If true, select all hidden members, which can then be filtered with `members`.
422
+ If false or empty list, do not select any hidden member. Default: `False`.
423
+ """,
424
+ ),
425
+ ] = False
426
+
427
+ private_members: Annotated[
428
+ bool | list[str],
429
+ Field(
430
+ group="members",
431
+ description="""A boolean, or an explicit list of private members to render.
432
+
433
+ If true, select all private members, which can then be filtered with `members`.
434
+ If false or empty list, do not select any private member.
435
+ """,
436
+ ),
437
+ ] = False
438
+
439
+ inherited_members: Annotated[
440
+ bool | list[str],
441
+ Field(
442
+ group="members",
443
+ description="""A boolean, or an explicit list of inherited members to render.
444
+
445
+ If true, select all inherited members, which can then be filtered with `members`.
446
+ If false or empty list, do not select any inherited member.
447
+ """,
448
+ ),
449
+ ] = False
450
+
451
+ line_length: Annotated[
452
+ int,
453
+ Field(
454
+ group="signatures",
455
+ description="Maximum line length when formatting code/signatures.",
456
+ ),
457
+ ] = 60
458
+
459
+ members: Annotated[
460
+ list[str] | bool | None,
461
+ Field(
462
+ group="members",
463
+ description="""A boolean, or an explicit list of members to render.
464
+
465
+ If true, select all members without further filtering.
466
+ If false or empty list, do not render members.
467
+ If none, select all members and apply further filtering with filters and docstrings.
468
+ """,
469
+ ),
470
+ ] = None
471
+
472
+ members_order: Annotated[
473
+ Literal["alphabetical", "source"],
474
+ Field(
475
+ group="members",
476
+ description="""The members ordering to use.
477
+
478
+ - `alphabetical`: order by the members names,
479
+ - `source`: order members as they appear in the source file.
480
+ """,
481
+ ),
482
+ ] = "alphabetical"
483
+
484
+ merge_constructor_into_class: Annotated[
485
+ bool,
486
+ Field(
487
+ group="docstrings",
488
+ description="Whether to merge the constructor method into the class' signature and docstring.",
489
+ ),
490
+ ] = False
491
+
492
+ argument_headings: Annotated[
493
+ bool,
494
+ Field(
495
+ group="headings",
496
+ description="Whether to render headings for parameters (therefore showing parameters in the ToC).",
497
+ ),
498
+ ] = False
499
+
500
+ separate_signature: Annotated[
501
+ bool,
502
+ Field(
503
+ group="signatures",
504
+ description="""Whether to put the whole signature in a code block below the heading.""",
505
+ ),
506
+ ] = False
507
+
508
+ show_bases: Annotated[
509
+ bool,
510
+ Field(
511
+ group="general",
512
+ description="Show the base classes of a class.",
513
+ ),
514
+ ] = True
515
+
516
+ show_category_heading: Annotated[
517
+ bool,
518
+ Field(
519
+ group="headings",
520
+ description="When grouped by categories, show a heading for each category.",
521
+ ),
522
+ ] = False
523
+
524
+ show_docstring_classes: Annotated[
525
+ bool,
526
+ Field(
527
+ group="docstrings",
528
+ description="Whether to display the 'Classes' section in the object's docstring.",
529
+ ),
530
+ ] = True
531
+
532
+ show_docstring_description: Annotated[
533
+ bool,
534
+ Field(
535
+ group="docstrings",
536
+ description="Whether to display the textual block (including admonitions) in the object's docstring.",
537
+ ),
538
+ ] = True
539
+
540
+ show_docstring_examples: Annotated[
541
+ bool,
542
+ Field(
543
+ group="docstrings",
544
+ description="Whether to display the 'Examples' section in the object's docstring.",
545
+ ),
546
+ ] = True
547
+
548
+ show_docstring_functions: Annotated[
549
+ bool,
550
+ Field(
551
+ group="docstrings",
552
+ description="Whether to display the 'Functions' or 'Methods' sections in the object's docstring.",
553
+ ),
554
+ ] = True
555
+
556
+ show_docstring_namespaces: Annotated[
557
+ bool,
558
+ Field(
559
+ group="docstrings",
560
+ description="Whether to display the 'Namespaces' section in the object's docstring.",
561
+ ),
562
+ ] = True
563
+
564
+ show_docstring_properties: Annotated[
565
+ bool,
566
+ Field(
567
+ group="docstrings",
568
+ description="Whether to display the 'Properties' section in the object's docstring.",
569
+ ),
570
+ ] = True
571
+
572
+ show_docstring_input_arguments: Annotated[
573
+ bool,
574
+ Field(
575
+ group="docstrings",
576
+ description="Whether to display the 'Input arguments' section in the object's docstring.",
577
+ ),
578
+ ] = True
579
+
580
+ show_docstring_name_value_arguments: Annotated[
581
+ bool,
582
+ Field(
583
+ group="docstrings",
584
+ description="Whether to display the 'Name-value pairs' section in the object's docstring.",
585
+ ),
586
+ ] = True
587
+
588
+ show_docstring_output_arguments: Annotated[
589
+ bool,
590
+ Field(
591
+ group="docstrings",
592
+ description="Whether to display the 'Ouput arguments' section in the object's docstring.",
593
+ ),
594
+ ] = True
595
+
596
+ show_if_no_docstring: Annotated[
597
+ bool,
598
+ Field(
599
+ group="docstrings",
600
+ description="Show the object heading even if it has no docstring or children with docstrings.",
601
+ ),
602
+ ] = False
603
+
604
+ show_inheritance_diagram: Annotated[
605
+ bool,
606
+ Field(
607
+ group="docstrings",
608
+ description="Show the inheritance diagram of a class using Mermaid.",
609
+ ),
610
+ ] = False
611
+
612
+ show_attributes: Annotated[
613
+ bool,
614
+ Field(
615
+ group="docstrings",
616
+ description="Whether to show attributes of the members.",
617
+ ),
618
+ ] = True
619
+
620
+ show_object_full_path: Annotated[
621
+ bool,
622
+ Field(
623
+ group="docstrings",
624
+ description="Show the full path of every object.",
625
+ ),
626
+ ] = False
627
+
628
+ show_root_full_path: Annotated[
629
+ bool,
630
+ Field(
631
+ group="docstrings",
632
+ description="Show the full path for the root object heading.",
633
+ ),
634
+ ] = True
635
+
636
+ show_root_heading: Annotated[
637
+ bool,
638
+ Field(
639
+ group="headings",
640
+ description="""Show the heading of the object at the root of the documentation tree.
641
+
642
+ The root object is the object referenced by the identifier after `:::`.
643
+ """,
644
+ ),
645
+ ] = False
646
+
647
+ show_root_members_full_path: Annotated[
648
+ bool,
649
+ Field(
650
+ group="headings",
651
+ description="Show the full path of the root members.",
652
+ ),
653
+ ] = False
654
+
655
+ show_root_toc_entry: Annotated[
656
+ bool,
657
+ Field(
658
+ group="headings",
659
+ description="If the root heading is not shown, at least add a ToC entry for it.",
660
+ ),
661
+ ] = True
662
+
663
+ show_signature_types: Annotated[
664
+ bool,
665
+ Field(
666
+ group="signatures",
667
+ description="Show the type annotations in methods and functions signatures.",
668
+ ),
669
+ ] = False
670
+
671
+ show_signature: Annotated[
672
+ bool,
673
+ Field(
674
+ group="signatures",
675
+ description="Show methods and functions signatures.",
676
+ ),
677
+ ] = True
678
+
679
+ show_source: Annotated[
680
+ bool,
681
+ Field(
682
+ group="general",
683
+ description="Show the source code of this object.",
684
+ ),
685
+ ] = True
686
+
687
+ show_subnamespaces: Annotated[
688
+ bool,
689
+ Field(
690
+ group="members",
691
+ description="When rendering a namespace, show its subnamespaces recursively.",
692
+ ),
693
+ ] = False
694
+
695
+ show_symbol_type_heading: Annotated[
696
+ bool,
697
+ Field(
698
+ group="headings",
699
+ description="Show the symbol type in headings (e.g. mod, class, meth, func and attr).",
700
+ ),
701
+ ] = False
702
+
703
+ show_symbol_type_toc: Annotated[
704
+ bool,
705
+ Field(
706
+ group="headings",
707
+ description="Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).",
708
+ ),
709
+ ] = False
710
+
711
+ signature_crossrefs: Annotated[
712
+ bool,
713
+ Field(
714
+ group="signatures",
715
+ description="Whether to render cross-references for type annotations in signatures.",
716
+ ),
717
+ ] = False
718
+
719
+ summary: Annotated[
720
+ bool | SummaryOption,
721
+ Field(
722
+ group="members",
723
+ description="Whether to render summaries of namespaces, classes, functions (methods) and properties.",
724
+ ),
725
+ ] = field(default_factory=SummaryOption)
726
+
727
+ toc_label: Annotated[
728
+ str,
729
+ Field(
730
+ group="headings",
731
+ description="A custom string to override the autogenerated toc label of the root object.",
732
+ ),
733
+ ] = ""
734
+
735
+ extra: Annotated[
736
+ dict[str, Any],
737
+ Field(
738
+ group="general",
739
+ description="Extra options.",
740
+ ),
741
+ ] = field(default_factory=dict)
742
+
743
+ @classmethod
744
+ def _extract_extra(cls, data: dict[str, Any]) -> tuple[dict[str, Any], dict[str, Any]]:
745
+ field_names = {field.name for field in fields(cls)}
746
+ copy = data.copy()
747
+ return {name: copy.pop(name) for name in data if name not in field_names}, copy
748
+
749
+ @classmethod
750
+ def coerce(cls, **data: Any) -> MutableMapping[str, Any]:
751
+ """Coerce data."""
752
+ if "docstring_options" in data:
753
+ docstring_style = data.get("docstring_style", "google")
754
+ docstring_options = data["docstring_options"]
755
+ if docstring_options is not None:
756
+ if docstring_style == "auto":
757
+ docstring_options = AutoStyleOptions.from_data(**docstring_options)
758
+ elif docstring_style == "google":
759
+ docstring_options = GoogleStyleOptions(**docstring_options)
760
+ elif docstring_style == "numpy":
761
+ docstring_options = NumpyStyleOptions(**docstring_options)
762
+ elif docstring_style == "sphinx":
763
+ docstring_options = SphinxStyleOptions(**docstring_options)
764
+ data["docstring_options"] = docstring_options
765
+ if "summary" in data:
766
+ summary = data["summary"]
767
+ if summary is True:
768
+ summary = SummaryOption(
769
+ **dict(properties=True, functions=True, classes=True, namespaces=True)
770
+ )
771
+ elif summary is False:
772
+ summary = SummaryOption(
773
+ **dict(properties=False, functions=False, classes=False, namespaces=False)
774
+ )
775
+ else:
776
+ summary = SummaryOption(**summary)
777
+ data["summary"] = summary
778
+ return data
779
+
780
+ @classmethod
781
+ def from_data(cls, **data: Any) -> Self:
782
+ """Create an instance from a dictionary."""
783
+ return cls(**cls.coerce(**data))
784
+
785
+
786
+ @dataclass(frozen=True, kw_only=True)
787
+ class MatlabOptions(MatlabInputOptions): # type: ignore[override,unused-ignore]
788
+ """Final options passed as template context."""
789
+
790
+ filters: list[tuple[re.Pattern, bool]] = field(default_factory=list) # type: ignore[assignment]
791
+ """A list of filters applied to filter objects based on their name."""
792
+
793
+ summary: SummaryOption = field(default_factory=SummaryOption)
794
+ """Whether to render summaries of namespaces, classes, functions (methods) and properties."""
795
+
796
+ @classmethod
797
+ def coerce(cls, **data: Any) -> MutableMapping[str, Any]:
798
+ """Create an instance from a dictionary."""
799
+ if "filters" in data:
800
+ data["filters"] = [
801
+ (re.compile(filtr.lstrip("!")), filtr.startswith("!"))
802
+ for filtr in data["filters"] or ()
803
+ ]
804
+ return super().coerce(**data)
805
+
806
+
807
+ @dataclass(frozen=True, kw_only=True)
808
+ class Inventory:
809
+ """An inventory."""
810
+
811
+ url: Annotated[
812
+ str,
813
+ Field(
814
+ parent="inventories",
815
+ description="The URL of the inventory.",
816
+ ),
817
+ ]
818
+
819
+ base: Annotated[
820
+ str | None,
821
+ Field(
822
+ parent="inventories",
823
+ description="The base URL of the inventory.",
824
+ ),
825
+ ] = None
826
+
827
+ domains: Annotated[
828
+ list[str],
829
+ Field(
830
+ parent="inventories",
831
+ description="The domains to load from the inventory.",
832
+ ),
833
+ ] = field(default_factory=lambda: ["py"])
834
+
835
+ @property
836
+ def _config(self) -> dict[str, Any]:
837
+ return {"base": self.base, "domains": self.domains}
838
+
839
+
840
+ @dataclass(frozen=True, kw_only=True)
841
+ class MatlabInputConfig:
842
+ """MATLAB handler configuration."""
843
+
844
+ inventories: Annotated[
845
+ list[str | Inventory],
846
+ Field(description="The inventories to load."),
847
+ ] = field(default_factory=list)
848
+
849
+ paths: Annotated[
850
+ list[str],
851
+ Field(description="The MATLAB paths"),
852
+ ] = field(default_factory=lambda: ["."])
853
+
854
+ paths_recursive: Annotated[
855
+ bool,
856
+ Field(description="Whether add all paths recursively."),
857
+ ] = False
858
+
859
+ options: Annotated[
860
+ MatlabInputOptions,
861
+ Field(description="Configuration options for collecting and rendering objects."),
862
+ ] = field(default_factory=MatlabInputOptions)
863
+
864
+ locale: Annotated[
865
+ str | None,
866
+ Field(description="The locale to use when translating template strings."),
867
+ ] = None
868
+
869
+ @classmethod
870
+ def coerce(cls, **data: Any) -> MutableMapping[str, Any]:
871
+ """Coerce data."""
872
+ return data
873
+
874
+ @classmethod
875
+ def from_data(cls, **data: Any) -> Self:
876
+ """Create an instance from a dictionary."""
877
+ return cls(**cls.coerce(**data))
878
+
879
+
880
+ @dataclass(frozen=True, kw_only=True)
881
+ class MatlabConfig(MatlabInputConfig): # type: ignore[override,unused-ignore]
882
+ """MATLAB handler configuration."""
883
+
884
+ inventories: list[Inventory] = field(default_factory=list) # type: ignore[assignment]
885
+ options: dict[str, Any] = field(default_factory=dict) # type: ignore[assignment]