Fix invalid genindex.html file produced with translated docs (#12495)

This commit is contained in:
Nicolas Peugnet 2024-07-04 03:00:28 +02:00 committed by GitHub
parent 57bf4dd9f7
commit b23ac4f16e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 3 deletions

View File

@ -86,6 +86,9 @@ Bugs fixed
* #12331: Resolve data-URI-image-extraction regression from v7.3.0 affecting
builders without native support for data-URIs in their output format.
Patch by James Addison.
* #12494: Fix invalid genindex.html file produced with translated docs
(regression in 7.1.0).
Patch by Nicolas Peugnet.
Testing
-------

View File

@ -272,7 +272,7 @@ def split_term_classifiers(line: str) -> tuple[str, str | None]:
return term, first_classifier
def make_glossary_term(env: BuildEnvironment, textnodes: Iterable[Node], index_key: str,
def make_glossary_term(env: BuildEnvironment, textnodes: Iterable[Node], index_key: str | None,
source: str, lineno: int, node_id: str | None, document: nodes.document,
) -> nodes.term:
# get a text-only representation of the term and register it
@ -395,7 +395,7 @@ class Glossary(SphinxDirective):
# use first classifier as a index key
term = make_glossary_term(self.env, textnodes,
first_classifier, source, lineno, # type: ignore[arg-type]
first_classifier, source, lineno,
node_id=None, document=self.state.document)
term.rawsource = line
system_messages.extend(sysmsg)

View File

@ -411,7 +411,7 @@ class Locale(SphinxTransform):
self.app, term or '', source, node.line, self.config, settings, # type: ignore[arg-type]
)
updater.patch = make_glossary_term(
self.env, patch, first_classifier or '',
self.env, patch, first_classifier,
source, node.line, _id, self.document, # type: ignore[arg-type]
)
processed = True

View File

@ -938,6 +938,16 @@ def test_html_index_entries(app):
start_tag2 = "<%s[^>]*>" % childtag
return fr"{start_tag1}\s*{keyword}\s*{start_tag2}"
expected_exprs = [
wrap('h2', 'Symbols'),
wrap('h2', 'C'),
wrap('h2', 'E'),
wrap('h2', 'F'),
wrap('h2', 'M'),
wrap('h2', 'N'),
wrap('h2', 'R'),
wrap('h2', 'S'),
wrap('h2', 'T'),
wrap('h2', 'V'),
wrap('a', 'NEWSLETTER'),
wrap('a', 'MAILING LIST'),
wrap('a', 'RECIPIENTS LIST'),