Skip to content

Search: fix parsing of parameters inside sphinx domains #9750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions readthedocs/search/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,10 @@ def _generate_domains_data(self, body):
def _parse_domain_tag(self, tag):
"""Returns the text from the description tag of the domain."""

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

Expand Down
2 changes: 1 addition & 1 deletion readthedocs/search/tests/data/sphinx/out/page.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
],
"domain_data": {
"test_py_module.test.Foo": "Docstring for class Foo. This text tests for the formatting of docstrings generated from output sphinx.ext.autodoc.",
"test_py_module.test.Foo.__init__": "Start the Foo."
"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…"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

funny, we already had that test case, but we were expecting the wrong result :D

}
}