diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-10-02 05:27:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-02 05:27:56 (GMT) |
commit | 5ee8344aa29d3ecbebcdb1fe32ac6bb5f5e2dda3 (patch) | |
tree | abf890136ba51babf1bf442f38371105c50e6466 | |
parent | c6fcbb4928ced97df81d2cef6c5dcec6bc7dcab7 (diff) | |
download | cpython-5ee8344aa29d3ecbebcdb1fe32ac6bb5f5e2dda3.zip cpython-5ee8344aa29d3ecbebcdb1fe32ac6bb5f5e2dda3.tar.gz cpython-5ee8344aa29d3ecbebcdb1fe32ac6bb5f5e2dda3.tar.bz2 |
gh-97607: Fix content parsing in the impl-detail reST directive (GH-97652)
* Don't parse content as arg in the impl-detail directive
This does not change the (untranslated) output,
but ensures that the doctree node metadata is correct.
which fixes gh-97607 with the text not being translated.
It also simplifies the code and logic
and makes it consistant with the docutils built-in directives.
* Remove unused branch from impl-detail directive handling no-content case
This is not used anywhere in the docs and lacks a clear use case,
and is more likely a mistake which is now flagged at build time.
This simplifies the logic from two code paths to one,
and makes the behavior consistant with similar built-in directives
(e.g. the various admonition types).
* Further simplify impl-detail reST directive code
(cherry picked from commit e8165d47b852e933c176209ddc0b5836a9b0d5f4)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
-rw-r--r-- | Doc/tools/extensions/pyspecific.py | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 915b28a..9abdde0 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -101,33 +101,24 @@ def source_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): class ImplementationDetail(Directive): has_content = True - required_arguments = 0 - optional_arguments = 1 final_argument_whitespace = True # This text is copied to templates/dummy.html label_text = 'CPython implementation detail:' def run(self): + self.assert_has_content() pnode = nodes.compound(classes=['impl-detail']) label = translators['sphinx'].gettext(self.label_text) content = self.content add_text = nodes.strong(label, label) - if self.arguments: - n, m = self.state.inline_text(self.arguments[0], self.lineno) - pnode.append(nodes.paragraph('', '', *(n + m))) self.state.nested_parse(content, self.content_offset, pnode) - if pnode.children and isinstance(pnode[0], nodes.paragraph): - content = nodes.inline(pnode[0].rawsource, translatable=True) - content.source = pnode[0].source - content.line = pnode[0].line - content += pnode[0].children - pnode[0].replace_self(nodes.paragraph('', '', content, - translatable=False)) - pnode[0].insert(0, add_text) - pnode[0].insert(1, nodes.Text(' ')) - else: - pnode.insert(0, nodes.paragraph('', '', add_text)) + content = nodes.inline(pnode[0].rawsource, translatable=True) + content.source = pnode[0].source + content.line = pnode[0].line + content += pnode[0].children + pnode[0].replace_self(nodes.paragraph( + '', '', add_text, nodes.Text(' '), content, translatable=False)) return [pnode] |