mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
py nodes, BitOr
This commit is contained in:
parent
a0e986c6b0
commit
1cb8c56720
@ -118,7 +118,9 @@ def _parse_annotation(annotation: str, env: BuildEnvironment = None) -> List[Nod
|
||||
result.extend(unparse(node.right))
|
||||
return result
|
||||
elif isinstance(node, ast.BitOr):
|
||||
return [nodes.Text(' '), addnodes.desc_sig_punctuation('', '|'), nodes.Text(' ')]
|
||||
return [addnodes.desc_sig_space(),
|
||||
addnodes.desc_sig_punctuation('', '|'),
|
||||
addnodes.desc_sig_space()]
|
||||
elif isinstance(node, ast.Constant): # type: ignore
|
||||
if node.value is Ellipsis:
|
||||
return [addnodes.desc_sig_punctuation('', "...")]
|
||||
|
@ -19,7 +19,7 @@ from sphinx import addnodes
|
||||
from sphinx.addnodes import (desc, desc_addname, desc_annotation, desc_content, desc_name,
|
||||
desc_optional, desc_parameter, desc_parameterlist, desc_returns,
|
||||
desc_sig_name, desc_sig_operator, desc_sig_punctuation,
|
||||
desc_signature, pending_xref)
|
||||
desc_signature, desc_sig_space, pending_xref)
|
||||
from sphinx.domains import IndexEntry
|
||||
from sphinx.domains.python import (PythonDomain, PythonModuleIndex, _parse_annotation,
|
||||
_pseudo_parse_arglist, py_sig_re)
|
||||
@ -484,9 +484,9 @@ def test_pyfunction_with_union_type_operator(app):
|
||||
[desc_sig_punctuation, ":"],
|
||||
" ",
|
||||
[desc_sig_name, ([pending_xref, "int"],
|
||||
" ",
|
||||
desc_sig_space,
|
||||
[desc_sig_punctuation, "|"],
|
||||
" ",
|
||||
desc_sig_space,
|
||||
[pending_xref, "None"])])])])
|
||||
|
||||
|
||||
@ -553,9 +553,9 @@ def test_pydata_with_union_type_operator(app):
|
||||
([desc_name, "version"],
|
||||
[desc_annotation, (": ",
|
||||
[pending_xref, "int"],
|
||||
" ",
|
||||
desc_sig_space,
|
||||
[desc_sig_punctuation, "|"],
|
||||
" ",
|
||||
desc_sig_space,
|
||||
[pending_xref, "str"])]))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user