mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '1.6-release'
This commit is contained in:
commit
5a9b78ed84
1
CHANGES
1
CHANGES
@ -77,6 +77,7 @@ Bugs fixed
|
||||
1.5 series, due to hard-coded usage of ``--halt-on-error`` option. (refs #3695)
|
||||
* #3683: sphinx.websupport module is not provided by default
|
||||
* #3683: Failed to build document if builder.css_file.insert() is called
|
||||
* #3714: viewcode extension not taking ``highlight_code='none'`` in account
|
||||
* #3698: Moving :doc: to std domain broke backwards compatibility
|
||||
|
||||
Testing
|
||||
|
1
mypy.ini
1
mypy.ini
@ -2,7 +2,6 @@
|
||||
python_version = 2.7
|
||||
ignore_missing_imports = True
|
||||
follow_imports = skip
|
||||
fast_parser = True
|
||||
incremental = True
|
||||
check_untyped_defs = True
|
||||
warn_unused_ignores = True
|
||||
|
@ -58,7 +58,7 @@ if __version__.endswith('+'):
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
out, err = p.communicate()
|
||||
if out:
|
||||
__display_version__ += '/' + out.decode().strip() # type: ignore
|
||||
__display_version__ += '/' + out.decode().strip()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
@ -190,7 +190,7 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
||||
|
||||
# Build the access page
|
||||
logger.info(bold('building access page...'), nonl=True)
|
||||
with codecs.open(path.join(language_dir, '_access.html'), 'w') as f:
|
||||
with codecs.open(path.join(language_dir, '_access.html'), 'w') as f: # type: ignore
|
||||
f.write(access_page_template % {
|
||||
'toc': htmlescape(toc, quote=True),
|
||||
'title': htmlescape(self.config.applehelp_title)
|
||||
|
@ -31,7 +31,7 @@ from sphinx.locale import pairindextypes
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Dict, Iterable, List, Set, Tuple # NOQA
|
||||
from typing import Any, DefaultDict, Dict, Iterable, List, Set, Tuple # NOQA
|
||||
from docutils import nodes # NOQA
|
||||
from sphinx.util.i18n import CatalogInfo # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
@ -122,7 +122,7 @@ class I18nBuilder(Builder):
|
||||
self.env.set_versioning_method(self.versioning_method,
|
||||
self.env.config.gettext_uuid)
|
||||
self.tags = I18nTags()
|
||||
self.catalogs = defaultdict(Catalog) # type: defaultdict[unicode, Catalog]
|
||||
self.catalogs = defaultdict(Catalog) # type: DefaultDict[unicode, Catalog]
|
||||
|
||||
def get_target_uri(self, docname, typ=None):
|
||||
# type: (unicode, unicode) -> unicode
|
||||
|
@ -390,7 +390,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
# typically doesn't include the time of day
|
||||
lufmt = self.config.html_last_updated_fmt
|
||||
if lufmt is not None:
|
||||
self.last_updated = format_date(lufmt or _('%b %d, %Y'),
|
||||
self.last_updated = format_date(lufmt or _('%b %d, %Y'), # type: ignore
|
||||
language=self.config.language)
|
||||
else:
|
||||
self.last_updated = None
|
||||
@ -823,7 +823,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
else:
|
||||
f = open(searchindexfn, 'rb') # type: ignore
|
||||
with f:
|
||||
self.indexer.load(f, self.indexer_format) # type: ignore
|
||||
self.indexer.load(f, self.indexer_format)
|
||||
except (IOError, OSError, ValueError):
|
||||
if keep:
|
||||
logger.warning('search index couldn\'t be loaded, but not all '
|
||||
@ -993,7 +993,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
else:
|
||||
f = open(searchindexfn + '.tmp', 'wb') # type: ignore
|
||||
with f:
|
||||
self.indexer.dump(f, self.indexer_format) # type: ignore
|
||||
self.indexer.dump(f, self.indexer_format)
|
||||
movefile(searchindexfn + '.tmp', searchindexfn)
|
||||
logger.info('done')
|
||||
|
||||
|
@ -16,7 +16,7 @@ import threading
|
||||
from os import path
|
||||
|
||||
from requests.exceptions import HTTPError
|
||||
from six.moves import queue, html_parser # type: ignore
|
||||
from six.moves import queue, html_parser
|
||||
from six.moves.urllib.parse import unquote
|
||||
from docutils import nodes
|
||||
|
||||
@ -105,8 +105,8 @@ class CheckExternalLinksBuilder(Builder):
|
||||
open(path.join(self.outdir, 'output.txt'), 'w').close()
|
||||
|
||||
# create queues and worker threads
|
||||
self.wqueue = queue.Queue()
|
||||
self.rqueue = queue.Queue()
|
||||
self.wqueue = queue.Queue() # type: queue.Queue
|
||||
self.rqueue = queue.Queue() # type: queue.Queue
|
||||
self.workers = [] # type: List[threading.Thread]
|
||||
for i in range(self.app.config.linkcheck_workers):
|
||||
thread = threading.Thread(target=self.check_thread)
|
||||
|
@ -206,7 +206,7 @@ class QtHelpBuilder(StandaloneHTMLBuilder):
|
||||
|
||||
# write the project file
|
||||
with codecs.open(path.join(outdir, outname + '.qhp'), 'w', 'utf-8') as f: # type: ignore # NOQA
|
||||
f.write(project_template % { # type: ignore
|
||||
f.write(project_template % {
|
||||
'outname': htmlescape(outname),
|
||||
'title': htmlescape(self.config.html_title),
|
||||
'version': htmlescape(self.config.version),
|
||||
@ -223,7 +223,7 @@ class QtHelpBuilder(StandaloneHTMLBuilder):
|
||||
|
||||
logger.info('writing collection project file...')
|
||||
with codecs.open(path.join(outdir, outname + '.qhcp'), 'w', 'utf-8') as f: # type: ignore # NOQA
|
||||
f.write(collection_template % { # type: ignore
|
||||
f.write(collection_template % {
|
||||
'outname': htmlescape(outname),
|
||||
'title': htmlescape(self.config.html_short_title),
|
||||
'homepage': htmlescape(homepage),
|
||||
|
@ -48,7 +48,7 @@ try:
|
||||
if sys.version_info >= (3,):
|
||||
import typing
|
||||
else:
|
||||
typing = None # type: ignore
|
||||
typing = None
|
||||
except ImportError:
|
||||
typing = None
|
||||
|
||||
|
@ -259,8 +259,7 @@ def find_autosummary_in_files(filenames):
|
||||
with codecs.open(filename, 'r', encoding='utf-8', # type: ignore
|
||||
errors='ignore') as f:
|
||||
lines = f.read().splitlines()
|
||||
documented.extend(find_autosummary_in_lines(lines, # type: ignore
|
||||
filename=filename))
|
||||
documented.extend(find_autosummary_in_lines(lines, filename=filename))
|
||||
return documented
|
||||
|
||||
|
||||
@ -273,7 +272,7 @@ def find_autosummary_in_docstring(name, module=None, filename=None):
|
||||
try:
|
||||
real_name, obj, parent, modname = import_by_name(name)
|
||||
lines = pydoc.getdoc(obj).splitlines()
|
||||
return find_autosummary_in_lines(lines, module=name, filename=filename)
|
||||
return find_autosummary_in_lines(lines, module=name, filename=filename) # type: ignore
|
||||
except AttributeError:
|
||||
pass
|
||||
except ImportError as e:
|
||||
|
@ -307,7 +307,7 @@ class DocTestBuilder(Builder):
|
||||
self.outfile = None # type: IO
|
||||
self.outfile = codecs.open(path.join(self.outdir, 'output.txt'), # type: ignore
|
||||
'w', encoding='utf-8')
|
||||
self.outfile.write(('Results of doctest builder run on %s\n' # type: ignore
|
||||
self.outfile.write(('Results of doctest builder run on %s\n'
|
||||
'==================================%s\n') %
|
||||
(date, '=' * len(date)))
|
||||
|
||||
|
@ -66,7 +66,7 @@ def process_ifconfig_nodes(app, doctree, docname):
|
||||
except Exception as err:
|
||||
# handle exceptions in a clean fashion
|
||||
from traceback import format_exception_only
|
||||
msg = ''.join(format_exception_only(err.__class__, err)) # type: ignore
|
||||
msg = ''.join(format_exception_only(err.__class__, err))
|
||||
newnode = doctree.reporter.error('Exception occured in '
|
||||
'ifconfig expression: \n%s' %
|
||||
msg, base_node=node)
|
||||
|
@ -42,7 +42,7 @@ import inspect
|
||||
try:
|
||||
from hashlib import md5
|
||||
except ImportError:
|
||||
from md5 import md5 # type: ignore
|
||||
from md5 import md5
|
||||
|
||||
from six import text_type
|
||||
from six.moves import builtins
|
||||
|
@ -156,7 +156,7 @@ def collect_pages(app):
|
||||
# construct a page name for the highlighted source
|
||||
pagename = '_modules/' + modname.replace('.', '/')
|
||||
# highlight the source using the builder's highlighter
|
||||
if env.config.highlight_language in ('python3', 'default'):
|
||||
if env.config.highlight_language in ('python3', 'default', 'none'):
|
||||
lexer = env.config.highlight_language
|
||||
else:
|
||||
lexer = 'python'
|
||||
|
@ -557,7 +557,7 @@ def valid_dir(d):
|
||||
|
||||
|
||||
class MyFormatter(optparse.IndentedHelpFormatter):
|
||||
def format_usage(self, usage):
|
||||
def format_usage(self, usage): # type: ignore
|
||||
# type: (str) -> str
|
||||
return usage
|
||||
|
||||
|
@ -133,7 +133,7 @@ class SphinxComponentRegistry(object):
|
||||
directive = type(directivename, # type: ignore
|
||||
(GenericObject, object),
|
||||
{'indextemplate': indextemplate,
|
||||
'parse_node': staticmethod(parse_node), # type: ignore
|
||||
'parse_node': staticmethod(parse_node),
|
||||
'doc_field_types': doc_field_types})
|
||||
|
||||
stddomain = self.domains['std']
|
||||
|
@ -41,7 +41,7 @@ from sphinx.util import import_object
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Dict, List # NOQA
|
||||
from typing import Any, Dict, List # NOQA
|
||||
|
||||
|
||||
class BaseSplitter(object):
|
||||
@ -65,8 +65,8 @@ class MecabSplitter(BaseSplitter):
|
||||
def __init__(self, options):
|
||||
# type: (Dict) -> None
|
||||
super(MecabSplitter, self).__init__(options)
|
||||
self.ctypes_libmecab = None # type: ignore
|
||||
self.ctypes_mecab = None # type: ignore
|
||||
self.ctypes_libmecab = None # type: Any
|
||||
self.ctypes_mecab = None # type: Any
|
||||
if not native_module:
|
||||
self.init_ctypes(options)
|
||||
else:
|
||||
|
@ -116,7 +116,7 @@ class DefaultSubstitutions(SphinxTransform):
|
||||
text = self.config[refname]
|
||||
if refname == 'today' and not text:
|
||||
# special handling: can also specify a strftime format
|
||||
text = format_date(self.config.today_fmt or _('%b %d, %Y'),
|
||||
text = format_date(self.config.today_fmt or _('%b %d, %Y'), # type: ignore
|
||||
language=self.config.language)
|
||||
ref.replace_self(nodes.Text(text, text))
|
||||
|
||||
|
@ -51,7 +51,7 @@ def copy_asset_file(source, destination, context=None, renderer=None):
|
||||
if destination.lower().endswith('_t'):
|
||||
destination = destination[:-2]
|
||||
with codecs.open(destination, 'w', encoding='utf-8') as fdst: # type: ignore
|
||||
fdst.write(renderer.render_string(fsrc.read(), context)) # type: ignore
|
||||
fdst.write(renderer.render_string(fsrc.read(), context))
|
||||
else:
|
||||
copyfile(source, destination)
|
||||
|
||||
|
@ -118,5 +118,5 @@ def parse_data_uri(uri):
|
||||
elif prop:
|
||||
mimetype = prop
|
||||
|
||||
image_data = base64.b64decode(data) # type: ignore
|
||||
image_data = base64.b64decode(data)
|
||||
return DataURI(mimetype, charset, image_data)
|
||||
|
@ -88,7 +88,7 @@ class ParallelTasks(object):
|
||||
failed = False
|
||||
except BaseException as err:
|
||||
failed = True
|
||||
errmsg = traceback.format_exception_only(err.__class__, err)[0].strip() # type: ignore # NOQA
|
||||
errmsg = traceback.format_exception_only(err.__class__, err)[0].strip()
|
||||
ret = (errmsg, traceback.format_exc())
|
||||
logging.convert_serializable(collector.logs)
|
||||
pipe.send((failed, collector.logs, ret))
|
||||
|
@ -79,7 +79,7 @@ if PY3:
|
||||
return text_type(tree)
|
||||
else:
|
||||
# no need to refactor on 2.x versions
|
||||
convert_with_2to3 = None # type: ignore
|
||||
convert_with_2to3 = None
|
||||
|
||||
|
||||
# htmlescape()
|
||||
|
@ -120,7 +120,7 @@ def _get_tls_cacert(url, config):
|
||||
certs = getattr(config, 'tls_cacerts', None)
|
||||
if not certs:
|
||||
return True
|
||||
elif isinstance(certs, (string_types, tuple)): # type: ignore
|
||||
elif isinstance(certs, (string_types, tuple)):
|
||||
return certs # type: ignore
|
||||
else:
|
||||
hostname = urlsplit(url)[1]
|
||||
|
@ -555,7 +555,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
if builder.config.today:
|
||||
self.elements['date'] = builder.config.today
|
||||
else:
|
||||
self.elements['date'] = format_date(builder.config.today_fmt or _('%b %d, %Y'),
|
||||
self.elements['date'] = format_date(builder.config.today_fmt or _('%b %d, %Y'), # type: ignore # NOQA
|
||||
language=builder.config.language)
|
||||
if builder.config.latex_logo:
|
||||
# no need for \\noindent here, used in flushright
|
||||
|
@ -107,7 +107,7 @@ class ManualPageTranslator(BaseTranslator):
|
||||
if builder.config.today:
|
||||
self._docinfo['date'] = builder.config.today
|
||||
else:
|
||||
self._docinfo['date'] = format_date(builder.config.today_fmt or _('%b %d, %Y'),
|
||||
self._docinfo['date'] = format_date(builder.config.today_fmt or _('%b %d, %Y'), # type: ignore # NOQA
|
||||
language=builder.config.language)
|
||||
self._docinfo['copyright'] = builder.config.copyright
|
||||
self._docinfo['version'] = builder.config.version
|
||||
|
@ -238,7 +238,7 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
'project': self.escape(self.builder.config.project),
|
||||
'copyright': self.escape(self.builder.config.copyright),
|
||||
'date': self.escape(self.builder.config.today or
|
||||
format_date(self.builder.config.today_fmt or _('%b %d, %Y'),
|
||||
format_date(self.builder.config.today_fmt or _('%b %d, %Y'), # type: ignore # NOQA
|
||||
language=self.builder.config.language))
|
||||
})
|
||||
# title
|
||||
|
@ -661,7 +661,7 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
self.add_text(''.join(out) + self.nl)
|
||||
|
||||
def writerow(row):
|
||||
# type: (list[List[unicode]]) -> None
|
||||
# type: (List[List[unicode]]) -> None
|
||||
lines = zip_longest(*row)
|
||||
for line in lines:
|
||||
out = ['|']
|
||||
|
Loading…
Reference in New Issue
Block a user