summaryrefslogtreecommitdiff
path: root/sphinx/cmd/quickstart.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-12-16 00:32:10 +0900
committerGitHub <noreply@github.com>2018-12-16 00:32:10 +0900
commitc70e65fc6cd04d02df4f7911025f534dbd27cc20 (patch)
tree1e8614ac5516dace99ef1df4d203081662c7c2d6 /sphinx/cmd/quickstart.py
parentd6d4406ce987cc8823d1b3a33be3a418bcd2a59d (diff)
parent79eec90f36f5a74e24cfd6740126396fd6567e07 (diff)
downloadsphinx-git-c70e65fc6cd04d02df4f7911025f534dbd27cc20.tar.gz
Merge branch 'master' into 5770_doctest_refers_highlight_language
Diffstat (limited to 'sphinx/cmd/quickstart.py')
-rw-r--r--sphinx/cmd/quickstart.py36
1 files changed, 17 insertions, 19 deletions
diff --git a/sphinx/cmd/quickstart.py b/sphinx/cmd/quickstart.py
index ace0ecdfc..ce66f7352 100644
--- a/sphinx/cmd/quickstart.py
+++ b/sphinx/cmd/quickstart.py
@@ -9,7 +9,6 @@
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
-from __future__ import print_function
import argparse
import locale
@@ -51,7 +50,6 @@ from sphinx.util.template import SphinxRenderer
if False:
# For type annotation
from typing import Any, Callable, Dict, List, Pattern, Union # NOQA
- from sphinx.util.typing import unicode # NOQA
TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
@@ -92,7 +90,7 @@ else:
# function to get input from terminal -- overridden by the test suite
def term_input(prompt):
- # type: (unicode) -> unicode
+ # type: (str) -> str
if sys.platform == 'win32':
# Important: On windows, readline is not enabled by default. In these
# environment, escape sequences have been broken. To avoid the
@@ -108,7 +106,7 @@ class ValidationError(Exception):
def is_path(x):
- # type: (unicode) -> unicode
+ # type: (str) -> str
x = path.expanduser(x)
if not path.isdir(x):
raise ValidationError(__("Please enter a valid path name."))
@@ -116,21 +114,21 @@ def is_path(x):
def allow_empty(x):
- # type: (unicode) -> unicode
+ # type: (str) -> str
return x
def nonempty(x):
- # type: (unicode) -> unicode
+ # type: (str) -> str
if not x:
raise ValidationError(__("Please enter some text."))
return x
def choice(*l):
- # type: (unicode) -> Callable[[unicode], unicode]
+ # type: (str) -> Callable[[str], str]
def val(x):
- # type: (unicode) -> unicode
+ # type: (str) -> str
if x not in l:
raise ValidationError(__('Please enter one of %s.') % ', '.join(l))
return x
@@ -138,14 +136,14 @@ def choice(*l):
def boolean(x):
- # type: (unicode) -> bool
+ # type: (str) -> bool
if x.upper() not in ('Y', 'YES', 'N', 'NO'):
raise ValidationError(__("Please enter either 'y' or 'n'."))
return x.upper() in ('Y', 'YES')
def suffix(x):
- # type: (unicode) -> unicode
+ # type: (str) -> str
if not (x[0:1] == '.' and len(x) > 1):
raise ValidationError(__("Please enter a file suffix, "
"e.g. '.rst' or '.txt'."))
@@ -153,12 +151,12 @@ def suffix(x):
def ok(x):
- # type: (unicode) -> unicode
+ # type: (str) -> str
return x
def term_decode(text):
- # type: (Union[bytes,unicode]) -> unicode
+ # type: (Union[bytes,str]) -> str
if isinstance(text, text_type):
return text
@@ -180,10 +178,10 @@ def term_decode(text):
def do_prompt(text, default=None, validator=nonempty):
- # type: (unicode, unicode, Callable[[unicode], Any]) -> Union[unicode, bool]
+ # type: (str, str, Callable[[str], Any]) -> Union[str, bool]
while True:
if default is not None:
- prompt = PROMPT_PREFIX + '%s [%s]: ' % (text, default) # type: unicode
+ prompt = PROMPT_PREFIX + '%s [%s]: ' % (text, default)
else:
prompt = PROMPT_PREFIX + text + ': '
if USE_LIBEDIT:
@@ -207,7 +205,7 @@ def do_prompt(text, default=None, validator=nonempty):
def convert_python_source(source, rex=re.compile(r"[uU]('.*?')")):
- # type: (unicode, Pattern) -> unicode
+ # type: (str, Pattern) -> str
# remove Unicode literal prefixes
warnings.warn('convert_python_source() is deprecated.',
RemovedInSphinx40Warning)
@@ -216,12 +214,12 @@ def convert_python_source(source, rex=re.compile(r"[uU]('.*?')")):
class QuickstartRenderer(SphinxRenderer):
def __init__(self, templatedir):
- # type: (unicode) -> None
+ # type: (str) -> None
self.templatedir = templatedir or ''
super(QuickstartRenderer, self).__init__()
def render(self, template_name, context):
- # type: (unicode, Dict) -> unicode
+ # type: (str, Dict) -> str
user_template = path.join(self.templatedir, path.basename(template_name))
if self.templatedir and path.exists(user_template):
return self.render_from_file(user_template, context)
@@ -374,7 +372,7 @@ directly.'''))
def generate(d, overwrite=True, silent=False, templatedir=None):
- # type: (Dict, bool, bool, unicode) -> None
+ # type: (Dict, bool, bool, str) -> None
"""Generate project based on values in *d*."""
template = QuickstartRenderer(templatedir=templatedir)
@@ -426,7 +424,7 @@ def generate(d, overwrite=True, silent=False, templatedir=None):
ensuredir(path.join(srcdir, d['dot'] + 'static'))
def write_file(fpath, content, newline=None):
- # type: (unicode, unicode, unicode) -> None
+ # type: (str, str, str) -> None
if overwrite or not path.isfile(fpath):
if 'quiet' not in d:
print(__('Creating file %s.') % fpath)