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
|
||||
from typing import Generator, Iterable, Tuple
|
||||
|
||||
from docutils.utils import smartquotes
|
||||
|
||||
from sphinx.util.docutils import __version_info__ as docutils_version
|
||||
|
||||
if False: # For type annotation
|
||||
from typing import Generator, Iterable, Tuple # NOQA
|
||||
|
||||
|
||||
langquotes = {'af': '“”‘’',
|
||||
'af-x-altquot': '„”‚’',
|
||||
@ -125,8 +123,7 @@ langquotes = {'af': '“”‘’',
|
||||
}
|
||||
|
||||
|
||||
def educateQuotes(text, language='en'):
|
||||
# type: (str, str) -> str
|
||||
def educateQuotes(text: str, language: str = 'en') -> str:
|
||||
"""
|
||||
Parameter: - text string (unicode or bytes).
|
||||
- language (`BCP 47` language tag.)
|
||||
@ -240,8 +237,10 @@ def educateQuotes(text, language='en'):
|
||||
return text
|
||||
|
||||
|
||||
def educate_tokens(text_tokens, attr=smartquotes.default_smartypants_attr, language='en'):
|
||||
# type: (Iterable[Tuple[str, str]], str, str) -> Generator[str, None, None]
|
||||
def educate_tokens(text_tokens: Iterable[Tuple[str, str]],
|
||||
attr: str = smartquotes.default_smartypants_attr,
|
||||
language: str = 'en'
|
||||
) -> Generator[str, None, None]:
|
||||
"""Return iterator that "educates" the items of `text_tokens`.
|
||||
|
||||
This is modified to intercept the ``attr='2'`` as it was used by the
|
||||
|
Loading…
Reference in New Issue
Block a user