Skip to content

Commit

Permalink
Add show_labels config option
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Feb 4, 2024
1 parent 8e86778 commit 3ed2f07
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
46 changes: 46 additions & 0 deletions docs/usage/configuration/members.md
Original file line number Diff line number Diff line change
Expand Up @@ -643,3 +643,49 @@ plugins:
</ul>
////
///
## `show_labels`
- **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }**
<!-- - **:octicons-project-template-24: Template :material-null:** (N/A) -->
Whether to show labels of the members. Defaults to `True`.
```yaml title="in mkdocs.yml (global configuration)"
plugins:
- mkdocstrings:
handlers:
python:
options:
show_labels: true
```

```md title="or in docs/some_page.md (local configuration)"
::: package.module
options:
show_labels: false
```

```python title="package/module.py"
class SomeClass:
some_attr: int
```

/// admonition | Preview
type: preview

//// tab | Show
<h3 id="django_autotyping.stubbing.codemods.auth_functions_codemod.SomeClass.some_attr" class="doc doc-heading">
<code class="highlight language-python"><span class="n">some_attr</span><span class="p">:</span> <span class="nb">int</span></code>
<span class="doc doc-labels">
<small class="doc doc-label doc-label-instance-attribute"><code>instance-attribute</code></small>
</span>
</h3>
////

//// tab | Don't show
<h3 id="django_autotyping.stubbing.codemods.auth_functions_codemod.SomeClass.some_attr" class="doc doc-heading">
<code class="highlight language-python"><span class="n">some_attr</span><span class="p">:</span> <span class="nb">int</span></code>
</h3>
////
///
2 changes: 2 additions & 0 deletions src/mkdocstrings_handlers/python/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class PythonHandler(BaseHandler):
"preload_modules": None,
"allow_inspection": True,
"summary": False,
"show_labels": True,
"unwrap_annotated": False,
}
"""Default handler configuration.
Expand Down Expand Up @@ -154,6 +155,7 @@ class PythonHandler(BaseHandler):
group_by_category (bool): Group the object's children by categories: attributes, classes, functions, and modules. Default: `True`.
show_submodules (bool): When rendering a module, show its submodules recursively. Default: `False`.
summary (bool | dict[str, bool]): Whether to render summaries of modules, classes, functions (methods) and attributes.
show_labels (bool): Whether to show labels of the members. Default: `True`.
Attributes: Docstrings options:
docstring_style (str): The docstring style to use: `google`, `numpy`, `sphinx`, or `None`. Default: `"google"`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if labels %}
{% if config.show_labels and labels %}
{{ log.debug("Rendering labels") }}
<span class="doc doc-labels">
{% for label in labels|sort %}
Expand Down

0 comments on commit 3ed2f07

Please sign in to comment.