mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove unnecessary conditional import in `sphinx.ext.napoleon
` (#11043)
The conditional import could have been useful for the external sphinxcontrib.napoleon (to keep backcompat with older versions of sphinx), but seems just confusing for a builtin extension.
This commit is contained in:
parent
45a0ea9fc9
commit
da25145d08
@ -324,22 +324,17 @@ def setup(app: Sphinx) -> Dict[str, Any]:
|
||||
|
||||
|
||||
def _patch_python_domain() -> None:
|
||||
try:
|
||||
from sphinx.domains.python import PyTypedField
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
import sphinx.domains.python
|
||||
from sphinx.locale import _
|
||||
for doc_field in sphinx.domains.python.PyObject.doc_field_types:
|
||||
if doc_field.name == 'parameter':
|
||||
doc_field.names = ('param', 'parameter', 'arg', 'argument')
|
||||
break
|
||||
sphinx.domains.python.PyObject.doc_field_types.append(
|
||||
PyTypedField('keyword', label=_('Keyword Arguments'),
|
||||
names=('keyword', 'kwarg', 'kwparam'),
|
||||
typerolename='obj', typenames=('paramtype', 'kwtype'),
|
||||
can_collapse=True))
|
||||
from sphinx.domains.python import PyObject, PyTypedField
|
||||
from sphinx.locale import _
|
||||
for doc_field in PyObject.doc_field_types:
|
||||
if doc_field.name == 'parameter':
|
||||
doc_field.names = ('param', 'parameter', 'arg', 'argument')
|
||||
break
|
||||
PyObject.doc_field_types.append(
|
||||
PyTypedField('keyword', label=_('Keyword Arguments'),
|
||||
names=('keyword', 'kwarg', 'kwparam'),
|
||||
typerolename='obj', typenames=('paramtype', 'kwtype'),
|
||||
can_collapse=True))
|
||||
|
||||
|
||||
def _process_docstring(app: Sphinx, what: str, name: str, obj: Any,
|
||||
|
Loading…
Reference in New Issue
Block a user