summaryrefslogtreecommitdiff
path: root/sphinx/cmd/make_mode.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-07-01 00:29:51 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-07-01 00:29:51 +0900
commit75477633b69b11858ae27c27f3af6e3ff2db928f (patch)
treea1d5b1bd3ffdc01fabd3ae594b1066ff25505eaf /sphinx/cmd/make_mode.py
parent852c061cc64e2876ec206e5a7a116a40caf3fac6 (diff)
parent95723aa6f648597682ff4107250fb042ddb40f50 (diff)
downloadsphinx-git-75477633b69b11858ae27c27f3af6e3ff2db928f.tar.gz
Merge branch '2.0'
Diffstat (limited to 'sphinx/cmd/make_mode.py')
-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)