Enable automatic formatting for `sphinx/domains/index.py`

This commit is contained in:
Adam Turner
2024-12-31 01:36:52 +00:00
parent 4da48f5198
commit 8519590e01
2 changed files with 6 additions and 4 deletions

View File

@@ -394,7 +394,6 @@ preview = true
quote-style = "single"
exclude = [
"sphinx/builders/latex/constants.py",
"sphinx/domains/index.py",
"sphinx/domains/javascript.py",
"sphinx/domains/math.py",
"sphinx/domains/python/_annotations.py",

View File

@@ -48,14 +48,15 @@ class IndexDomain(Domain):
"""Process a document after it is read by the environment."""
entries = self.entries.setdefault(env.docname, [])
for node in list(document.findall(addnodes.index)):
node_entries = node['entries']
try:
for (entry_type, value, _target_id, _main, _category_key) in node['entries']:
for entry_type, value, _target_id, _main, _category_key in node_entries:
split_index_msg(entry_type, value)
except ValueError as exc:
logger.warning(str(exc), location=node)
node.parent.remove(node)
else:
for entry in node['entries']:
for entry in node_entries:
entries.append(entry)
@@ -88,7 +89,9 @@ class IndexDirective(SphinxDirective):
indexnode['inline'] = False
self.set_source_info(indexnode)
for entry in arguments:
indexnode['entries'].extend(process_index_entry(entry, targetnode['ids'][0]))
indexnode['entries'].extend(
process_index_entry(entry, targetnode['ids'][0])
)
return [indexnode, targetnode]