mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch 'master' into refactor_inventory
This commit is contained in:
commit
e655794b8e
@ -46,7 +46,7 @@ install:
|
||||
- pip install -U pip setuptools
|
||||
- pip install docutils==$DOCUTILS
|
||||
- pip install -r test-reqs.txt
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then python3.6 -m pip install 'mypy==0.471' 'typed-ast<1.0'; fi
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then python3.6 -m pip install mypy typed-ast; fi
|
||||
script:
|
||||
- flake8
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then make style-check type-check test-async; fi
|
||||
|
@ -21,6 +21,10 @@ from os import path
|
||||
|
||||
from .deprecation import RemovedInNextVersionWarning
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import List # NOQA
|
||||
|
||||
# by default, all DeprecationWarning under sphinx package will be emit.
|
||||
# Users can avoid this by using environment variable: PYTHONWARNINGS=
|
||||
if 'PYTHONWARNINGS' not in os.environ:
|
||||
|
@ -13,7 +13,7 @@ from docutils import nodes
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Sequence # NOQA
|
||||
from typing import List, Sequence # NOQA
|
||||
|
||||
|
||||
class translatable(object):
|
||||
|
@ -29,7 +29,7 @@ from sphinx.quickstart import EXTENSIONS
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, List, Tuple # NOQA
|
||||
|
||||
# automodule options
|
||||
if 'SPHINX_APIDOC_OPTIONS' in os.environ:
|
||||
@ -274,7 +274,7 @@ def is_excluded(root, excludes):
|
||||
e.g. an exlude "foo" also accidentally excluding "foobar".
|
||||
"""
|
||||
for exclude in excludes:
|
||||
if fnmatch(root, exclude): # type: ignore
|
||||
if fnmatch(root, exclude):
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -427,6 +427,7 @@ Note: By default this script will not overwrite already created files.""")
|
||||
qs.generate(d, silent=True, overwrite=opts.force)
|
||||
elif not opts.notoc:
|
||||
create_modules_toc_file(modules, opts)
|
||||
return 0
|
||||
|
||||
|
||||
# So program can be started with "python -m sphinx.apidoc ..."
|
||||
|
@ -51,7 +51,7 @@ from sphinx.util.i18n import find_catalog_source_files
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, IO, Iterable, Iterator, Tuple, Type, Union # NOQA
|
||||
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Tuple, Type, Union # NOQA
|
||||
from docutils.parsers import Parser # NOQA
|
||||
from docutils.transform import Transform # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
|
@ -32,7 +32,7 @@ from sphinx import directives # noqa
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Iterable, Sequence, Tuple, Union # NOQA
|
||||
from typing import Any, Callable, Dict, Iterable, List, Sequence, Set, Tuple, Union # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.config import Config # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
@ -49,11 +49,11 @@ class Builder(object):
|
||||
"""
|
||||
|
||||
# builder's name, for the -b command line options
|
||||
name = ''
|
||||
name = '' # type: unicode
|
||||
# builder's output format, or '' if no document output is produced
|
||||
format = ''
|
||||
format = '' # type: unicode
|
||||
# doctree versioning method
|
||||
versioning_method = 'none'
|
||||
versioning_method = 'none' # type: unicode
|
||||
versioning_compare = False
|
||||
# allow parallel write_doc() calls
|
||||
allow_parallel = False
|
||||
@ -88,7 +88,7 @@ class Builder(object):
|
||||
# basename of images directory
|
||||
self.imagedir = ""
|
||||
# relative path to image directory from current docname (used at writing docs)
|
||||
self.imgpath = ""
|
||||
self.imgpath = "" # type: unicode
|
||||
|
||||
# these get set later
|
||||
self.parallel_ok = False
|
||||
|
@ -31,7 +31,7 @@ import subprocess
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any # NOQA
|
||||
from typing import Any, Dict # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ from sphinx.util.pycompat import htmlescape
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ except ImportError:
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any # NOQA
|
||||
from typing import Any, Dict, List # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@ from sphinx.builders import Builder
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any # NOQA
|
||||
from typing import Any, Dict, Set # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
@ -38,7 +38,7 @@ from sphinx.util.smartypants import sphinx_smarty_pants as ssp
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ from sphinx.util.fileutil import copy_asset_file
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterable # NOQA
|
||||
from typing import Any, Dict, Iterable, List # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
@ -31,7 +31,7 @@ from sphinx.locale import pairindextypes
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterable, Tuple # NOQA
|
||||
from typing import Any, Dict, Iterable, List, Set, Tuple # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.util.i18n import CatalogInfo # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
@ -258,7 +258,7 @@ class MessageCatalogBuilder(I18nBuilder):
|
||||
version = self.config.version,
|
||||
copyright = self.config.copyright,
|
||||
project = self.config.project,
|
||||
ctime = datetime.fromtimestamp( # type: ignore
|
||||
ctime = datetime.fromtimestamp(
|
||||
timestamp, ltz).strftime('%Y-%m-%d %H:%M%z'),
|
||||
)
|
||||
for textdomain, catalog in status_iterator(iteritems(self.catalogs), # type: ignore
|
||||
|
@ -52,7 +52,7 @@ from sphinx.environment.adapters.indexentries import IndexEntries
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterable, Iterator, Type, Tuple, Union # NOQA
|
||||
from typing import Any, Dict, Iterable, Iterator, List, Type, Tuple, Union # NOQA
|
||||
from sphinx.domains import Domain, Index # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
@ -96,7 +96,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
allow_parallel = True
|
||||
out_suffix = '.html'
|
||||
link_suffix = '.html' # defaults to matching out_suffix
|
||||
indexer_format = js_index
|
||||
indexer_format = js_index # type: Any
|
||||
indexer_dumps_unicode = True
|
||||
# create links to original images from images [True/False]
|
||||
html_scaled_image_link = True
|
||||
@ -1155,7 +1155,7 @@ class SerializingHTMLBuilder(StandaloneHTMLBuilder):
|
||||
implementation = None # type: Any
|
||||
implementation_dumps_unicode = False
|
||||
#: additional arguments for dump()
|
||||
additional_dump_args = ()
|
||||
additional_dump_args = () # type: Tuple
|
||||
|
||||
#: the filename for the global context file
|
||||
globalcontext_filename = None # type: unicode
|
||||
|
@ -26,7 +26,7 @@ from sphinx.util.pycompat import htmlescape
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, IO, Tuple # NOQA
|
||||
from typing import Any, Dict, IO, List, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ from sphinx.writers.latex import LaTeXWriter
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterable, Tuple, Union # NOQA
|
||||
from typing import Any, Dict, Iterable, List, Tuple, Union # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.config import Config # NOQA
|
||||
|
||||
|
@ -39,7 +39,7 @@ from sphinx.util.requests import is_ssl_error
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple, Union # NOQA
|
||||
from typing import Any, Dict, List, Set, Tuple, Union # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.util.requests.requests import Response # NOQA
|
||||
|
||||
|
@ -27,7 +27,7 @@ from sphinx.writers.manpage import ManualPageWriter
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Union # NOQA
|
||||
from typing import Any, Dict, List, Set, Union # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ from sphinx.util.pycompat import htmlescape
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ from sphinx.writers.texinfo import TexinfoWriter
|
||||
if False:
|
||||
# For type annotation
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from typing import Any, Iterable, Tuple, Union # NOQA
|
||||
from typing import Any, Dict, Iterable, List, Tuple, Union # NOQA
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -21,7 +21,7 @@ from sphinx.writers.text import TextWriter
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterator # NOQA
|
||||
from typing import Any, Dict, Iterator, Set # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
@ -22,7 +22,7 @@ from sphinx.writers.websupport import WebSupportTranslator
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterable, Tuple # NOQA
|
||||
from typing import Any, Dict, Iterable, Tuple # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
@ -22,7 +22,7 @@ from sphinx.writers.xml import XMLWriter, PseudoXMLWriter
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterator # NOQA
|
||||
from typing import Any, Dict, Iterator, Set # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -30,7 +30,7 @@ from sphinx.util.pycompat import terminal_safe
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, IO, Union # NOQA
|
||||
from typing import Any, IO, List, Union # NOQA
|
||||
|
||||
|
||||
USAGE = """\
|
||||
@ -220,12 +220,12 @@ def main(argv):
|
||||
|
||||
# handle remaining filename arguments
|
||||
filenames = args[2:]
|
||||
err = 0 # type: ignore
|
||||
errored = False
|
||||
for filename in filenames:
|
||||
if not path.isfile(filename):
|
||||
print('Error: Cannot find file %r.' % filename, file=sys.stderr)
|
||||
err = 1 # type: ignore
|
||||
if err:
|
||||
errored = True
|
||||
if errored:
|
||||
return 1
|
||||
|
||||
# likely encoding used for command-line arguments
|
||||
|
@ -24,7 +24,7 @@ from sphinx.util.pycompat import execfile_, NoneType
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Iterable, Iterator, Tuple # NOQA
|
||||
from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple # NOQA
|
||||
from sphinx.util.tags import Tags # NOQA
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -237,10 +237,10 @@ class Config(object):
|
||||
'ignoring (use %r to set individual elements)' %
|
||||
(name, name + '.key=value'))
|
||||
elif isinstance(defvalue, list):
|
||||
return value.split(',') # type: ignore
|
||||
return value.split(',')
|
||||
elif isinstance(defvalue, integer_types):
|
||||
try:
|
||||
return int(value) # type: ignore
|
||||
return int(value)
|
||||
except ValueError:
|
||||
raise ValueError('invalid number %r for config value %r, ignoring' %
|
||||
(value, name))
|
||||
|
@ -31,7 +31,7 @@ from sphinx.directives.patches import ( # noqa
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any # NOQA
|
||||
from typing import Any, Dict, List # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
||||
|
@ -23,7 +23,7 @@ from sphinx.util.nodes import set_source_info
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.config import Config # NOQA
|
||||
|
||||
|
@ -24,7 +24,7 @@ from sphinx.util.matching import patfilter
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@ from sphinx.util.nodes import set_source_info
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Dict, List # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -19,11 +19,13 @@ from sphinx.locale import _
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Iterable, Tuple, Type, Union # NOQA
|
||||
from typing import Any, Callable, Dict, Iterable, List, Tuple, Type, Union # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from docutils.parsers.rst.states import Inliner # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
from sphinx.roles import XRefRole # NOQA
|
||||
from sphinx.util.typing import RoleFunction # NOQA
|
||||
|
||||
|
||||
class ObjType(object):
|
||||
@ -143,7 +145,7 @@ class Domain(object):
|
||||
#: directive name -> directive class
|
||||
directives = {} # type: Dict[unicode, Any]
|
||||
#: role name -> role callable
|
||||
roles = {} # type: Dict[unicode, Callable]
|
||||
roles = {} # type: Dict[unicode, Union[RoleFunction, XRefRole]]
|
||||
#: a list of Index subclasses
|
||||
indices = [] # type: List[Type[Index]]
|
||||
#: role name -> a warning message if reference is missing
|
||||
|
@ -24,7 +24,7 @@ from sphinx.util.docfields import Field, TypedField
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterator, Tuple # NOQA
|
||||
from typing import Any, Dict, Iterator, List, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
@ -29,7 +29,7 @@ from sphinx.util.docfields import Field, GroupedField
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterator, Match, Pattern, Tuple, Union # NOQA
|
||||
from typing import Any, Callable, Dict, Iterator, List, Match, Pattern, Tuple, Union # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.config import Config # NOQA
|
||||
@ -539,7 +539,7 @@ class ASTBase(UnicodeMixin):
|
||||
# type: (Any) -> bool
|
||||
return not self.__eq__(other)
|
||||
|
||||
__hash__ = None # type: None
|
||||
__hash__ = None # type: Callable[[], int]
|
||||
|
||||
def clone(self):
|
||||
# type: () -> ASTBase
|
||||
@ -3292,7 +3292,7 @@ class DefinitionParser(object):
|
||||
return DefinitionError(''.join(result))
|
||||
|
||||
def status(self, msg):
|
||||
# type: (unicode) -> unicode
|
||||
# type: (unicode) -> None
|
||||
# for debugging
|
||||
indicator = '-' * self.pos + '^'
|
||||
print("%s\n%s\n%s" % (msg, self.definition, indicator))
|
||||
@ -3373,6 +3373,8 @@ class DefinitionParser(object):
|
||||
# type: () -> unicode
|
||||
if self.last_match is not None:
|
||||
return self.last_match.group()
|
||||
else:
|
||||
return None
|
||||
|
||||
def read_rest(self):
|
||||
# type: () -> unicode
|
||||
|
@ -20,7 +20,7 @@ from sphinx.util.docfields import Field, GroupedField, TypedField
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterator, Tuple # NOQA
|
||||
from typing import Any, Dict, Iterator, List, Tuple # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
|
@ -27,7 +27,7 @@ from sphinx.util.docfields import Field, GroupedField, TypedField
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterable, Iterator, Tuple, Union # NOQA
|
||||
from typing import Any, Dict, Iterable, Iterator, List, Tuple, Union # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
@ -22,7 +22,7 @@ from sphinx.util.nodes import make_refnode
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterator, Tuple # NOQA
|
||||
from typing import Any, Dict, Iterator, List, Tuple # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
|
@ -12,7 +12,7 @@
|
||||
import re
|
||||
import unicodedata
|
||||
|
||||
from six import PY3, iteritems
|
||||
from six import iteritems
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive, directives
|
||||
@ -29,17 +29,10 @@ from sphinx.util.nodes import clean_astext, make_refnode
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Dict, Iterator, List, Tuple, Type, Union # NOQA
|
||||
from docutils.parsers.rst.states import Inliner # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
from sphinx.util.typing import Role # NOQA
|
||||
|
||||
if PY3:
|
||||
unicode = str
|
||||
|
||||
RoleFunction = Callable[[unicode, unicode, unicode, int, Inliner, Dict, List[unicode]],
|
||||
Tuple[List[nodes.Node], List[nodes.Node]]]
|
||||
from sphinx.util.typing import RoleFunction # NOQA
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -54,7 +47,7 @@ class GenericObject(ObjectDescription):
|
||||
"""
|
||||
A generic x-ref directive registered with Sphinx.add_object_type().
|
||||
"""
|
||||
indextemplate = ''
|
||||
indextemplate = '' # type: unicode
|
||||
parse_node = None # type: Callable[[GenericObject, BuildEnvironment, unicode, addnodes.desc_signature], unicode] # NOQA
|
||||
|
||||
def handle_signature(self, sig, signode):
|
||||
|
@ -51,7 +51,7 @@ from sphinx.environment.adapters.toctree import TocTree
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Iterator, Pattern, Tuple, Type, Union # NOQA
|
||||
from typing import Any, Callable, Dict, Iterator, List, Pattern, Set, Tuple, Type, Union # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.config import Config # NOQA
|
||||
@ -320,8 +320,8 @@ class BuildEnvironment(object):
|
||||
if filename.startswith(self.srcdir):
|
||||
filename = filename[len(self.srcdir) + 1:]
|
||||
for suffix in self.config.source_suffix:
|
||||
if fnmatch.fnmatch(filename, '*' + suffix): # type: ignore
|
||||
return filename[:-len(suffix)] # type: ignore
|
||||
if fnmatch.fnmatch(filename, '*' + suffix):
|
||||
return filename[:-len(suffix)]
|
||||
else:
|
||||
# the file does not have docname
|
||||
return None
|
||||
@ -338,14 +338,14 @@ class BuildEnvironment(object):
|
||||
docname = docname.replace(SEP, path.sep)
|
||||
if suffix is None:
|
||||
candidate_suffix = None # type: unicode
|
||||
for candidate_suffix in self.config.source_suffix: # type: ignore
|
||||
for candidate_suffix in self.config.source_suffix:
|
||||
if path.isfile(path.join(self.srcdir, docname) +
|
||||
candidate_suffix):
|
||||
suffix = candidate_suffix
|
||||
break
|
||||
else:
|
||||
# document does not exist
|
||||
suffix = self.config.source_suffix[0] # type: ignore
|
||||
suffix = self.config.source_suffix[0]
|
||||
if base is True:
|
||||
return path.join(self.srcdir, docname) + suffix
|
||||
elif base is None:
|
||||
|
@ -20,7 +20,7 @@ from sphinx.util import iteritems, split_into, logging
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Pattern, Tuple # NOQA
|
||||
from typing import Any, Dict, Pattern, List, Tuple # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
||||
|
@ -19,7 +19,7 @@ from sphinx.util.nodes import clean_astext, process_only_nodes
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any # NOQA
|
||||
from typing import Any, Dict, List # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
||||
|
@ -13,6 +13,7 @@ from six import itervalues
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Dict, List, Set # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.sphinx import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
@ -26,7 +26,7 @@ from sphinx.util.images import guess_mimetype
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Tuple # NOQA
|
||||
from typing import Dict, List, Set, Tuple # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.sphinx import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
@ -18,6 +18,7 @@ from sphinx.environment.collectors import EnvironmentCollector
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Set # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.sphinx import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
@ -15,6 +15,7 @@ from sphinx.environment.collectors import EnvironmentCollector
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Set # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.applicatin import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
@ -15,6 +15,7 @@ from sphinx.environment.collectors import EnvironmentCollector
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Set # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.sphinx import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
@ -16,6 +16,7 @@ from sphinx.transforms import SphinxContentsFilter
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Set # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.sphinx import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
@ -21,7 +21,7 @@ from sphinx.environment.collectors import EnvironmentCollector
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Set, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
@ -40,7 +40,7 @@ from sphinx.util.docstrings import prepare_docstring
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Iterator, Sequence, Tuple, Type, Union # NOQA
|
||||
from typing import Any, Callable, Dict, Iterator, List, Sequence, Set, Tuple, Type, Union # NOQA
|
||||
from types import ModuleType # NOQA
|
||||
from docutils.utils import Reporter # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
@ -482,7 +482,7 @@ class Documenter(object):
|
||||
#: true if the generated content may contain titles
|
||||
titles_allowed = False
|
||||
|
||||
option_spec = {'noindex': bool_option}
|
||||
option_spec = {'noindex': bool_option} # type: Dict[unicode, Callable]
|
||||
|
||||
@staticmethod
|
||||
def get_attr(obj, name, *defargs):
|
||||
@ -1081,7 +1081,7 @@ class ModuleDocumenter(Documenter):
|
||||
'member-order': identity, 'exclude-members': members_set_option,
|
||||
'private-members': bool_option, 'special-members': members_option,
|
||||
'imported-members': bool_option,
|
||||
}
|
||||
} # type: Dict[unicode, Callable]
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member, membername, isattr, parent):
|
||||
@ -1333,7 +1333,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
||||
'show-inheritance': bool_option, 'member-order': identity,
|
||||
'exclude-members': members_set_option,
|
||||
'private-members': bool_option, 'special-members': members_option,
|
||||
}
|
||||
} # type: Dict[unicode, Callable]
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member, membername, isattr, parent):
|
||||
|
@ -76,7 +76,7 @@ from sphinx.ext.autodoc import Options
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple, Type, Union # NOQA
|
||||
from typing import Any, Dict, List, Tuple, Type, Union # NOQA
|
||||
from docutils.utils import Inliner # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
@ -546,8 +546,7 @@ def _import_by_name(name):
|
||||
|
||||
# -- :autolink: (smart default role) -------------------------------------------
|
||||
|
||||
def autolink_role(typ, rawtext, etext, lineno, inliner,
|
||||
options={}, content=[]):
|
||||
def autolink_role(typ, rawtext, etext, lineno, inliner, options={}, content=[]):
|
||||
# type: (unicode, unicode, unicode, int, Inliner, Dict, List[unicode]) -> Tuple[List[nodes.Node], List[nodes.Node]] # NOQA
|
||||
"""Smart linking role.
|
||||
|
||||
@ -555,6 +554,7 @@ def autolink_role(typ, rawtext, etext, lineno, inliner,
|
||||
otherwise expands to '*text*'.
|
||||
"""
|
||||
env = inliner.document.settings.env
|
||||
r = None # type: Tuple[List[nodes.Node], List[nodes.Node]]
|
||||
r = env.get_domain('py').role('obj')(
|
||||
'obj', rawtext, etext, lineno, inliner, options, content)
|
||||
pnode = r[0][0]
|
||||
@ -563,9 +563,9 @@ def autolink_role(typ, rawtext, etext, lineno, inliner,
|
||||
try:
|
||||
name, obj, parent, modname = import_by_name(pnode['reftarget'], prefixes)
|
||||
except ImportError:
|
||||
content = pnode[0]
|
||||
r[0][0] = nodes.emphasis(rawtext, content[0].astext(), # type: ignore
|
||||
classes=content['classes']) # type: ignore
|
||||
content_node = pnode[0]
|
||||
r[0][0] = nodes.emphasis(rawtext, content_node[0].astext(),
|
||||
classes=content_node['classes'])
|
||||
return r
|
||||
|
||||
|
||||
@ -581,7 +581,7 @@ def get_rst_suffix(app):
|
||||
return parser_class.supported
|
||||
|
||||
suffix = None # type: unicode
|
||||
for suffix in app.config.source_suffix: # type: ignore
|
||||
for suffix in app.config.source_suffix:
|
||||
if 'restructuredtext' in get_supported_format(suffix):
|
||||
return suffix
|
||||
|
||||
|
@ -51,7 +51,7 @@ add_documenter(InstanceAttributeDocumenter)
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Tuple, List # NOQA
|
||||
from typing import Any, Callable, Dict, Tuple, List # NOQA
|
||||
from jinja2 import BaseLoader # NOQA
|
||||
from sphinx import addnodes # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
|
@ -25,7 +25,7 @@ from sphinx.util.inspect import safe_getattr
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, IO, Pattern, Tuple # NOQA
|
||||
from typing import Any, Callable, Dict, IO, List, Pattern, Set, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -35,7 +35,7 @@ from sphinx.locale import _
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, IO, Iterable, Sequence, Tuple # NOQA
|
||||
from typing import Any, Callable, Dict, IO, Iterable, List, Sequence, Set, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -32,7 +32,7 @@ from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -28,7 +28,7 @@ from sphinx.util.nodes import set_source_info
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any # NOQA
|
||||
from typing import Any, Dict, List # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ from sphinx.ext.mathbase import setup_math as mathbase_setup, wrap_displaymath
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.ext.mathbase import math as math_node, displaymath # NOQA
|
||||
|
||||
|
@ -45,7 +45,7 @@ except ImportError:
|
||||
from md5 import md5 # type: ignore
|
||||
|
||||
from six import text_type
|
||||
from six.moves import builtins # type: ignore
|
||||
from six.moves import builtins
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive, directives
|
||||
@ -58,7 +58,7 @@ from sphinx.util import force_decode
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
||||
|
@ -45,7 +45,7 @@ from sphinx.util.inventory import InventoryFile
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Dict, IO, Tuple, Union # NOQA
|
||||
from typing import Any, Dict, IO, List, Tuple, Union # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.config import Config # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
@ -18,7 +18,7 @@ from sphinx.errors import SphinxError
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any # NOQA
|
||||
from typing import Any, Dict, Set # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ from sphinx.util.nodes import make_refnode, set_source_info
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Iterable, Tuple # NOQA
|
||||
from typing import Any, Callable, Dict, Iterable, List, Tuple # NOQA
|
||||
from docutils.parsers.rst.states import Inliner # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
|
@ -19,7 +19,7 @@ from sphinx.ext.napoleon.docstring import GoogleDocstring, NumpyDocstring
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any # NOQA
|
||||
from typing import Any, Dict, List # NOQA
|
||||
|
||||
|
||||
class Config(object):
|
||||
|
@ -23,7 +23,7 @@ from sphinx.util.pycompat import UnicodeMixin
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Tuple, Union # NOQA
|
||||
from typing import Any, Callable, Dict, List, Tuple, Union # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.config import Config as SphinxConfig # NOQA
|
||||
|
||||
@ -234,9 +234,9 @@ class GoogleDocstring(UnicodeMixin):
|
||||
if prefer_type and not _type:
|
||||
_type, _name = _name, _type
|
||||
indent = self._get_indent(line) + 1
|
||||
_desc = [_desc] + self._dedent(self._consume_indented_block(indent)) # type: ignore
|
||||
_desc = self.__class__(_desc, self._config).lines()
|
||||
return _name, _type, _desc # type: ignore
|
||||
_descs = [_desc] + self._dedent(self._consume_indented_block(indent))
|
||||
_descs = self.__class__(_descs, self._config).lines()
|
||||
return _name, _type, _descs
|
||||
|
||||
def _consume_fields(self, parse_type=True, prefer_type=False):
|
||||
# type: (bool, bool) -> List[Tuple[unicode, unicode, List[unicode]]]
|
||||
@ -254,9 +254,9 @@ class GoogleDocstring(UnicodeMixin):
|
||||
_type, colon, _desc = self._partition_field_on_colon(line)
|
||||
if not colon:
|
||||
_type, _desc = _desc, _type
|
||||
_desc = [_desc] + self._dedent(self._consume_to_end()) # type: ignore
|
||||
_desc = self.__class__(_desc, self._config).lines()
|
||||
return _type, _desc # type: ignore
|
||||
_descs = [_desc] + self._dedent(self._consume_to_end())
|
||||
_descs = self.__class__(_descs, self._config).lines()
|
||||
return _type, _descs
|
||||
|
||||
def _consume_returns_section(self):
|
||||
# type: () -> List[Tuple[unicode, unicode, List[unicode]]]
|
||||
@ -326,13 +326,13 @@ class GoogleDocstring(UnicodeMixin):
|
||||
def _fix_field_desc(self, desc):
|
||||
# type: (List[unicode]) -> List[unicode]
|
||||
if self._is_list(desc):
|
||||
desc = [''] + desc # type: ignore
|
||||
desc = [u''] + desc
|
||||
elif desc[0].endswith('::'):
|
||||
desc_block = desc[1:]
|
||||
indent = self._get_indent(desc[0])
|
||||
block_indent = self._get_initial_indent(desc_block)
|
||||
if block_indent > indent:
|
||||
desc = [''] + desc # type: ignore
|
||||
desc = [u''] + desc
|
||||
else:
|
||||
desc = ['', desc[0]] + self._indent(desc_block, 4)
|
||||
return desc
|
||||
@ -344,9 +344,9 @@ class GoogleDocstring(UnicodeMixin):
|
||||
return ['.. %s:: %s' % (admonition, lines[0].strip()), '']
|
||||
elif lines:
|
||||
lines = self._indent(self._dedent(lines), 3)
|
||||
return ['.. %s::' % admonition, ''] + lines + [''] # type: ignore
|
||||
return [u'.. %s::' % admonition, u''] + lines + [u'']
|
||||
else:
|
||||
return ['.. %s::' % admonition, '']
|
||||
return [u'.. %s::' % admonition, u'']
|
||||
|
||||
def _format_block(self, prefix, lines, padding=None):
|
||||
# type: (unicode, List[unicode], unicode) -> List[unicode]
|
||||
@ -566,8 +566,8 @@ class GoogleDocstring(UnicodeMixin):
|
||||
lines.append(':vartype %s: %s' % (_name, _type))
|
||||
else:
|
||||
lines.extend(['.. attribute:: ' + _name, ''])
|
||||
field = self._format_field('', _type, _desc) # type: ignore
|
||||
lines.extend(self._indent(field, 3)) # type: ignore
|
||||
fields = self._format_field('', _type, _desc)
|
||||
lines.extend(self._indent(fields, 3))
|
||||
lines.append('')
|
||||
if self._config.napoleon_use_ivar:
|
||||
lines.append('')
|
||||
@ -617,7 +617,7 @@ class GoogleDocstring(UnicodeMixin):
|
||||
for _name, _, _desc in self._consume_fields(parse_type=False):
|
||||
lines.append('.. method:: %s' % _name)
|
||||
if _desc:
|
||||
lines.extend([''] + self._indent(_desc, 3)) # type: ignore
|
||||
lines.extend([u''] + self._indent(_desc, 3))
|
||||
lines.append('')
|
||||
return lines
|
||||
|
||||
|
@ -33,7 +33,7 @@ from sphinx.ext.mathbase import setup_math as mathbase_setup, wrap_displaymath
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.ext.mathbase import math as math_node, displaymath # NOQA
|
||||
|
||||
|
@ -25,7 +25,7 @@ from docutils.parsers.rst.directives.admonitions import BaseAdmonition
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterable # NOQA
|
||||
from typing import Any, Dict, Iterable, List # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
||||
|
@ -24,7 +24,7 @@ from sphinx.util.nodes import make_refnode
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Iterable, Iterator, Tuple # NOQA
|
||||
from typing import Any, Dict, Iterable, Iterator, Set, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
||||
|
@ -29,7 +29,7 @@ from sphinx.pygments_styles import SphinxStyle, NoneStyle
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any # NOQA
|
||||
from typing import Any, Dict # NOQA
|
||||
from pygments.formatter import Formatter # NOQA
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ from sphinx.util.docutils import LoggingReporter
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple, Union # NOQA
|
||||
from typing import Any, Dict, List, Tuple, Union # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from docutils.io import Input # NOQA
|
||||
from docutils.parsers import Parser # NOQA
|
||||
|
@ -24,7 +24,7 @@ from sphinx.util.osutil import mtimes_of_files
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Iterator, Tuple # NOQA
|
||||
from typing import Any, Callable, Dict, List, Iterator, Tuple # NOQA
|
||||
from jinja2.environment import Environment # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.themes import Theme # NOQA
|
||||
|
@ -16,7 +16,7 @@ from six.moves import UserString
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Iterator, Tuple # NOQA
|
||||
from typing import Any, Callable, Dict, Iterator, List, Tuple # NOQA
|
||||
|
||||
|
||||
class _TranslationProxy(UserString, object):
|
||||
|
@ -25,6 +25,10 @@ from sphinx import cmdline
|
||||
from sphinx.util.console import bold, blue # type: ignore
|
||||
from sphinx.util.osutil import cd, rmtree
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import List # NOQA
|
||||
|
||||
proj_name = os.getenv('SPHINXPROJ', '<project>')
|
||||
|
||||
|
||||
@ -79,6 +83,7 @@ class Make(object):
|
||||
print("Removing everything under %r..." % self.builddir)
|
||||
for item in os.listdir(self.builddir):
|
||||
rmtree(self.builddir_join(item))
|
||||
return 0
|
||||
|
||||
def build_help(self):
|
||||
# type: () -> None
|
||||
@ -94,6 +99,7 @@ class Make(object):
|
||||
return 1
|
||||
print()
|
||||
print('Build finished. The HTML pages are in %s.' % self.builddir_join('html'))
|
||||
return 0
|
||||
|
||||
def build_dirhtml(self):
|
||||
# type: () -> int
|
||||
@ -102,6 +108,7 @@ class Make(object):
|
||||
print()
|
||||
print('Build finished. The HTML pages are in %s.' %
|
||||
self.builddir_join('dirhtml'))
|
||||
return 0
|
||||
|
||||
def build_singlehtml(self):
|
||||
# type: () -> int
|
||||
@ -110,6 +117,7 @@ class Make(object):
|
||||
print()
|
||||
print('Build finished. The HTML page is in %s.' %
|
||||
self.builddir_join('singlehtml'))
|
||||
return 0
|
||||
|
||||
def build_pickle(self):
|
||||
# type: () -> int
|
||||
@ -117,6 +125,7 @@ class Make(object):
|
||||
return 1
|
||||
print()
|
||||
print('Build finished; now you can process the pickle files.')
|
||||
return 0
|
||||
|
||||
def build_json(self):
|
||||
# type: () -> int
|
||||
@ -124,6 +133,7 @@ class Make(object):
|
||||
return 1
|
||||
print()
|
||||
print('Build finished; now you can process the JSON files.')
|
||||
return 0
|
||||
|
||||
def build_htmlhelp(self):
|
||||
# type: () -> int
|
||||
@ -132,6 +142,7 @@ class Make(object):
|
||||
print()
|
||||
print('Build finished; now you can run HTML Help Workshop with the '
|
||||
'.hhp project file in %s.' % self.builddir_join('htmlhelp'))
|
||||
return 0
|
||||
|
||||
def build_qthelp(self):
|
||||
# type: () -> int
|
||||
@ -144,6 +155,7 @@ class Make(object):
|
||||
print('To view the help file:')
|
||||
print('$ assistant -collectionFile %s.qhc' %
|
||||
self.builddir_join('qthelp', proj_name))
|
||||
return 0
|
||||
|
||||
def build_devhelp(self):
|
||||
# type: () -> int
|
||||
@ -156,6 +168,7 @@ class Make(object):
|
||||
print("$ ln -s %s $HOME/.local/share/devhelp/%s" %
|
||||
(self.builddir_join('devhelp'), proj_name))
|
||||
print("$ devhelp")
|
||||
return 0
|
||||
|
||||
def build_epub(self):
|
||||
# type: () -> int
|
||||
@ -163,6 +176,7 @@ class Make(object):
|
||||
return 1
|
||||
print()
|
||||
print('Build finished. The ePub file is in %s.' % self.builddir_join('epub'))
|
||||
return 0
|
||||
|
||||
def build_latex(self):
|
||||
# type: () -> int
|
||||
@ -172,6 +186,7 @@ class Make(object):
|
||||
if os.name == 'posix':
|
||||
print("Run `make' in that directory to run these through (pdf)latex")
|
||||
print("(use `make latexpdf' here to do that automatically).")
|
||||
return 0
|
||||
|
||||
def build_latexpdf(self):
|
||||
# type: () -> int
|
||||
@ -179,6 +194,7 @@ class Make(object):
|
||||
return 1
|
||||
with cd(self.builddir_join('latex')):
|
||||
os.system('%s all-pdf' % self.makecmd)
|
||||
return 0
|
||||
|
||||
def build_latexpdfja(self):
|
||||
# type: () -> int
|
||||
@ -186,6 +202,7 @@ class Make(object):
|
||||
return 1
|
||||
with cd(self.builddir_join('latex')):
|
||||
os.system('%s all-pdf-ja' % self.makecmd)
|
||||
return 0
|
||||
|
||||
def build_text(self):
|
||||
# type: () -> int
|
||||
@ -193,6 +210,7 @@ class Make(object):
|
||||
return 1
|
||||
print()
|
||||
print('Build finished. The text files are in %s.' % self.builddir_join('text'))
|
||||
return 0
|
||||
|
||||
def build_texinfo(self):
|
||||
# type: () -> int
|
||||
@ -203,6 +221,7 @@ class Make(object):
|
||||
if os.name == 'posix':
|
||||
print("Run `make' in that directory to run these through makeinfo")
|
||||
print("(use `make info' here to do that automatically).")
|
||||
return 0
|
||||
|
||||
def build_info(self):
|
||||
# type: () -> int
|
||||
@ -210,6 +229,7 @@ class Make(object):
|
||||
return 1
|
||||
with cd(self.builddir_join('texinfo')):
|
||||
os.system('%s info' % self.makecmd)
|
||||
return 0
|
||||
|
||||
def build_gettext(self):
|
||||
# type: () -> int
|
||||
@ -219,6 +239,7 @@ class Make(object):
|
||||
print()
|
||||
print('Build finished. The message catalogs are in %s.' %
|
||||
self.builddir_join('gettext'))
|
||||
return 0
|
||||
|
||||
def build_changes(self):
|
||||
# type: () -> int
|
||||
@ -227,6 +248,7 @@ class Make(object):
|
||||
print()
|
||||
print('Build finished. The overview file is in %s.' %
|
||||
self.builddir_join('changes'))
|
||||
return 0
|
||||
|
||||
def build_linkcheck(self):
|
||||
# type: () -> int
|
||||
@ -251,6 +273,7 @@ class Make(object):
|
||||
print()
|
||||
print("Testing of coverage in the sources finished, look at the "
|
||||
"results in %s." % self.builddir_join('coverage'))
|
||||
return 0
|
||||
|
||||
def build_xml(self):
|
||||
# type: () -> int
|
||||
@ -258,6 +281,7 @@ class Make(object):
|
||||
return 1
|
||||
print()
|
||||
print('Build finished. The XML files are in %s.' % self.builddir_join('xml'))
|
||||
return 0
|
||||
|
||||
def build_pseudoxml(self):
|
||||
# type: () -> int
|
||||
@ -266,6 +290,7 @@ class Make(object):
|
||||
print()
|
||||
print('Build finished. The pseudo-XML files are in %s.' %
|
||||
self.builddir_join('pseudoxml'))
|
||||
return 0
|
||||
|
||||
def run_generic_build(self, builder, doctreedir=None):
|
||||
# type: (unicode, unicode) -> int
|
||||
|
@ -26,7 +26,7 @@ from sphinx.util.docstrings import prepare_docstring, prepare_commentdoc
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
|
||||
|
||||
# load the Python grammar
|
||||
|
@ -9,6 +9,10 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Callable # NOQA
|
||||
|
||||
|
||||
class BaseNode(object):
|
||||
"""
|
||||
@ -29,7 +33,7 @@ class BaseNode(object):
|
||||
return NotImplemented
|
||||
return not self._eq(other)
|
||||
|
||||
__hash__ = None # type: str
|
||||
__hash__ = None # type: Callable[[object], int]
|
||||
|
||||
def get_prev_sibling(self):
|
||||
"""Return previous child in parent's children, or None."""
|
||||
|
@ -21,7 +21,7 @@ from sphinx.pycode.pgen2 import token
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Tuple # NOQA
|
||||
from typing import Dict, List, Tuple # NOQA
|
||||
|
||||
|
||||
class Grammar(object):
|
||||
|
@ -15,7 +15,7 @@ from sphinx.pycode.pgen2 import token
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, List, Set, Tuple # NOQA
|
||||
|
||||
class ParseError(Exception):
|
||||
"""Exception to signal the parser is stuck."""
|
||||
|
@ -11,7 +11,7 @@ from sphinx.pycode.pgen2 import grammar, token, tokenize
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
|
||||
|
||||
class PgenGrammar(grammar.Grammar):
|
||||
|
@ -37,6 +37,10 @@ from six import PY3
|
||||
from sphinx.pycode.pgen2.token import *
|
||||
from sphinx.pycode.pgen2 import token
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import List # NOQA
|
||||
|
||||
__all__ = [x for x in dir(token) if x[0] != '_'] + ["tokenize",
|
||||
"generate_tokens", "untokenize"]
|
||||
del token
|
||||
|
@ -44,7 +44,7 @@ from sphinx.util import texescape
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Pattern # NOQA
|
||||
from typing import Any, Callable, Dict, List, Pattern # NOQA
|
||||
|
||||
TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
|
||||
|
||||
@ -108,11 +108,11 @@ def nonempty(x):
|
||||
|
||||
|
||||
def choice(*l):
|
||||
# type: (List[unicode]) -> Callable[[unicode], unicode]
|
||||
# type: (unicode) -> Callable[[unicode], unicode]
|
||||
def val(x):
|
||||
# type: (unicode) -> unicode
|
||||
if x not in l:
|
||||
raise ValidationError('Please enter one of %s.' % ', '.join(l)) # type: ignore
|
||||
raise ValidationError('Please enter one of %s.' % ', '.join(l))
|
||||
return x
|
||||
return val
|
||||
|
||||
@ -708,6 +708,7 @@ def main(argv=sys.argv):
|
||||
print('Invalid template variable: %s' % variable)
|
||||
|
||||
generate(d, templatedir=opts.templatedir)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -23,7 +23,7 @@ from sphinx.util.nodes import split_explicit_title, process_index_entry, \
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple, Type # NOQA
|
||||
from typing import Any, Dict, List, Tuple, Type # NOQA
|
||||
from docutils.parsers.rst.states import Inliner # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
@ -180,8 +180,7 @@ class AnyXRefRole(XRefRole):
|
||||
return result
|
||||
|
||||
|
||||
def indexmarkup_role(typ, rawtext, text, lineno, inliner,
|
||||
options={}, content=[]):
|
||||
def indexmarkup_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||
# type: (unicode, unicode, unicode, int, Inliner, Dict, List[unicode]) -> Tuple[List[nodes.Node], List[nodes.Node]] # NOQA
|
||||
"""Role for PEP/RFC references that generate an index entry."""
|
||||
env = inliner.document.settings.env
|
||||
@ -241,6 +240,8 @@ def indexmarkup_role(typ, rawtext, text, lineno, inliner,
|
||||
classes=[typ])
|
||||
rn += sn
|
||||
return [indexnode, targetnode, rn], []
|
||||
else:
|
||||
raise ValueError('unknown role type: %s' % typ)
|
||||
|
||||
|
||||
_amp_re = re.compile(r'(?<!&)&(?![&\s])')
|
||||
|
@ -23,7 +23,7 @@ from sphinx.search.jssplitter import splitter_code
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, IO, Iterable, Tuple, Type # NOQA
|
||||
from typing import Any, Dict, IO, Iterable, List, Tuple, Type, Set # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
||||
@ -63,7 +63,7 @@ var Stemmer = function() {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
"""
|
||||
""" # type: unicode
|
||||
|
||||
_word_re = re.compile(r'\w+(?u)')
|
||||
|
||||
@ -287,7 +287,7 @@ class IndexBuilder(object):
|
||||
# type: (IO, Any) -> None
|
||||
"""Reconstruct from frozen data."""
|
||||
if isinstance(format, string_types):
|
||||
format = self.formats[format] # type: ignore
|
||||
format = self.formats[format]
|
||||
frozen = format.load(stream)
|
||||
# if an old index is present, we treat it as not existing.
|
||||
if not isinstance(frozen, dict) or \
|
||||
@ -315,7 +315,7 @@ class IndexBuilder(object):
|
||||
# type: (IO, Any) -> None
|
||||
"""Dump the frozen index to a stream."""
|
||||
if isinstance(format, string_types):
|
||||
format = self.formats[format] # type: ignore
|
||||
format = self.formats[format]
|
||||
format.dump(self.freeze(), stream)
|
||||
|
||||
def get_objects(self, fn2index):
|
||||
@ -456,3 +456,5 @@ class IndexBuilder(object):
|
||||
'non-minified-js',
|
||||
self.lang.js_stemmer_rawcode
|
||||
)
|
||||
else:
|
||||
return None
|
||||
|
@ -12,7 +12,11 @@
|
||||
from sphinx.search import SearchLanguage
|
||||
from sphinx.util.stemmer import get_stemmer
|
||||
|
||||
english_stopwords = set("""
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Dict # NOQA
|
||||
|
||||
english_stopwords = set(u"""
|
||||
a and are as at
|
||||
be but by
|
||||
for
|
||||
|
@ -39,6 +39,10 @@ from sphinx.errors import SphinxError, ExtensionError
|
||||
from sphinx.search import SearchLanguage
|
||||
from sphinx.util import import_object
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Dict, List # NOQA
|
||||
|
||||
|
||||
class BaseSplitter(object):
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -21,7 +21,11 @@ try:
|
||||
except ImportError:
|
||||
JIEBA = False
|
||||
|
||||
english_stopwords = set("""
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Dict, List # NOQA
|
||||
|
||||
english_stopwords = set(u"""
|
||||
a and are as at
|
||||
be but by
|
||||
for
|
||||
|
@ -28,7 +28,7 @@ from sphinx.util.osutil import abspath
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, List, Tuple # NOQA
|
||||
|
||||
|
||||
class BuildDoc(Command):
|
||||
|
@ -16,8 +16,7 @@ import tempfile
|
||||
from os import path
|
||||
|
||||
from six import string_types, iteritems
|
||||
from six.moves import configparser # type: ignore
|
||||
from typing import Any, Callable, Tuple # NOQA
|
||||
from six.moves import configparser
|
||||
|
||||
try:
|
||||
import pkg_resources
|
||||
@ -32,7 +31,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Tuple # NOQA
|
||||
from typing import Any, Callable, Dict, List, Tuple # NOQA
|
||||
|
||||
NODEFAULT = object()
|
||||
THEMECONF = 'theme.conf'
|
||||
@ -148,7 +147,7 @@ class Theme(object):
|
||||
fp.write(tinfo.read(name))
|
||||
|
||||
self.themeconf = configparser.RawConfigParser()
|
||||
self.themeconf.read(path.join(self.themedir, THEMECONF))
|
||||
self.themeconf.read(path.join(self.themedir, THEMECONF)) # type: ignore
|
||||
|
||||
try:
|
||||
inherit = self.themeconf.get('theme', 'inherit')
|
||||
@ -172,7 +171,7 @@ class Theme(object):
|
||||
base theme chain.
|
||||
"""
|
||||
try:
|
||||
return self.themeconf.get(section, name)
|
||||
return self.themeconf.get(section, name) # type: ignore
|
||||
except (configparser.NoOptionError, configparser.NoSectionError):
|
||||
if self.base is not None:
|
||||
return self.base.get_confstr(section, name, default)
|
||||
@ -245,7 +244,7 @@ def load_theme_plugins():
|
||||
path = func_or_path
|
||||
|
||||
if isinstance(path, string_types):
|
||||
theme_paths.append(path) # type: ignore
|
||||
theme_paths.append(path)
|
||||
else:
|
||||
raise ThemeError('Plugin %r does not response correctly.' %
|
||||
plugin.module_name)
|
||||
|
@ -29,7 +29,7 @@ from sphinx.domains.std import make_glossary_term, split_term_classifiers
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
from sphinx.config import Config # NOQA
|
||||
|
||||
|
@ -45,7 +45,7 @@ from sphinx.util.matching import patfilter # noqa
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, IO, Iterable, Iterator, Pattern, Sequence, Tuple, Union # NOQA
|
||||
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Pattern, Sequence, Set, Tuple, Union # NOQA
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -109,7 +109,7 @@ def get_matching_docs(dirname, suffixes, exclude_matchers=()):
|
||||
suffixpatterns = ['*' + s for s in suffixes]
|
||||
for filename in get_matching_files(dirname, exclude_matchers):
|
||||
for suffixpattern in suffixpatterns:
|
||||
if fnmatch.fnmatch(filename, suffixpattern): # type: ignore
|
||||
if fnmatch.fnmatch(filename, suffixpattern):
|
||||
yield filename[:-len(suffixpattern) + 1]
|
||||
break
|
||||
|
||||
|
@ -22,7 +22,7 @@ docutils_version = tuple(int(x) for x in _du_version.split('.')[:2])
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any # NOQA
|
||||
from typing import Any, Dict # NOQA
|
||||
|
||||
|
||||
class _DeprecationWrapper(object):
|
||||
|
@ -19,6 +19,11 @@ try:
|
||||
except ImportError:
|
||||
colorama = None
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Dict # NOQA
|
||||
|
||||
|
||||
_ansi_re = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm')
|
||||
codes = {} # type: Dict[str, str]
|
||||
|
||||
|
@ -17,7 +17,7 @@ from sphinx import addnodes
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
from sphinx.domains import Domain # NOQA
|
||||
|
||||
|
||||
|
@ -11,6 +11,10 @@
|
||||
|
||||
import sys
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import List # NOQA
|
||||
|
||||
|
||||
def prepare_docstring(s, ignore=1):
|
||||
# type: (unicode, int) -> List[unicode]
|
||||
|
@ -24,10 +24,9 @@ logger = logging.getLogger(__name__)
|
||||
report_re = re.compile('^(.+?:\\d+): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\\d+)?\\) '
|
||||
'(.+?)\n?$')
|
||||
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Iterator, Tuple # NOQA
|
||||
from typing import Any, Callable, Iterator, List, Tuple # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
||||
|
@ -18,7 +18,7 @@ from sphinx.util.osutil import copyfile, ensuredir, walk
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Callable, Union # NOQA
|
||||
from typing import Callable, Dict, Union # NOQA
|
||||
from sphinx.util.matching import Matcher # NOQA
|
||||
from sphinx.util.template import BaseRenderer # NOQA
|
||||
|
||||
|
@ -28,7 +28,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Callable # NOQA
|
||||
from typing import Callable, List, Set # NOQA
|
||||
from sphinx.environment import BuildEnvironment # NOQA
|
||||
|
||||
LocaleFileInfoBase = namedtuple('CatalogInfo', 'base_dir,domain,charset')
|
||||
|
@ -23,7 +23,7 @@ except ImportError:
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Tuple # NOQA
|
||||
from typing import Dict, List, Tuple # NOQA
|
||||
|
||||
mime_suffixes = {
|
||||
'.pdf': 'application/pdf',
|
||||
|
@ -12,13 +12,13 @@
|
||||
import re
|
||||
|
||||
from six import PY3, binary_type
|
||||
from six.moves import builtins # type: ignore
|
||||
from six.moves import builtins
|
||||
|
||||
from sphinx.util import force_decode
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Tuple, Type # NOQA
|
||||
from typing import Any, Callable, List, Tuple, Type # NOQA
|
||||
|
||||
# this imports the standard library inspect module without resorting to
|
||||
# relatively import this module
|
||||
|
@ -18,7 +18,7 @@ from sphinx.util.pycompat import u
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, IO, Match, Union # NOQA
|
||||
from typing import Any, Dict, IO, List, Match, Union # NOQA
|
||||
|
||||
_str_re = re.compile(r'"(\\\\|\\"|[^"])*"')
|
||||
_int_re = re.compile(r'\d+')
|
||||
@ -124,7 +124,7 @@ def loads(x):
|
||||
i = 0
|
||||
n = len(x)
|
||||
stack = [] # type: List[Union[List, Dict]]
|
||||
obj = nothing
|
||||
obj = nothing # type: Any
|
||||
key = False
|
||||
keys = []
|
||||
while i < n:
|
||||
@ -204,7 +204,7 @@ def loads(x):
|
||||
obj[keys[-1]] = y
|
||||
key = False
|
||||
else:
|
||||
obj.append(y) # type: ignore
|
||||
obj.append(y)
|
||||
if obj is nothing:
|
||||
raise ValueError("nothing loaded from string")
|
||||
return obj
|
||||
|
@ -29,7 +29,7 @@ class SphinxJSONEncoder(json.JSONEncoder):
|
||||
|
||||
|
||||
def dump(obj, fp, *args, **kwds):
|
||||
# type: (Any, IO, Any, Any) -> unicode
|
||||
# type: (Any, IO, Any, Any) -> None
|
||||
kwds['cls'] = SphinxJSONEncoder
|
||||
json.dump(obj, fp, *args, **kwds)
|
||||
|
||||
|
@ -24,7 +24,7 @@ from sphinx.util.console import colorize
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Generator, IO, Tuple, Union # NOQA
|
||||
from typing import Any, Dict, Generator, IO, List, Tuple, Union # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
@ -13,7 +13,7 @@ import re
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Callable, Match, Pattern # NOQA
|
||||
from typing import Callable, Dict, List, Match, Pattern # NOQA
|
||||
|
||||
|
||||
def _translate_pattern(pat):
|
||||
|
@ -22,7 +22,7 @@ from sphinx.util import logging
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Iterable, Tuple, Union # NOQA
|
||||
from typing import Any, Callable, Iterable, List, Set, Tuple, Union # NOQA
|
||||
from sphinx.builders import Builder # NOQA
|
||||
from sphinx.utils.tags import Tags # NOQA
|
||||
|
||||
@ -182,6 +182,7 @@ def find_source_node(node):
|
||||
for pnode in traverse_parent(node):
|
||||
if pnode.source:
|
||||
return pnode.source
|
||||
return None
|
||||
|
||||
|
||||
def traverse_parent(node, cls=None):
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user