Skip to content

Commit 509e793

Browse files
authored
feat: show subnamespaces (#36)
* add option show_subnamespaces * forward config
1 parent dbf469a commit 509e793

5 files changed

Lines changed: 361 additions & 16 deletions

File tree

docs/usage/configuration/docstrings.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,6 @@ plugins:
611611
show_docstring_namespaces: false
612612
```
613613

614-
```tree
615-
module/
616-
__init__.py
617-
submodule.py
618-
```
619-
620614
--8<-- "docs/snippets/+module/module.md"
621615

622616
???+ preview

docs/usage/configuration/members.md

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,69 @@ plugins:
549549
```markdown
550550
::: +mymembers
551551
options:
552-
group_by_category: False
552+
group_by_category: false
553553
```
554554

555555
::: +mymembers
556556
options:
557-
group_by_category: False
557+
group_by_category: false
558+
559+
## `show_subnamespaces`
560+
561+
- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }**
562+
563+
When rendering a namespace, show its subnamespaces recursively.
564+
565+
This is false by default, because most of the time we render only one namespace per page, and when rendering a full package (a tree of namespaces and their members) on a single page, we quickly run out of [heading levels][heading_level].
566+
567+
```yaml title="in mkdocs.yml (global configuration)"
568+
plugins:
569+
- mkdocstrings:
570+
handlers:
571+
matlab:
572+
options:
573+
show_subnamespaces: true
574+
```
575+
576+
```md title="or in docs/some_page.md (local configuration)"
577+
::: +matlab_namespace
578+
options:
579+
show_subnamespaces: false
580+
```
581+
582+
--8<-- "docs/snippets/+module/module.md"
583+
584+
???+ preview
585+
586+
=== "With show subnamespaces"
587+
588+
```markdown
589+
::: +module
590+
options:
591+
show_subnamespaces: true
592+
```
593+
594+
::: +module
595+
options:
596+
show_subnamespaces: true
597+
show_docstring_namespaces: false
598+
show_docstring_classes: false
599+
show_docstring_functions: false
600+
601+
=== "Without show subnamespaces"
602+
603+
```markdown
604+
::: +module
605+
options:
606+
show_subnamespaces: false
607+
```
608+
609+
::: +module
610+
options:
611+
show_subnamespaces: false
612+
show_docstring_namespaces: false
613+
show_docstring_classes: false
614+
show_docstring_functions: false
558615

559616
## `summary`
560617

src/mkdocstrings_handlers/matlab/collect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def update_model(self, model: MatlabMixin, config: Mapping) -> MatlabMixin:
238238
case DocstringSectionKind.parameters:
239239
section.title = "Input arguments:"
240240
case DocstringSectionKind.returns:
241-
section.title= "Output arguments:"
241+
section.title = "Output arguments:"
242242
case DocstringSectionKind.other_parameters:
243243
section.title = "Name-Value Arguments:"
244244

src/mkdocstrings_handlers/matlab/handler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class MatlabHandler(BaseHandler):
5353
"members_order": rendering.Order.alphabetical.value,
5454
"filters": ["!^delete$|^disp$"],
5555
"group_by_category": True,
56+
"show_subnamespaces": False,
5657
"summary": False,
5758
"show_labels": True,
5859
# Docstring options
@@ -120,6 +121,7 @@ class MatlabHandler(BaseHandler):
120121
The `members` option takes precedence over `filters` (filters will still be applied recursively
121122
to lower members in the hierarchy). Default: `["!^delete$|^disp$"]`.
122123
group_by_category (bool): Group the object's children by categories: properties, classes, functions, and namespaces. Default: `True`.
124+
show_subnamespaces (bool): When rendering a namespace, show its subnamespaces recursively. Default: `False`.
123125
summary (bool | dict[str, bool]): Whether to render summaries of namespaces, classes, functions (methods) and properties. Default: `False`.
124126
show_labels (bool): Whether to show labels of the members. Default: `True`.
125127
@@ -251,6 +253,9 @@ def render(self, data: CollectorItem, config: Mapping[str, Any]) -> str:
251253
}
252254

253255
# Map docstring options
256+
final_config["show_submodules"] = config.get(
257+
"show_subnamespaces", False
258+
)
254259
final_config["show_docstring_attributes"] = config.get(
255260
"show_docstring_properties", True
256261
)

0 commit comments

Comments
 (0)