mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '3.5.x' into 3.x
This commit is contained in:
commit
1df14a4828
7
CHANGES
7
CHANGES
@ -4,6 +4,8 @@ Release 3.5.4 (in development)
|
|||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
* #9071: Restrict docutils to 0.16
|
||||||
|
|
||||||
Incompatible changes
|
Incompatible changes
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
@ -16,6 +18,11 @@ Features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* #9078: autodoc: Async staticmethods and classmethods are considered as non
|
||||||
|
async coroutine-functions with Python3.10
|
||||||
|
* #8870: The style of toctree captions has been changed with docutils-0.17
|
||||||
|
* #9001: The style of ``sidebar`` directive has been changed with docutils-0.17
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -23,7 +23,7 @@ install_requires = [
|
|||||||
'sphinxcontrib-qthelp',
|
'sphinxcontrib-qthelp',
|
||||||
'Jinja2>=2.3',
|
'Jinja2>=2.3',
|
||||||
'Pygments>=2.0',
|
'Pygments>=2.0',
|
||||||
'docutils>=0.12',
|
'docutils>=0.12,<0.17',
|
||||||
'snowballstemmer>=1.1',
|
'snowballstemmer>=1.1',
|
||||||
'babel>=1.3',
|
'babel>=1.3',
|
||||||
'alabaster>=0.7,<0.8',
|
'alabaster>=0.7,<0.8',
|
||||||
|
@ -237,7 +237,7 @@ class TocTree:
|
|||||||
newnode = addnodes.compact_paragraph('', '')
|
newnode = addnodes.compact_paragraph('', '')
|
||||||
caption = toctree.attributes.get('caption')
|
caption = toctree.attributes.get('caption')
|
||||||
if caption:
|
if caption:
|
||||||
caption_node = nodes.caption(caption, '', *[nodes.Text(caption)])
|
caption_node = nodes.title(caption, '', *[nodes.Text(caption)])
|
||||||
caption_node.line = toctree.line
|
caption_node.line = toctree.line
|
||||||
caption_node.source = toctree.source
|
caption_node.source = toctree.source
|
||||||
caption_node.rawsource = toctree['rawcaption']
|
caption_node.rawsource = toctree['rawcaption']
|
||||||
|
@ -319,7 +319,8 @@ img.align-default, .figure.align-default {
|
|||||||
|
|
||||||
/* -- sidebars -------------------------------------------------------------- */
|
/* -- sidebars -------------------------------------------------------------- */
|
||||||
|
|
||||||
div.sidebar {
|
div.sidebar,
|
||||||
|
aside.sidebar {
|
||||||
margin: 0 0 0.5em 1em;
|
margin: 0 0 0.5em 1em;
|
||||||
border: 1px solid #ddb;
|
border: 1px solid #ddb;
|
||||||
padding: 7px;
|
padding: 7px;
|
||||||
@ -377,12 +378,14 @@ div.body p.centered {
|
|||||||
/* -- content of sidebars/topics/admonitions -------------------------------- */
|
/* -- content of sidebars/topics/admonitions -------------------------------- */
|
||||||
|
|
||||||
div.sidebar > :last-child,
|
div.sidebar > :last-child,
|
||||||
|
aside.sidebar > :last-child,
|
||||||
div.topic > :last-child,
|
div.topic > :last-child,
|
||||||
div.admonition > :last-child {
|
div.admonition > :last-child {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.sidebar::after,
|
div.sidebar::after,
|
||||||
|
aside.sidebar::after,
|
||||||
div.topic::after,
|
div.topic::after,
|
||||||
div.admonition::after,
|
div.admonition::after,
|
||||||
blockquote::after {
|
blockquote::after {
|
||||||
|
@ -352,8 +352,18 @@ def isroutine(obj: Any) -> bool:
|
|||||||
|
|
||||||
def iscoroutinefunction(obj: Any) -> bool:
|
def iscoroutinefunction(obj: Any) -> bool:
|
||||||
"""Check if the object is coroutine-function."""
|
"""Check if the object is coroutine-function."""
|
||||||
# unwrap staticmethod, classmethod and partial (except wrappers)
|
def iswrappedcoroutine(obj: Any) -> bool:
|
||||||
obj = unwrap_all(obj, stop=lambda o: hasattr(o, '__wrapped__'))
|
"""Check if the object is wrapped coroutine-function."""
|
||||||
|
if isstaticmethod(obj) or isclassmethod(obj) or ispartial(obj):
|
||||||
|
# staticmethod, classmethod and partial method are not a wrapped coroutine-function
|
||||||
|
# Note: Since 3.10, staticmethod and classmethod becomes a kind of wrappers
|
||||||
|
return False
|
||||||
|
elif hasattr(obj, '__wrapped__'):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
obj = unwrap_all(obj, stop=iswrappedcoroutine)
|
||||||
if hasattr(obj, '__code__') and inspect.iscoroutinefunction(obj):
|
if hasattr(obj, '__code__') and inspect.iscoroutinefunction(obj):
|
||||||
# check obj.__code__ because iscoroutinefunction() crashes for custom method-like
|
# check obj.__code__ because iscoroutinefunction() crashes for custom method-like
|
||||||
# objects (see https://github.com/sphinx-doc/sphinx/issues/6605)
|
# objects (see https://github.com/sphinx-doc/sphinx/issues/6605)
|
||||||
|
@ -404,7 +404,12 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
def visit_title(self, node: Element) -> None:
|
def visit_title(self, node: Element) -> None:
|
||||||
super().visit_title(node)
|
if isinstance(node.parent, addnodes.compact_paragraph) and node.parent.get('toctree'):
|
||||||
|
self.body.append(self.starttag(node, 'p', '', CLASS='caption'))
|
||||||
|
self.body.append('<span class="caption-text">')
|
||||||
|
self.context.append('</span></p>\n')
|
||||||
|
else:
|
||||||
|
super().visit_title(node)
|
||||||
self.add_secnumber(node)
|
self.add_secnumber(node)
|
||||||
self.add_fignumber(node.parent)
|
self.add_fignumber(node.parent)
|
||||||
if isinstance(node.parent, nodes.table):
|
if isinstance(node.parent, nodes.table):
|
||||||
|
@ -355,7 +355,12 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
|||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
def visit_title(self, node: Element) -> None:
|
def visit_title(self, node: Element) -> None:
|
||||||
super().visit_title(node)
|
if isinstance(node.parent, addnodes.compact_paragraph) and node.parent.get('toctree'):
|
||||||
|
self.body.append(self.starttag(node, 'p', '', CLASS='caption'))
|
||||||
|
self.body.append('<span class="caption-text">')
|
||||||
|
self.context.append('</span></p>\n')
|
||||||
|
else:
|
||||||
|
super().visit_title(node)
|
||||||
self.add_secnumber(node)
|
self.add_secnumber(node)
|
||||||
self.add_fignumber(node.parent)
|
self.add_fignumber(node.parent)
|
||||||
if isinstance(node.parent, nodes.table):
|
if isinstance(node.parent, nodes.table):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from docutils.nodes import bullet_list, caption, comment, list_item, reference
|
from docutils.nodes import bullet_list, comment, list_item, reference, title
|
||||||
|
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
from sphinx.addnodes import compact_paragraph, only
|
from sphinx.addnodes import compact_paragraph, only
|
||||||
@ -211,7 +211,7 @@ def test_get_toctree_for(app):
|
|||||||
app.build()
|
app.build()
|
||||||
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False)
|
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False)
|
||||||
assert_node(toctree,
|
assert_node(toctree,
|
||||||
[compact_paragraph, ([caption, "Table of Contents"],
|
[compact_paragraph, ([title, "Table of Contents"],
|
||||||
bullet_list,
|
bullet_list,
|
||||||
bullet_list,
|
bullet_list,
|
||||||
bullet_list)])
|
bullet_list)])
|
||||||
@ -251,7 +251,7 @@ def test_get_toctree_for_collapse(app):
|
|||||||
app.build()
|
app.build()
|
||||||
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=True)
|
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=True)
|
||||||
assert_node(toctree,
|
assert_node(toctree,
|
||||||
[compact_paragraph, ([caption, "Table of Contents"],
|
[compact_paragraph, ([title, "Table of Contents"],
|
||||||
bullet_list,
|
bullet_list,
|
||||||
bullet_list,
|
bullet_list,
|
||||||
bullet_list)])
|
bullet_list)])
|
||||||
@ -283,7 +283,7 @@ def test_get_toctree_for_maxdepth(app):
|
|||||||
toctree = TocTree(app.env).get_toctree_for('index', app.builder,
|
toctree = TocTree(app.env).get_toctree_for('index', app.builder,
|
||||||
collapse=False, maxdepth=3)
|
collapse=False, maxdepth=3)
|
||||||
assert_node(toctree,
|
assert_node(toctree,
|
||||||
[compact_paragraph, ([caption, "Table of Contents"],
|
[compact_paragraph, ([title, "Table of Contents"],
|
||||||
bullet_list,
|
bullet_list,
|
||||||
bullet_list,
|
bullet_list,
|
||||||
bullet_list)])
|
bullet_list)])
|
||||||
@ -329,7 +329,7 @@ def test_get_toctree_for_includehidden(app):
|
|||||||
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False,
|
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False,
|
||||||
includehidden=False)
|
includehidden=False)
|
||||||
assert_node(toctree,
|
assert_node(toctree,
|
||||||
[compact_paragraph, ([caption, "Table of Contents"],
|
[compact_paragraph, ([title, "Table of Contents"],
|
||||||
bullet_list,
|
bullet_list,
|
||||||
bullet_list)])
|
bullet_list)])
|
||||||
|
|
||||||
|
@ -622,11 +622,8 @@ def test_html_meta(app):
|
|||||||
assert expected_expr in result
|
assert expected_expr in result
|
||||||
expected_expr = '<meta content="I18N, SPHINX, MARKUP" name="keywords" />'
|
expected_expr = '<meta content="I18N, SPHINX, MARKUP" name="keywords" />'
|
||||||
assert expected_expr in result
|
assert expected_expr in result
|
||||||
if docutils.__version_info__ < (0, 17):
|
expected_expr = '<p class="caption"><span class="caption-text">HIDDEN TOC</span></p>'
|
||||||
expected_expr = '<p class="caption"><span class="caption-text">HIDDEN TOC</span></p>'
|
assert expected_expr in result
|
||||||
assert expected_expr in result
|
|
||||||
else:
|
|
||||||
expected_expr = '<p><span class="caption-text">HIDDEN TOC</span></p>'
|
|
||||||
|
|
||||||
|
|
||||||
@sphinx_intl
|
@sphinx_intl
|
||||||
|
Loading…
Reference in New Issue
Block a user