-
-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Describe the bug
The class docstrings are never displayed.
Screenshots
With the following class
class SSIM(nn.Module):
r"""Creates a criterion that measures the SSIM
between an input and a target.
Args:
window_size: The size of the window.
sigma: The standard deviation of the window.
n_channels: The number of channels $C$.
reduction: Specifies the reduction to apply to the output:
`'none'` | `'mean'` | `'sum'`.
"""
def __init__(
self,
window_size: int = 11,
sigma: float = 1.5,
n_channels: int = 3,
reduction: str = 'mean',
**kwargs,
):
passI get
when merge_init_into_class is false and
when it is true.
System (please complete the following information):
mkdocstrings-pythonversion: 0.6.6- Python version: 3.8.10
- OS: Ubuntu 20.04
plugins:
- mkdocstrings:
default_handler: python
handlers:
python:
selection:
docstring_style: google
rendering:
docstring_section_style: list
heading_level: 3
members_order: source
merge_init_into_class: true
show_bases: false
show_if_no_docstring: false
show_root_full_path: true
show_root_heading: true
show_source: false
show_submodules: false
watch:
- piqaAdditional context
If I understand correctly the following logic, a docstring is displayed only if merge_init_into_class=true and the __init__ function has a docstring, but it is never the one from the class itself.
python/src/mkdocstrings_handlers/python/templates/material/_base/class.html
Lines 82 to 88 in b43e1a5
| {% if config.merge_init_into_class %} | |
| {% if "__init__" in class.members and class.members["__init__"].has_docstring %} | |
| {% with docstring_sections = class.members["__init__"].docstring.parsed %} | |
| {% include "docstring.html" with context %} | |
| {% endwith %} | |
| {% endif %} | |
| {% endif %} |
I think that if merge_init_into_class=false or __init__ does not have a docstring, the docstring of the class should be displayed, if any. If merge_init_into_class=true and both __init__ and the class have a docstring, it is more complicated but IMO, the class docstring should have precedence.

