Skip to content

Commit

Permalink
Merge pull request #10457 from scVENUS/fix#10456
Browse files Browse the repository at this point in the history
closes #10456: test and fix for sphinx.domain.python.filter_meta_fields()
  • Loading branch information
tk0miya committed May 22, 2022
2 parents 34d6d3b + fcb54ae commit b36eaaf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -16,6 +16,8 @@ Features added
Bugs fixed
----------

* #10456: filter_meta_fields fails to remove more than one meta-field

Testing
--------

Expand Down
4 changes: 2 additions & 2 deletions sphinx/domains/python.py
Expand Up @@ -1068,11 +1068,11 @@ def filter_meta_fields(app: Sphinx, domain: str, objtype: str, content: Element)
for node in content:
if isinstance(node, nodes.field_list):
fields = cast(List[nodes.field], node)
for field in fields:
# removing list items while iterating the list needs reversed()
for field in reversed(fields):
field_name = cast(nodes.field_body, field[0]).astext().strip()
if field_name == 'meta' or field_name.startswith('meta '):
node.remove(field)
break


class PythonModuleIndex(Index):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_domain_py.py
Expand Up @@ -999,7 +999,9 @@ def test_info_field_list(app):
text = (".. py:module:: example\n"
".. py:class:: Class\n"
"\n"
" :meta blah: this meta-field must not show up in the toc-tree\n"
" :param str name: blah blah\n"
" :meta another meta field:\n"
" :param age: blah blah\n"
" :type age: int\n"
" :param items: blah blah\n"
Expand Down

0 comments on commit b36eaaf

Please sign in to comment.