mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
support pandas-style default spec by postprocessing tokens
This commit is contained in:
parent
274d9fe4f9
commit
9b425606e7
@ -845,10 +845,17 @@ def _recombine_set_tokens(tokens: List[str]) -> List[str]:
|
||||
|
||||
|
||||
def _tokenize_type_spec(spec: str) -> List[str]:
|
||||
def postprocess(item):
|
||||
if item.startswith("default"):
|
||||
return [item[:7], item[7:]]
|
||||
else:
|
||||
return [item]
|
||||
|
||||
tokens = list(
|
||||
item
|
||||
for item in _token_regex.split(spec)
|
||||
if item is not None and item.strip()
|
||||
for raw_token in _token_regex.split(spec)
|
||||
for item in postprocess(raw_token)
|
||||
if item
|
||||
)
|
||||
return tokens
|
||||
|
||||
|
@ -2013,6 +2013,7 @@ definition_after_normal_text : int
|
||||
"int or float or None, optional",
|
||||
'{"F", "C", "N"}',
|
||||
"{'F', 'C', 'N'}, default: 'F'",
|
||||
"{'F', 'C', 'N or C'}, default 'F'",
|
||||
'"ma{icious"',
|
||||
r"'with \'quotes\''",
|
||||
)
|
||||
@ -2022,6 +2023,7 @@ definition_after_normal_text : int
|
||||
["int", " or ", "float", " or ", "None", ", ", "optional"],
|
||||
["{", '"F"', ", ", '"C"', ", ", '"N"', "}"],
|
||||
["{", "'F'", ", ", "'C'", ", ", "'N'", "}", ", ", "default", ": ", "'F'"],
|
||||
["{", "'F'", ", ", "'C'", ", ", "'N or C'", "}", ", ", "default", " ", "'F'"],
|
||||
['"ma{icious"'],
|
||||
[r"'with \'quotes\''"],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user