Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add show_labels config option #130

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

```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 | With labels
<code class="highlight language-python">
<span class="n">some_attr</span><span class="p">:</span>
<span class="nb">int</span>
</code>
<small><code>instance-attribute</code></small>
////

//// tab | Without labels
<code class="highlight language-python">
<span class="n">some_attr</span><span class="p">:</span>
<span class="nb">int</span>
</code>
////
///
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
Loading