Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-06-29 19:12:17 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-06-29 19:27:43 +0300
commit9148b6e653fd416e185fa2a1d5c91df279999831 (patch)
treee1de8dc45ffa842052a497d2e85dd7a6b8971ca9 /sphinx/cmd
parent5cc5c53435bd933cf93d09700324e8b808eee39e (diff)
Migrate to py3 style type annotation: sphinx.cmd.make_mode
Diffstat (limited to 'sphinx/cmd')
-rw-r--r--sphinx/cmd/make_mode.py36
1 files changed, 11 insertions, 25 deletions
diff --git a/sphinx/cmd/make_mode.py b/sphinx/cmd/make_mode.py
index e87aa02fc..508b60959 100644
--- a/sphinx/cmd/make_mode.py
+++ b/sphinx/cmd/make_mode.py
@@ -18,16 +18,13 @@ import os
import subprocess
import sys
from os import path
+from typing import List
import sphinx
from sphinx.cmd.build import build_main
from sphinx.util.console import color_terminal, nocolor, bold, blue # type: ignore
from sphinx.util.osutil import cd, rmtree
-if False:
- # For type annotation
- from typing import List # NOQA
-
BUILDERS = [
("", "html", "to make standalone HTML files"),
@@ -58,20 +55,16 @@ BUILDERS = [
class Make:
-
- def __init__(self, srcdir, builddir, opts):
- # type: (str, str, List[str]) -> None
+ def __init__(self, srcdir: str, builddir: str, opts: List[str]) -> None:
self.srcdir = srcdir
self.builddir = builddir
self.opts = opts
self.makecmd = os.environ.get('MAKE', 'make') # refer $MAKE to determine make command
- def builddir_join(self, *comps):
- # type: (str) -> str
+ def builddir_join(self, *comps: str) -> str:
return path.join(self.builddir, *comps)
- def build_clean(self):
- # type: () -> int
+ def build_clean(self) -> int:
srcdir = path.abspath(self.srcdir)
builddir = path.abspath(self.builddir)
if not path.exists(self.builddir):
@@ -90,8 +83,7 @@ class Make:
rmtree(self.builddir_join(item))
return 0
- def build_help(self):
- # type: () -> None
+ def build_help(self) -> None:
if not color_terminal():
nocolor()
@@ -101,8 +93,7 @@ class Make:
if not osname or os.name == osname:
print(' %s %s' % (blue(bname.ljust(10)), description))
- def build_latexpdf(self):
- # type: () -> int
+ def build_latexpdf(self) -> int:
if self.run_generic_build('latex') > 0:
return 1
@@ -117,8 +108,7 @@ class Make:
print('Error: Failed to run: %s' % makecmd)
return 1
- def build_latexpdfja(self):
- # type: () -> int
+ def build_latexpdfja(self) -> int:
if self.run_generic_build('latex') > 0:
return 1
@@ -133,8 +123,7 @@ class Make:
print('Error: Failed to run: %s' % makecmd)
return 1
- def build_info(self):
- # type: () -> int
+ def build_info(self) -> int:
if self.run_generic_build('texinfo') > 0:
return 1
try:
@@ -144,15 +133,13 @@ class Make:
print('Error: Failed to run: %s' % self.makecmd)
return 1
- def build_gettext(self):
- # type: () -> int
+ def build_gettext(self) -> int:
dtdir = self.builddir_join('gettext', '.doctrees')
if self.run_generic_build('gettext', doctreedir=dtdir) > 0:
return 1
return 0
- def run_generic_build(self, builder, doctreedir=None):
- # type: (str, str) -> int
+ def run_generic_build(self, builder: str, doctreedir: str = None) -> int:
# compatibility with old Makefile
papersize = os.getenv('PAPER', '')
opts = self.opts
@@ -168,8 +155,7 @@ class Make:
return build_main(args + opts)
-def run_make_mode(args):
- # type: (List[str]) -> int
+def run_make_mode(args: List[str]) -> int:
if len(args) < 3:
print('Error: at least 3 arguments (builder, source '
'dir, build dir) are required.', file=sys.stderr)