mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #7161: autodoc: typehints extension does not support parallel build
This commit is contained in:
parent
1339948dce
commit
68e248fa73
1
CHANGES
1
CHANGES
@ -19,6 +19,7 @@ Bugs fixed
|
||||
* #7138: autodoc: ``autodoc.typehints`` crashed when variable has unbound object
|
||||
as a value
|
||||
* #7156: autodoc: separator for keyword only arguments is not shown
|
||||
* #7161: autodoc: typehints extension does not support parallel build
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -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,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user