ITADN

bug: `filters: []` not usable when `group_by_category` is set to `false`

#324OpenT0nyX1ang 创建于 2025-12-03
bug
T
T0nyX1angcommented
### To Reproduce Here is a simple module with a public and a protected function. ``` def test(): """test.""" pass def _test(): """_test.""" pass ``` Other options can be set to default values as follows. ```yaml plugins: - mkdocstrings: default_handler: python handlers: python: options: group_by_category: false filters: [] ``` Then, the `_test()` method is not appeared in the generated document. ### Full traceback <details><summary>Full traceback</summary> ```python DEBUG - mkdocstrings_handlers: python\templates\material\function.html.jinja: Rendering mod.test.test DEBUG - mkdocstrings_handlers: python\templates\material\signature.html.jinja: Rendering signature DEBUG - mkdocstrings_handlers: python\templates\material\docstring.html.jinja: Rendering docstring # the following lines won't appear if `group_by_category` is set to `false` DEBUG - mkdocstrings_handlers: python\templates\material\function.html.jinja: Rendering mod.test._test DEBUG - mkdocstrings_handlers: python\templates\material\signature.html.jinja: Rendering signature DEBUG - mkdocstrings_handlers: python\templates\material\docstring.html.jinja: Rendering docstring ``` </details> ### Expected behavior <!-- Please provide a clear and concise description of what you expected to happen. --> ### Environment information - __System__: Windows 10 - __Python__: cpython 3.10.11 - __Environment variables__: - __Installed packages__: - `mkdocstrings-python` v2.0.0 ### Additional context I have tried to pinpoint the issue in `children.html.jinja`, and find the following lines: ```python {% if config.group_by_category %} ... irrelevant codes here ... {% else %} {% for child in obj.all_members |filter_objects( filters=config.filters, members_list=members_list, inherited_members=config.inherited_members, keep_no_docstrings=config.show_if_no_docstring, ) |order_members(config.members_order, members_list) %} {% if not (obj.is_class and child.name == "__init__" and config.merge_init_into_class) %} {% if config.filters == "public" or members_list is not none or child.is_public %} ... rendering codes here ... {% endif %} {% endif %} {% endfor %} {% endif %} ``` I validate the filtering part, and the results are correct, so the problem may be inside the rendering part. Comparing with the similar codes in the `if`-branch, there is a significant difference in the code: ```python {% if config.filters == "public" or members_list is not none or (not child.is_imported or child.is_public) %} ``` After adding these lines, the problem will be resolved on my device.
1 条评论