mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
commit
b36eaafef1
2
CHANGES
2
CHANGES
@ -16,6 +16,8 @@ Features added
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* #10456: filter_meta_fields fails to remove more than one meta-field
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user