mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Migrate to py3 style type annotation: sphinx.util.smartypants
This commit is contained in:
parent
d141fbf054
commit
60b1cec446
@ -26,14 +26,12 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
from typing import Generator, Iterable, Tuple
|
||||||
|
|
||||||
from docutils.utils import smartquotes
|
from docutils.utils import smartquotes
|
||||||
|
|
||||||
from sphinx.util.docutils import __version_info__ as docutils_version
|
from sphinx.util.docutils import __version_info__ as docutils_version
|
||||||
|
|
||||||
if False: # For type annotation
|
|
||||||
from typing import Generator, Iterable, Tuple # NOQA
|
|
||||||
|
|
||||||
|
|
||||||
langquotes = {'af': '“”‘’',
|
langquotes = {'af': '“”‘’',
|
||||||
'af-x-altquot': '„”‚’',
|
'af-x-altquot': '„”‚’',
|
||||||
@ -125,8 +123,7 @@ langquotes = {'af': '“”‘’',
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def educateQuotes(text, language='en'):
|
def educateQuotes(text: str, language: str = 'en') -> str:
|
||||||
# type: (str, str) -> str
|
|
||||||
"""
|
"""
|
||||||
Parameter: - text string (unicode or bytes).
|
Parameter: - text string (unicode or bytes).
|
||||||
- language (`BCP 47` language tag.)
|
- language (`BCP 47` language tag.)
|
||||||
@ -240,8 +237,10 @@ def educateQuotes(text, language='en'):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def educate_tokens(text_tokens, attr=smartquotes.default_smartypants_attr, language='en'):
|
def educate_tokens(text_tokens: Iterable[Tuple[str, str]],
|
||||||
# type: (Iterable[Tuple[str, str]], str, str) -> Generator[str, None, None]
|
attr: str = smartquotes.default_smartypants_attr,
|
||||||
|
language: str = 'en'
|
||||||
|
) -> Generator[str, None, None]:
|
||||||
"""Return iterator that "educates" the items of `text_tokens`.
|
"""Return iterator that "educates" the items of `text_tokens`.
|
||||||
|
|
||||||
This is modified to intercept the ``attr='2'`` as it was used by the
|
This is modified to intercept the ``attr='2'`` as it was used by the
|
||||||
|
Loading…
Reference in New Issue
Block a user