Skip to content

Commit a609d9a

Browse files
authored
Search: fix parsing of parameters inside sphinx domains (#9750)
We were removing all dl lists that were inside a domain in order to remove nested domains, but in doing so we were removing parameters (they are inside a dl list!). Instead, let's reuse the method to detect sphinx domains.
1 parent b621dd4 commit a609d9a

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

readthedocs/search/parsers.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,10 @@ def _generate_domains_data(self, body):
545545
def _parse_domain_tag(self, tag):
546546
"""Returns the text from the description tag of the domain."""
547547

548-
# remove the 'dl', 'dt' and 'dd' tags from it
549-
# because all the 'dd' and 'dt' tags are inside 'dl'
550-
# and all 'dl' tags are already captured.
551-
nodes_to_be_removed = tag.css('dl') + tag.css('dt') + tag.css('dd')
552-
for node in nodes_to_be_removed:
548+
# Remove all nested domains,
549+
# since they are already parsed separately.
550+
nested_domains = self._get_sphinx_domains(tag)
551+
for node in nested_domains:
553552
if tag != node:
554553
node.decompose()
555554

readthedocs/search/tests/data/sphinx/out/page.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@
4040
],
4141
"domain_data": {
4242
"test_py_module.test.Foo": "Docstring for class Foo. This text tests for the formatting of docstrings generated from output sphinx.ext.autodoc.",
43-
"test_py_module.test.Foo.__init__": "Start the Foo."
43+
"test_py_module.test.Foo.__init__": "Start the Foo. Parameters: qux (string) – The first argument to initialize class. spam (bool) – Spam me yes or no…"
4444
}
4545
}

0 commit comments

Comments
 (0)