mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '2.2.1' into 2.0
This commit is contained in:
commit
73a93f897e
2
setup.py
2
setup.py
@ -47,7 +47,7 @@ extras_require = {
|
||||
'html5lib',
|
||||
'flake8>=3.5.0',
|
||||
'flake8-import-order',
|
||||
'mypy>=0.720',
|
||||
'mypy>=0.730',
|
||||
'docutils-stubs',
|
||||
],
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class Stylesheet(str):
|
||||
attributes = None # type: Dict[str, str]
|
||||
filename = None # type: str
|
||||
|
||||
def __new__(cls, filename: str, *args: str, **attributes: str) -> None:
|
||||
def __new__(cls, filename: str, *args: str, **attributes: str) -> "Stylesheet":
|
||||
self = str.__new__(cls, filename) # type: ignore
|
||||
self.filename = filename
|
||||
self.attributes = attributes
|
||||
@ -142,7 +142,7 @@ class JavaScript(str):
|
||||
attributes = None # type: Dict[str, str]
|
||||
filename = None # type: str
|
||||
|
||||
def __new__(cls, filename: str, **attributes: str) -> None:
|
||||
def __new__(cls, filename: str, **attributes: str) -> "JavaScript":
|
||||
self = str.__new__(cls, filename) # type: ignore
|
||||
self.filename = filename
|
||||
self.attributes = attributes
|
||||
|
@ -88,7 +88,7 @@ class Make:
|
||||
nocolor()
|
||||
|
||||
print(bold("Sphinx v%s" % sphinx.__display_version__))
|
||||
print("Please use `make %s' where %s is one of" % ((blue('target'),) * 2)) # type: ignore # NOQA
|
||||
print("Please use `make %s' where %s is one of" % ((blue('target'),) * 2))
|
||||
for osname, bname, description in BUILDERS:
|
||||
if not osname or os.name == osname:
|
||||
print(' %s %s' % (blue(bname.ljust(10)), description))
|
||||
|
@ -286,7 +286,7 @@ class DocTestBuilder(Builder):
|
||||
# for doctest examples but unusable for multi-statement code such
|
||||
# as setup code -- to be able to use doctest error reporting with
|
||||
# that code nevertheless, we monkey-patch the "compile" it uses.
|
||||
doctest.compile = self.compile
|
||||
doctest.compile = self.compile # type: ignore
|
||||
|
||||
sys.path[0:0] = self.config.doctest_path
|
||||
|
||||
@ -507,7 +507,7 @@ Doctest summary
|
||||
if len(code) == 1:
|
||||
# ordinary doctests (code/output interleaved)
|
||||
try:
|
||||
test = parser.get_doctest(code[0].code, {}, group.name, # type: ignore
|
||||
test = parser.get_doctest(code[0].code, {}, group.name,
|
||||
code[0].filename, code[0].lineno)
|
||||
except Exception:
|
||||
logger.warning(__('ignoring invalid doctest code: %r'), code[0].code,
|
||||
|
@ -368,7 +368,7 @@ class InheritanceDiagram(SphinxDirective):
|
||||
# removed from the doctree after we're done with them.
|
||||
for name in graph.get_all_class_names():
|
||||
refnodes, x = class_role( # type: ignore
|
||||
'class', ':class:`%s`' % name, name, 0, self.state)
|
||||
'class', ':class:`%s`' % name, name, 0, self.state) # type: ignore
|
||||
node.extend(refnodes)
|
||||
# Store the graph object so we can use it to generate the
|
||||
# dot file later
|
||||
|
@ -398,7 +398,7 @@ def inspect_main(argv: List[str]) -> None:
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import logging # type: ignore
|
||||
logging.basicConfig()
|
||||
import logging as _logging
|
||||
_logging.basicConfig()
|
||||
|
||||
inspect_main(argv=sys.argv[1:])
|
||||
|
@ -330,10 +330,10 @@ def read_doc(app, env, filename):
|
||||
# Sphinx-1.8 style
|
||||
source = input_class(app, env, source=None, source_path=filename, # type: ignore
|
||||
encoding=env.config.source_encoding)
|
||||
pub = Publisher(reader=reader, # type: ignore
|
||||
pub = Publisher(reader=reader,
|
||||
parser=parser,
|
||||
writer=SphinxDummyWriter(),
|
||||
source_class=SphinxDummySourceClass,
|
||||
source_class=SphinxDummySourceClass, # type: ignore
|
||||
destination=NullOutput())
|
||||
pub.process_programmatic_settings(None, env.settings, None)
|
||||
pub.set_source(source, filename)
|
||||
|
@ -35,7 +35,7 @@ class _TranslationProxy(UserString):
|
||||
"""
|
||||
__slots__ = ('_func', '_args')
|
||||
|
||||
def __new__(cls, func, *args):
|
||||
def __new__(cls, func, *args): # type: ignore
|
||||
# type: (Callable, str) -> object
|
||||
if not args:
|
||||
# not called with "function" and "arguments", but a plain string
|
||||
|
@ -120,8 +120,8 @@ class SphinxTestApp(application.Sphinx):
|
||||
warningiserror = False
|
||||
|
||||
self._saved_path = sys.path[:]
|
||||
self._saved_directives = directives._directives.copy()
|
||||
self._saved_roles = roles._roles.copy()
|
||||
self._saved_directives = directives._directives.copy() # type: ignore
|
||||
self._saved_roles = roles._roles.copy() # type: ignore
|
||||
|
||||
self._saved_nodeclasses = {v for v in dir(nodes.GenericNodeVisitor)
|
||||
if v.startswith('visit_')}
|
||||
@ -140,8 +140,8 @@ class SphinxTestApp(application.Sphinx):
|
||||
locale.translators.clear()
|
||||
sys.path[:] = self._saved_path
|
||||
sys.modules.pop('autodoc_fodder', None)
|
||||
directives._directives = self._saved_directives
|
||||
roles._roles = self._saved_roles
|
||||
directives._directives = self._saved_directives # type: ignore
|
||||
roles._roles = self._saved_roles # type: ignore
|
||||
for method in dir(nodes.GenericNodeVisitor):
|
||||
if method.startswith('visit_') and \
|
||||
method not in self._saved_nodeclasses:
|
||||
|
@ -252,7 +252,7 @@ def save_traceback(app: "Sphinx") -> str:
|
||||
platform.python_version(),
|
||||
platform.python_implementation(),
|
||||
docutils.__version__, docutils.__version_details__,
|
||||
jinja2.__version__,
|
||||
jinja2.__version__, # type: ignore
|
||||
last_msgs)).encode())
|
||||
if app is not None:
|
||||
for ext in app.extensions.values():
|
||||
|
@ -54,13 +54,13 @@ additional_nodes = set() # type: Set[Type[nodes.Element]]
|
||||
def docutils_namespace() -> Generator[None, None, None]:
|
||||
"""Create namespace for reST parsers."""
|
||||
try:
|
||||
_directives = copy(directives._directives)
|
||||
_roles = copy(roles._roles)
|
||||
_directives = copy(directives._directives) # type: ignore
|
||||
_roles = copy(roles._roles) # type: ignore
|
||||
|
||||
yield
|
||||
finally:
|
||||
directives._directives = _directives
|
||||
roles._roles = _roles
|
||||
directives._directives = _directives # type: ignore
|
||||
roles._roles = _roles # type: ignore
|
||||
|
||||
for node in list(additional_nodes):
|
||||
unregister_node(node)
|
||||
@ -69,7 +69,7 @@ def docutils_namespace() -> Generator[None, None, None]:
|
||||
|
||||
def is_directive_registered(name: str) -> bool:
|
||||
"""Check the *name* directive is already registered."""
|
||||
return name in directives._directives
|
||||
return name in directives._directives # type: ignore
|
||||
|
||||
|
||||
def register_directive(name: str, directive: "Type[Directive]") -> None:
|
||||
@ -83,7 +83,7 @@ def register_directive(name: str, directive: "Type[Directive]") -> None:
|
||||
|
||||
def is_role_registered(name: str) -> bool:
|
||||
"""Check the *name* role is already registered."""
|
||||
return name in roles._roles
|
||||
return name in roles._roles # type: ignore
|
||||
|
||||
|
||||
def register_role(name: str, role: RoleFunction) -> None:
|
||||
@ -97,7 +97,7 @@ def register_role(name: str, role: RoleFunction) -> None:
|
||||
|
||||
def unregister_role(name: str) -> None:
|
||||
"""Unregister a role from docutils."""
|
||||
roles._roles.pop(name, None)
|
||||
roles._roles.pop(name, None) # type: ignore
|
||||
|
||||
|
||||
def is_node_registered(node: "Type[Element]") -> bool:
|
||||
@ -112,7 +112,7 @@ def register_node(node: "Type[Element]") -> None:
|
||||
inside ``docutils_namespace()`` to prevent side-effects.
|
||||
"""
|
||||
if not hasattr(nodes.GenericNodeVisitor, 'visit_' + node.__name__):
|
||||
nodes._add_node_class_names([node.__name__])
|
||||
nodes._add_node_class_names([node.__name__]) # type: ignore
|
||||
additional_nodes.add(node)
|
||||
|
||||
|
||||
|
@ -546,7 +546,7 @@ class Signature:
|
||||
else:
|
||||
qualname = repr(annotation)
|
||||
|
||||
if (isinstance(annotation, typing.TupleMeta) and
|
||||
if (isinstance(annotation, typing.TupleMeta) and # type: ignore
|
||||
not hasattr(annotation, '__tuple_params__')): # for Python 3.6
|
||||
params = annotation.__args__
|
||||
if params:
|
||||
@ -572,7 +572,7 @@ class Signature:
|
||||
param_str = ', '.join(self.format_annotation(p) for p in params)
|
||||
return '%s[%s]' % (qualname, param_str)
|
||||
elif (hasattr(typing, 'UnionMeta') and
|
||||
isinstance(annotation, typing.UnionMeta) and
|
||||
isinstance(annotation, typing.UnionMeta) and # type: ignore
|
||||
hasattr(annotation, '__union_params__')): # for Python 3.5
|
||||
params = annotation.__union_params__
|
||||
if params is not None:
|
||||
@ -590,7 +590,7 @@ class Signature:
|
||||
else:
|
||||
param_str = ', '.join(self.format_annotation(p) for p in params)
|
||||
return 'Union[%s]' % param_str
|
||||
elif (isinstance(annotation, typing.CallableMeta) and
|
||||
elif (isinstance(annotation, typing.CallableMeta) and # type: ignore
|
||||
getattr(annotation, '__args__', None) is not None and
|
||||
hasattr(annotation, '__result__')): # for Python 3.5
|
||||
# Skipped in the case of plain typing.Callable
|
||||
@ -605,7 +605,7 @@ class Signature:
|
||||
return '%s[%s, %s]' % (qualname,
|
||||
args_str,
|
||||
self.format_annotation(annotation.__result__))
|
||||
elif (isinstance(annotation, typing.TupleMeta) and
|
||||
elif (isinstance(annotation, typing.TupleMeta) and # type: ignore
|
||||
hasattr(annotation, '__tuple_params__') and
|
||||
hasattr(annotation, '__tuple_use_ellipsis__')): # for Python 3.5
|
||||
params = annotation.__tuple_params__
|
||||
|
@ -212,7 +212,7 @@ class TexinfoTranslator(SphinxTranslator):
|
||||
for index in self.indices:
|
||||
name, content = index
|
||||
pointers = tuple([name] + self.rellinks[name])
|
||||
self.body.append('\n@node %s,%s,%s,%s\n' % pointers) # type: ignore
|
||||
self.body.append('\n@node %s,%s,%s,%s\n' % pointers)
|
||||
self.body.append('@unnumbered %s\n\n%s\n' % (name, content))
|
||||
|
||||
while self.referenced_ids:
|
||||
@ -618,7 +618,7 @@ class TexinfoTranslator(SphinxTranslator):
|
||||
|
||||
node_name = node['node_name']
|
||||
pointers = tuple([node_name] + self.rellinks[node_name])
|
||||
self.body.append('\n@node %s,%s,%s,%s\n' % pointers) # type: ignore
|
||||
self.body.append('\n@node %s,%s,%s,%s\n' % pointers)
|
||||
for id in sorted(self.next_section_ids):
|
||||
self.add_anchor(id, node)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user