py nodes, List

This commit is contained in:
Jakob Lykke Andersen
2021-09-25 12:12:18 +02:00
parent 1cb8c56720
commit c00e608783
2 changed files with 6 additions and 2 deletions

View File

@@ -138,7 +138,9 @@ def _parse_annotation(annotation: str, env: BuildEnvironment = None) -> List[Nod
# once
for elem in node.elts:
result.extend(unparse(elem))
result.append(addnodes.desc_sig_punctuation('', ', '))
result.append(addnodes.desc_sig_punctuation('', ','))
result.append(addnodes.desc_sig_space())
result.pop()
result.pop()
result.append(addnodes.desc_sig_punctuation('', ']'))
return result

View File

@@ -310,11 +310,13 @@ def test_parse_annotation(app):
[desc_sig_punctuation, "]"]))
doctree = _parse_annotation("Callable[[int, int], int]", app.env)
print(doctree)
assert_node(doctree, ([pending_xref, "Callable"],
[desc_sig_punctuation, "["],
[desc_sig_punctuation, "["],
[pending_xref, "int"],
[desc_sig_punctuation, ", "],
[desc_sig_punctuation, ","],
desc_sig_space,
[pending_xref, "int"],
[desc_sig_punctuation, "]"],
[desc_sig_punctuation, ", "],