mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '4.1.x' into 4.x
This commit is contained in:
commit
05cce83cc7
9
CHANGES
9
CHANGES
@ -32,6 +32,9 @@ Dependencies
|
|||||||
Incompatible changes
|
Incompatible changes
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
* #9435: linkcheck: Disable checking automatically generated anchors on
|
||||||
|
github.com (ex. anchors in reST/Markdown documents)
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
----------
|
----------
|
||||||
|
|
||||||
@ -41,6 +44,12 @@ Features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* #9489: autodoc: Custom types using ``typing.NewType`` are not displayed well
|
||||||
|
with the HEAD of 3.10
|
||||||
|
* #9490: autodoc: Some objects under ``typing`` module are not displayed well
|
||||||
|
with the HEAD of 3.10
|
||||||
|
* #9435: linkcheck: Failed to check anchors in github.com
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -714,7 +714,10 @@ def setup(app: Sphinx) -> Dict[str, Any]:
|
|||||||
app.add_event('linkcheck-process-uri')
|
app.add_event('linkcheck-process-uri')
|
||||||
|
|
||||||
app.connect('config-inited', compile_linkcheck_allowed_redirects, priority=800)
|
app.connect('config-inited', compile_linkcheck_allowed_redirects, priority=800)
|
||||||
app.connect('linkcheck-process-uri', rewrite_github_anchor)
|
|
||||||
|
# FIXME: Disable URL rewrite handler for github.com temporarily.
|
||||||
|
# ref: https://github.com/sphinx-doc/sphinx/issues/9435
|
||||||
|
# app.connect('linkcheck-process-uri', rewrite_github_anchor)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'version': 'builtin',
|
'version': 'builtin',
|
||||||
|
@ -211,12 +211,15 @@ def getslots(obj: Any) -> Optional[Dict]:
|
|||||||
|
|
||||||
def isNewType(obj: Any) -> bool:
|
def isNewType(obj: Any) -> bool:
|
||||||
"""Check the if object is a kind of NewType."""
|
"""Check the if object is a kind of NewType."""
|
||||||
__module__ = safe_getattr(obj, '__module__', None)
|
if sys.version_info >= (3, 10):
|
||||||
__qualname__ = safe_getattr(obj, '__qualname__', None)
|
return isinstance(obj, typing.NewType)
|
||||||
if __module__ == 'typing' and __qualname__ == 'NewType.<locals>.new_type':
|
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
return False
|
__module__ = safe_getattr(obj, '__module__', None)
|
||||||
|
__qualname__ = safe_getattr(obj, '__qualname__', None)
|
||||||
|
if __module__ == 'typing' and __qualname__ == 'NewType.<locals>.new_type':
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def isenumclass(x: Any) -> bool:
|
def isenumclass(x: Any) -> bool:
|
||||||
|
@ -171,17 +171,17 @@ def _restify_py37(cls: Optional[Type]) -> str:
|
|||||||
text += r"\ [%s]" % ", ".join(restify(a) for a in cls.__args__)
|
text += r"\ [%s]" % ", ".join(restify(a) for a in cls.__args__)
|
||||||
|
|
||||||
return text
|
return text
|
||||||
elif hasattr(cls, '__qualname__'):
|
|
||||||
if cls.__module__ == 'typing':
|
|
||||||
return ':class:`~%s.%s`' % (cls.__module__, cls.__qualname__)
|
|
||||||
else:
|
|
||||||
return ':class:`%s.%s`' % (cls.__module__, cls.__qualname__)
|
|
||||||
elif hasattr(cls, '_name'):
|
elif hasattr(cls, '_name'):
|
||||||
# SpecialForm
|
# SpecialForm
|
||||||
if cls.__module__ == 'typing':
|
if cls.__module__ == 'typing':
|
||||||
return ':obj:`~%s.%s`' % (cls.__module__, cls._name)
|
return ':obj:`~%s.%s`' % (cls.__module__, cls._name)
|
||||||
else:
|
else:
|
||||||
return ':obj:`%s.%s`' % (cls.__module__, cls._name)
|
return ':obj:`%s.%s`' % (cls.__module__, cls._name)
|
||||||
|
elif hasattr(cls, '__qualname__'):
|
||||||
|
if cls.__module__ == 'typing':
|
||||||
|
return ':class:`~%s.%s`' % (cls.__module__, cls.__qualname__)
|
||||||
|
else:
|
||||||
|
return ':class:`%s.%s`' % (cls.__module__, cls.__qualname__)
|
||||||
elif isinstance(cls, ForwardRef):
|
elif isinstance(cls, ForwardRef):
|
||||||
return ':class:`%s`' % cls.__forward_arg__
|
return ':class:`%s`' % cls.__forward_arg__
|
||||||
else:
|
else:
|
||||||
@ -309,7 +309,7 @@ def stringify(annotation: Any) -> str:
|
|||||||
elif annotation in INVALID_BUILTIN_CLASSES:
|
elif annotation in INVALID_BUILTIN_CLASSES:
|
||||||
return INVALID_BUILTIN_CLASSES[annotation]
|
return INVALID_BUILTIN_CLASSES[annotation]
|
||||||
elif (getattr(annotation, '__module__', None) == 'builtins' and
|
elif (getattr(annotation, '__module__', None) == 'builtins' and
|
||||||
hasattr(annotation, '__qualname__')):
|
getattr(annotation, '__qualname__', None)):
|
||||||
if hasattr(annotation, '__args__'): # PEP 585 generic
|
if hasattr(annotation, '__args__'): # PEP 585 generic
|
||||||
return repr(annotation)
|
return repr(annotation)
|
||||||
else:
|
else:
|
||||||
|
@ -13,8 +13,7 @@ Some additional anchors to exercise ignore code
|
|||||||
* `Complete nonsense <https://localhost:7777/doesnotexist>`_
|
* `Complete nonsense <https://localhost:7777/doesnotexist>`_
|
||||||
* `Example valid local file <conf.py>`_
|
* `Example valid local file <conf.py>`_
|
||||||
* `Example invalid local file <path/to/notfound>`_
|
* `Example invalid local file <path/to/notfound>`_
|
||||||
* https://github.com/sphinx-doc/sphinx#documentation
|
* https://github.com/sphinx-doc/sphinx/blob/4.x/sphinx/__init__.py#L2
|
||||||
* https://github.com/sphinx-doc/sphinx#user-content-testing
|
|
||||||
|
|
||||||
.. image:: https://www.google.com/image.png
|
.. image:: https://www.google.com/image.png
|
||||||
.. figure:: https://www.google.com/image2.png
|
.. figure:: https://www.google.com/image2.png
|
||||||
|
@ -66,8 +66,8 @@ def test_defaults_json(app):
|
|||||||
"info"]:
|
"info"]:
|
||||||
assert attr in row
|
assert attr in row
|
||||||
|
|
||||||
assert len(content.splitlines()) == 12
|
assert len(content.splitlines()) == 11
|
||||||
assert len(rows) == 12
|
assert len(rows) == 11
|
||||||
# the output order of the rows is not stable
|
# the output order of the rows is not stable
|
||||||
# due to possible variance in network latency
|
# due to possible variance in network latency
|
||||||
rowsby = {row["uri"]: row for row in rows}
|
rowsby = {row["uri"]: row for row in rows}
|
||||||
@ -88,7 +88,7 @@ def test_defaults_json(app):
|
|||||||
assert dnerow['uri'] == 'https://localhost:7777/doesnotexist'
|
assert dnerow['uri'] == 'https://localhost:7777/doesnotexist'
|
||||||
assert rowsby['https://www.google.com/image2.png'] == {
|
assert rowsby['https://www.google.com/image2.png'] == {
|
||||||
'filename': 'links.txt',
|
'filename': 'links.txt',
|
||||||
'lineno': 20,
|
'lineno': 19,
|
||||||
'status': 'broken',
|
'status': 'broken',
|
||||||
'code': 0,
|
'code': 0,
|
||||||
'uri': 'https://www.google.com/image2.png',
|
'uri': 'https://www.google.com/image2.png',
|
||||||
@ -102,10 +102,6 @@ def test_defaults_json(app):
|
|||||||
# images should fail
|
# images should fail
|
||||||
assert "Not Found for url: https://www.google.com/image.png" in \
|
assert "Not Found for url: https://www.google.com/image.png" in \
|
||||||
rowsby["https://www.google.com/image.png"]["info"]
|
rowsby["https://www.google.com/image.png"]["info"]
|
||||||
# The anchor of the URI for github.com is automatically modified
|
|
||||||
assert 'https://github.com/sphinx-doc/sphinx#documentation' not in rowsby
|
|
||||||
assert 'https://github.com/sphinx-doc/sphinx#user-content-documentation' in rowsby
|
|
||||||
assert 'https://github.com/sphinx-doc/sphinx#user-content-testing' in rowsby
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
|
Loading…
Reference in New Issue
Block a user