Skip to content

Commit 1df14a4

Browse files
committed
Merge branch '3.5.x' into 3.x
2 parents fcb7d01 + 43dc091 commit 1df14a4

File tree

9 files changed

+44
-17
lines changed

9 files changed

+44
-17
lines changed

CHANGES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Release 3.5.4 (in development)
44
Dependencies
55
------------
66

7+
* #9071: Restrict docutils to 0.16
8+
79
Incompatible changes
810
--------------------
911

@@ -16,6 +18,11 @@ Features added
1618
Bugs fixed
1719
----------
1820

21+
* #9078: autodoc: Async staticmethods and classmethods are considered as non
22+
async coroutine-functions with Python3.10
23+
* #8870: The style of toctree captions has been changed with docutils-0.17
24+
* #9001: The style of ``sidebar`` directive has been changed with docutils-0.17
25+
1926
Testing
2027
--------
2128

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
'sphinxcontrib-qthelp',
2424
'Jinja2>=2.3',
2525
'Pygments>=2.0',
26-
'docutils>=0.12',
26+
'docutils>=0.12,<0.17',
2727
'snowballstemmer>=1.1',
2828
'babel>=1.3',
2929
'alabaster>=0.7,<0.8',

sphinx/environment/adapters/toctree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def _entries_from_toctree(toctreenode: addnodes.toctree, parents: List[str],
237237
newnode = addnodes.compact_paragraph('', '')
238238
caption = toctree.attributes.get('caption')
239239
if caption:
240-
caption_node = nodes.caption(caption, '', *[nodes.Text(caption)])
240+
caption_node = nodes.title(caption, '', *[nodes.Text(caption)])
241241
caption_node.line = toctree.line
242242
caption_node.source = toctree.source
243243
caption_node.rawsource = toctree['rawcaption']

sphinx/themes/basic/static/basic.css_t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ img.align-default, .figure.align-default {
319319

320320
/* -- sidebars -------------------------------------------------------------- */
321321

322-
div.sidebar {
322+
div.sidebar,
323+
aside.sidebar {
323324
margin: 0 0 0.5em 1em;
324325
border: 1px solid #ddb;
325326
padding: 7px;
@@ -377,12 +378,14 @@ div.body p.centered {
377378
/* -- content of sidebars/topics/admonitions -------------------------------- */
378379

379380
div.sidebar > :last-child,
381+
aside.sidebar > :last-child,
380382
div.topic > :last-child,
381383
div.admonition > :last-child {
382384
margin-bottom: 0;
383385
}
384386

385387
div.sidebar::after,
388+
aside.sidebar::after,
386389
div.topic::after,
387390
div.admonition::after,
388391
blockquote::after {

sphinx/util/inspect.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,18 @@ def isroutine(obj: Any) -> bool:
352352

353353
def iscoroutinefunction(obj: Any) -> bool:
354354
"""Check if the object is coroutine-function."""
355-
# unwrap staticmethod, classmethod and partial (except wrappers)
356-
obj = unwrap_all(obj, stop=lambda o: hasattr(o, '__wrapped__'))
355+
def iswrappedcoroutine(obj: Any) -> bool:
356+
"""Check if the object is wrapped coroutine-function."""
357+
if isstaticmethod(obj) or isclassmethod(obj) or ispartial(obj):
358+
# staticmethod, classmethod and partial method are not a wrapped coroutine-function
359+
# Note: Since 3.10, staticmethod and classmethod becomes a kind of wrappers
360+
return False
361+
elif hasattr(obj, '__wrapped__'):
362+
return True
363+
else:
364+
return False
365+
366+
obj = unwrap_all(obj, stop=iswrappedcoroutine)
357367
if hasattr(obj, '__code__') and inspect.iscoroutinefunction(obj):
358368
# check obj.__code__ because iscoroutinefunction() crashes for custom method-like
359369
# objects (see https://github.com/sphinx-doc/sphinx/issues/6605)

sphinx/writers/html.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,12 @@ def depart_term(self, node: Element) -> None:
404404

405405
# overwritten
406406
def visit_title(self, node: Element) -> None:
407-
super().visit_title(node)
407+
if isinstance(node.parent, addnodes.compact_paragraph) and node.parent.get('toctree'):
408+
self.body.append(self.starttag(node, 'p', '', CLASS='caption'))
409+
self.body.append('<span class="caption-text">')
410+
self.context.append('</span></p>\n')
411+
else:
412+
super().visit_title(node)
408413
self.add_secnumber(node)
409414
self.add_fignumber(node.parent)
410415
if isinstance(node.parent, nodes.table):

sphinx/writers/html5.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,12 @@ def depart_term(self, node: Element) -> None:
355355

356356
# overwritten
357357
def visit_title(self, node: Element) -> None:
358-
super().visit_title(node)
358+
if isinstance(node.parent, addnodes.compact_paragraph) and node.parent.get('toctree'):
359+
self.body.append(self.starttag(node, 'p', '', CLASS='caption'))
360+
self.body.append('<span class="caption-text">')
361+
self.context.append('</span></p>\n')
362+
else:
363+
super().visit_title(node)
359364
self.add_secnumber(node)
360365
self.add_fignumber(node.parent)
361366
if isinstance(node.parent, nodes.table):

tests/test_environment_toctree.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import pytest
1212
from docutils import nodes
13-
from docutils.nodes import bullet_list, caption, comment, list_item, reference
13+
from docutils.nodes import bullet_list, comment, list_item, reference, title
1414

1515
from sphinx import addnodes
1616
from sphinx.addnodes import compact_paragraph, only
@@ -211,7 +211,7 @@ def test_get_toctree_for(app):
211211
app.build()
212212
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False)
213213
assert_node(toctree,
214-
[compact_paragraph, ([caption, "Table of Contents"],
214+
[compact_paragraph, ([title, "Table of Contents"],
215215
bullet_list,
216216
bullet_list,
217217
bullet_list)])
@@ -251,7 +251,7 @@ def test_get_toctree_for_collapse(app):
251251
app.build()
252252
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=True)
253253
assert_node(toctree,
254-
[compact_paragraph, ([caption, "Table of Contents"],
254+
[compact_paragraph, ([title, "Table of Contents"],
255255
bullet_list,
256256
bullet_list,
257257
bullet_list)])
@@ -283,7 +283,7 @@ def test_get_toctree_for_maxdepth(app):
283283
toctree = TocTree(app.env).get_toctree_for('index', app.builder,
284284
collapse=False, maxdepth=3)
285285
assert_node(toctree,
286-
[compact_paragraph, ([caption, "Table of Contents"],
286+
[compact_paragraph, ([title, "Table of Contents"],
287287
bullet_list,
288288
bullet_list,
289289
bullet_list)])
@@ -329,7 +329,7 @@ def test_get_toctree_for_includehidden(app):
329329
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False,
330330
includehidden=False)
331331
assert_node(toctree,
332-
[compact_paragraph, ([caption, "Table of Contents"],
332+
[compact_paragraph, ([title, "Table of Contents"],
333333
bullet_list,
334334
bullet_list)])
335335

tests/test_intl.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,8 @@ def test_html_meta(app):
622622
assert expected_expr in result
623623
expected_expr = '<meta content="I18N, SPHINX, MARKUP" name="keywords" />'
624624
assert expected_expr in result
625-
if docutils.__version_info__ < (0, 17):
626-
expected_expr = '<p class="caption"><span class="caption-text">HIDDEN TOC</span></p>'
627-
assert expected_expr in result
628-
else:
629-
expected_expr = '<p><span class="caption-text">HIDDEN TOC</span></p>'
625+
expected_expr = '<p class="caption"><span class="caption-text">HIDDEN TOC</span></p>'
626+
assert expected_expr in result
630627

631628

632629
@sphinx_intl

0 commit comments

Comments
 (0)