Merge branch '2.4.x' into 2.x

This commit is contained in:
Takeshi KOMIYA 2020-02-18 01:42:21 +09:00
commit e6bb13de72
4 changed files with 16 additions and 8 deletions

View File

@ -20,7 +20,10 @@ Bugs fixed
as a value
* #7156: autodoc: separator for keyword only arguments is not shown
* #7146: autodoc: IndexError is raised on suppressed type_comment found
* #7161: autodoc: typehints extension does not support parallel build
* #7151: crashed when extension assigns a value to ``env.indexentries``
* #7170: text: Remove debug print
* #7137: viewcode: Avoid to crash when non-python code given
Testing
--------

View File

@ -18,19 +18,19 @@ from docutils.nodes import Element
from sphinx import addnodes
from sphinx.application import Sphinx
from sphinx.config import ENUM
from sphinx.config import Config, ENUM
from sphinx.util import inspect, typing
def config_inited(app, config):
def config_inited(app: Sphinx, config: Config) -> None:
if config.autodoc_typehints == 'description':
# HACK: override this to make autodoc suppressing typehints in signatures
config.autodoc_typehints = 'none'
config.autodoc_typehints = 'none' # type: ignore
# preserve user settings
app._autodoc_typehints_description = True
app._autodoc_typehints_description = True # type: ignore
else:
app._autodoc_typehints_description = False
app._autodoc_typehints_description = False # type: ignore
def record_typehints(app: Sphinx, objtype: str, name: str, obj: Any,
@ -140,10 +140,16 @@ def modify_field_list(node: nodes.field_list, annotations: Dict[str, str]) -> No
node += field
def setup(app):
def setup(app: Sphinx) -> Dict[str, Any]:
app.setup_extension('sphinx.ext.autodoc')
app.config.values['autodoc_typehints'] = ('signature', True,
ENUM("signature", "description", "none"))
app.connect('config-inited', config_inited)
app.connect('autodoc-process-signature', record_typehints)
app.connect('object-description-transform', merge_typehints)
return {
'version': 'builtin',
'parallel_read_safe': True,
'parallel_write_safe': True,
}

View File

@ -66,11 +66,11 @@ def doctree_read(app: Sphinx, doctree: Node) -> None:
if code_tags is None:
try:
analyzer = ModuleAnalyzer.for_module(modname)
analyzer.find_tags()
except Exception:
env._viewcode_modules[modname] = False # type: ignore
return
analyzer.find_tags()
code = analyzer.code
tags = analyzer.tags
else:

View File

@ -918,7 +918,6 @@ class TextTranslator(SphinxTranslator):
def _depart_admonition(self, node: Element) -> None:
label = admonitionlabels[node.tagname]
indent = sum(self.stateindent) + len(label)
print(self.states[-1])
if (len(self.states[-1]) == 1 and
self.states[-1][0][0] == 0 and
MAXWIDTH - indent >= sum(len(s) for s in self.states[-1][0][1])):