Skip to content

Commit

Permalink
Merge branch '4.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Jan 2, 2022
2 parents 2d92be7 + daf57f2 commit 6f707a0
Show file tree
Hide file tree
Showing 121 changed files with 5,711 additions and 4,315 deletions.
5 changes: 2 additions & 3 deletions setup.py
@@ -1,6 +1,5 @@
import os
import sys
from distutils import log
from io import StringIO

from setuptools import find_packages, setup
Expand Down Expand Up @@ -148,8 +147,8 @@ def _run_domain_js(self, domain):
if catalog.fuzzy and not self.use_fuzzy:
continue

log.info('writing JavaScript strings in catalog %r to %r',
po_file, js_file)
self.log.info('writing JavaScript strings in catalog %r to %r',
po_file, js_file)

jscatalog = {}
for message in catalog:
Expand Down
7 changes: 7 additions & 0 deletions sphinx/addnodes.py
Expand Up @@ -16,6 +16,13 @@
if TYPE_CHECKING:
from sphinx.application import Sphinx

try:
from docutils.nodes import meta as docutils_meta # type: ignore
except ImportError:
# docutils-0.17 or older
from docutils.parsers.rst.directives.html import MetaBody
docutils_meta = MetaBody.meta


class document(nodes.document):
"""The document root element patched by Sphinx.
Expand Down
7 changes: 3 additions & 4 deletions sphinx/directives/patches.py
Expand Up @@ -29,13 +29,10 @@
from sphinx.util.typing import OptionSpec

try:
from docutils.nodes import meta as meta_node # type: ignore
from docutils.parsers.rst.directives.misc import Meta as MetaBase # type: ignore
except ImportError:
# docutils-0.17 or older
from docutils.parsers.rst.directives.html import Meta as MetaBase
from docutils.parsers.rst.directives.html import MetaBody
meta_node = MetaBody.meta

if TYPE_CHECKING:
from sphinx.application import Sphinx
Expand Down Expand Up @@ -74,8 +71,10 @@ class Meta(MetaBase, SphinxDirective):
def run(self) -> List[Node]:
result = super().run()
for node in result:
# for docutils-0.17 or older. Since docutils-0.18, patching is no longer needed
# because it uses picklable node; ``docutils.nodes.meta``.
if (isinstance(node, nodes.pending) and
isinstance(node.details['nodes'][0], meta_node)):
isinstance(node.details['nodes'][0], addnodes.docutils_meta)):
meta = node.details['nodes'][0]
meta.source = self.env.doc2path(self.env.docname)
meta.line = self.lineno
Expand Down
31 changes: 26 additions & 5 deletions sphinx/ext/autodoc/__init__.py
Expand Up @@ -1676,7 +1676,11 @@ def add_directive_header(self, sig: str) -> None:
self.env.events.emit('autodoc-process-bases',
self.fullname, self.object, self.options, bases)

base_classes = [restify(cls) for cls in bases]
if self.config.autodoc_typehints_format == "short":
base_classes = [restify(cls, "smart") for cls in bases]
else:
base_classes = [restify(cls) for cls in bases]

sourcename = self.get_sourcename()
self.add_line('', sourcename)
self.add_line(' ' + _('Bases: %s') % ', '.join(base_classes), sourcename)
Expand Down Expand Up @@ -1773,7 +1777,11 @@ def add_content(self, more_content: Optional[StringList], no_docstring: bool = F

if self.doc_as_attr and not self.get_variable_comment():
try:
more_content = StringList([_('alias of %s') % restify(self.object)], source='')
if self.config.autodoc_typehints_format == "short":
alias = restify(self.object, "smart")
else:
alias = restify(self.object)
more_content = StringList([_('alias of %s') % alias], source='')
except AttributeError:
pass # Invalid class object is passed.

Expand Down Expand Up @@ -1846,7 +1854,12 @@ def should_suppress_directive_header(self) -> bool:

def update_content(self, more_content: StringList) -> None:
if inspect.isgenericalias(self.object):
more_content.append(_('alias of %s') % restify(self.object), '')
if self.config.autodoc_typehints_format == "short":
alias = restify(self.object, "smart")
else:
alias = restify(self.object)

more_content.append(_('alias of %s') % alias, '')
more_content.append('', '')

super().update_content(more_content)
Expand All @@ -1864,7 +1877,11 @@ def should_suppress_directive_header(self) -> bool:

def update_content(self, more_content: StringList) -> None:
if inspect.isNewType(self.object):
supertype = restify(self.object.__supertype__)
if self.config.autodoc_typehints_format == "short":
supertype = restify(self.object.__supertype__, "smart")
else:
supertype = restify(self.object.__supertype__)

more_content.append(_('alias of %s') % supertype, '')
more_content.append('', '')

Expand Down Expand Up @@ -1901,7 +1918,11 @@ def update_content(self, more_content: StringList) -> None:
for constraint in self.object.__constraints__:
attrs.append(stringify_typehint(constraint))
if self.object.__bound__:
attrs.append(r"bound=\ " + restify(self.object.__bound__))
if self.config.autodoc_typehints_format == "short":
bound = restify(self.object.__bound__, "smart")
else:
bound = restify(self.object.__bound__)
attrs.append(r"bound=\ " + bound)
if self.object.__covariant__:
attrs.append("covariant=True")
if self.object.__contravariant__:
Expand Down
Binary file modified sphinx/locale/ar/LC_MESSAGES/sphinx.mo
Binary file not shown.

0 comments on commit 6f707a0

Please sign in to comment.