You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Gettext builder not extracting content of doctest blocks #12871
Hi, running a gettext builder on a documents with doctest-block in gettext_additional_targets doesn't add the content of doctest blocks in generated POTs.
A minimal comparison with gettext_additional_targets = ['doctest-block'] gives the same result on Sphinx 7.3.7 and current main:
>>> 2+24
is extracted, while:
>>> 2+24
is missing from the POT file.
The likely cause is source metadata. After transforms, both nodes have translatable=True and the same rawsource, but the indented doctest has source=None; sphinx.util.nodes.is_translatable() therefore skips it. apply_source_workaround() repairs this case for nested literal_block nodes, but not for doctest_block nodes.
The fix should add nodes.doctest_block to that source workaround and add regression coverage using an indented doctest matching the CPython example.
edit: The source-metadata cause has since been confirmed in feature request #41, and the Sphinx workaround is proposed in #14632.
Describe the bug
Hi, running a gettext builder on a documents with
doctest-blockingettext_additional_targetsdoesn't add the content of doctest blocks in generated POTs.How to Reproduce
Add
doctest-blocktogettext_additional_targetsinconf.py(gh-123407: Allow translation of doctest blocks content python/cpython#123852).
Run
% make gettext.-> lack of expected doctest blocks in POTs, example one: https://github.com/python/cpython/blob/be90648fb2de58b148dcc7553a08ca646911baf2/Doc/tutorial/introduction.rst?plain=1#L150-L155
Environment Information
Sphinx version:
v7.3.7Additional context
From a quick look I'm not able to figure out the cause in the Sphinx codebase.