Merge pull request #10457 from scVENUS/fix#10456

closes #10456: test and fix for sphinx.domain.python.filter_meta_fields()
This commit is contained in:
Takeshi KOMIYA 2022-05-22 13:26:35 +09:00 committed by GitHub
commit b36eaafef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -16,6 +16,8 @@ Features added
Bugs fixed
----------
* #10456: filter_meta_fields fails to remove more than one meta-field
Testing
--------

View File

@ -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):

View File

@ -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"