Skip to content

Commit 1f77be7

Browse files
committed
Merge branch '4.x'
2 parents 3f51f1a + f050a77 commit 1f77be7

File tree

10 files changed

+86
-14
lines changed

10 files changed

+86
-14
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test with the HEAD of docutils
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * SUN"
6+
workflow_dispatch:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up Python
15+
uses: actions/setup-python@v2
16+
- name: Check Python version
17+
run: python --version
18+
- name: Unpin docutils
19+
run: sed -i -e "s/'docutils>=.*'/'docutils'/" setup.py
20+
- name: Install graphviz
21+
run: sudo apt-get install graphviz
22+
- name: Install dependencies
23+
run: pip install -U tox codecov
24+
- name: Run Tox
25+
run: tox -e du-latest -- -vv

.github/workflows/main.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
name: [py36, py37, py38, py39]
11+
name: [py36, py37, py38, py39, py310]
1212
include:
1313
- name: py36
1414
python: 3.6
@@ -23,9 +23,12 @@ jobs:
2323
python: 3.9
2424
docutils: du17
2525
coverage: "--cov ./ --cov-append --cov-config setup.cfg"
26-
- name: py310-dev
27-
python: 3.10-dev
26+
- name: py310
27+
python: "3.10"
2828
docutils: du17
29+
- name: py311-dev
30+
python: 3.11-dev
31+
docutils: py311
2932
env:
3033
PYTEST_ADDOPTS: ${{ matrix.coverage }}
3134

@@ -47,6 +50,9 @@ jobs:
4750
run: sudo apt-get install graphviz
4851
- name: Install dependencies
4952
run: pip install -U tox codecov
53+
- name: Install the latest py package (for py3.11-dev)
54+
run: pip install -U git+https://github.com/pytest-dev/py
55+
if: ${{ matrix.python == '3.11-dev' }}
5056
- name: Run Tox
5157
run: tox -e ${{ matrix.docutils }} -- -vv
5258
- name: codecov

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Release 4.3.0 (in development)
2525
Dependencies
2626
------------
2727

28+
* Support Python 3.10
29+
2830
Incompatible changes
2931
--------------------
3032

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def _run_domain_js(self, domain):
207207
'Programming Language :: Python :: 3.7',
208208
'Programming Language :: Python :: 3.8',
209209
'Programming Language :: Python :: 3.9',
210+
'Programming Language :: Python :: 3.10',
210211
'Programming Language :: Python :: Implementation :: CPython',
211212
'Programming Language :: Python :: Implementation :: PyPy',
212213
'Framework :: Setuptools Plugin',

sphinx/addnodes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from docutils import nodes
1414
from docutils.nodes import Element
1515

16+
from sphinx.util import docutils
17+
1618
if TYPE_CHECKING:
1719
from sphinx.application import Sphinx
1820

@@ -563,14 +565,16 @@ def setup(app: "Sphinx") -> Dict[str, Any]:
563565
app.add_node(start_of_file)
564566
app.add_node(highlightlang)
565567
app.add_node(tabular_col_spec)
566-
app.add_node(meta)
567568
app.add_node(pending_xref)
568569
app.add_node(number_reference)
569570
app.add_node(download_reference)
570571
app.add_node(literal_emphasis)
571572
app.add_node(literal_strong)
572573
app.add_node(manpage)
573574

575+
if docutils.__version_info__ < (0, 18):
576+
app.add_node(meta)
577+
574578
return {
575579
'version': 'builtin',
576580
'parallel_read_safe': True,

sphinx/directives/patches.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from docutils import nodes
1515
from docutils.nodes import Node, make_id, system_message
1616
from docutils.parsers.rst import directives
17-
from docutils.parsers.rst.directives import html, images, tables
17+
from docutils.parsers.rst.directives import images, tables
1818

1919
from sphinx import addnodes
2020
from sphinx.deprecation import RemovedInSphinx60Warning
@@ -27,6 +27,15 @@
2727
from sphinx.util.osutil import SEP, os_path, relpath
2828
from sphinx.util.typing import OptionSpec
2929

30+
try:
31+
from docutils.nodes import meta as meta_node # type: ignore
32+
from docutils.parsers.rst.directives.misc import Meta as MetaBase # type: ignore
33+
except ImportError:
34+
# docutils-0.17 or older
35+
from docutils.parsers.rst.directives.html import Meta as MetaBase
36+
from docutils.parsers.rst.directives.html import MetaBody
37+
meta_node = MetaBody.meta
38+
3039
if TYPE_CHECKING:
3140
from sphinx.application import Sphinx
3241

@@ -60,19 +69,19 @@ def run(self) -> List[Node]:
6069
return [figure_node]
6170

6271

63-
class Meta(html.Meta, SphinxDirective):
72+
class Meta(MetaBase, SphinxDirective):
6473
def run(self) -> List[Node]:
6574
result = super().run()
6675
for node in result:
6776
if (isinstance(node, nodes.pending) and
68-
isinstance(node.details['nodes'][0], html.MetaBody.meta)):
77+
isinstance(node.details['nodes'][0], meta_node)):
6978
meta = node.details['nodes'][0]
7079
meta.source = self.env.doc2path(self.env.docname)
7180
meta.line = self.lineno
72-
meta.rawcontent = meta['content'] # type: ignore
81+
meta.rawcontent = meta['content']
7382

7483
# docutils' meta nodes aren't picklable because the class is nested
75-
meta.__class__ = addnodes.meta # type: ignore
84+
meta.__class__ = addnodes.meta
7685

7786
return result
7887

sphinx/environment/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
logger = logging.getLogger(__name__)
4646

4747
default_settings: Dict[str, Any] = {
48+
'embed_images': False,
4849
'embed_stylesheet': False,
4950
'cloak_email_addresses': True,
5051
'pep_base_url': 'https://www.python.org/dev/peps/',
@@ -54,6 +55,7 @@
5455
'input_encoding': 'utf-8-sig',
5556
'doctitle_xform': False,
5657
'sectsubtitle_xform': False,
58+
'section_self_link': False,
5759
'halt_level': 5,
5860
'file_insertion_enabled': True,
5961
'smartquotes_locales': [],

tests/test_ext_autodoc.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,9 +1399,16 @@ def test_slots(app):
13991399
def test_enum_class(app):
14001400
options = {"members": None}
14011401
actual = do_autodoc(app, 'class', 'target.enums.EnumCls', options)
1402+
1403+
if sys.version_info > (3, 11):
1404+
args = ('(value, names=None, *, module=None, qualname=None, '
1405+
'type=None, start=1, boundary=None)')
1406+
else:
1407+
args = '(value)'
1408+
14021409
assert list(actual) == [
14031410
'',
1404-
'.. py:class:: EnumCls(value)',
1411+
'.. py:class:: EnumCls' + args,
14051412
' :module: target.enums',
14061413
'',
14071414
' this is enum class',
@@ -2106,6 +2113,9 @@ def test_singledispatchmethod_automethod(app):
21062113
]
21072114

21082115

2116+
@pytest.mark.skipif(sys.version_info > (3, 11),
2117+
reason=('cython does not support python-3.11 yet. '
2118+
'see https://github.com/cython/cython/issues/4365'))
21092119
@pytest.mark.skipif(pyximport is None, reason='cython is not installed')
21102120
@pytest.mark.sphinx('html', testroot='ext-autodoc')
21112121
def test_cython(app):

tests/test_versioning.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111
import pickle
1212

1313
import pytest
14-
from docutils.parsers.rst.directives.html import MetaBody
1514

1615
from sphinx import addnodes
1716
from sphinx.testing.util import SphinxTestApp
1817
from sphinx.versioning import add_uids, get_ratio, merge_doctrees
1918

19+
try:
20+
from docutils.parsers.rst.directives.html import MetaBody
21+
meta = MetaBody.meta
22+
except ImportError:
23+
from docutils.nodes import meta
24+
2025
app = original = original_uids = None
2126

2227

@@ -64,7 +69,7 @@ def test_picklablility():
6469
copy.settings.warning_stream = None
6570
copy.settings.env = None
6671
copy.settings.record_dependencies = None
67-
for metanode in copy.traverse(MetaBody.meta):
72+
for metanode in copy.traverse(meta):
6873
metanode.__class__ = addnodes.meta
6974
loaded = pickle.loads(pickle.dumps(copy, pickle.HIGHEST_PROTOCOL))
7075
assert all(getattr(n, 'uid', False) for n in loaded.traverse(is_paragraph))

tox.ini

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
minversion = 2.4.0
3-
envlist = docs,flake8,mypy,twine,coverage,py{36,37,38,39},du{14,15,16,17}
3+
envlist = docs,flake8,mypy,twine,coverage,py{36,37,38,39,310},du{14,15,16,17}
44

55
[testenv]
66
usedevelop = True
@@ -15,13 +15,14 @@ passenv =
1515
EPUBCHECK_PATH
1616
TERM
1717
description =
18-
py{36,37,38,39}: Run unit tests against {envname}.
18+
py{36,37,38,39,310}: Run unit tests against {envname}.
1919
du{12,13,14}: Run unit tests with the given version of docutils.
2020
deps =
2121
du14: docutils==0.14.*
2222
du15: docutils==0.15.*
2323
du16: docutils==0.16.*
2424
du17: docutils==0.17.*
25+
py311: git+https://github.com/pytest-dev/py
2526
extras =
2627
test
2728
setenv =
@@ -30,6 +31,13 @@ setenv =
3031
commands=
3132
python -X dev -m pytest --durations 25 {posargs}
3233

34+
[testenv:du-latest]
35+
commands =
36+
git clone https://repo.or.cz/docutils.git {temp_dir}/docutils
37+
python -m pip install {temp_dir}/docutils/docutils
38+
rm -rf {temp_dir}/docutils
39+
{[testenv]commands}
40+
3341
[testenv:flake8]
3442
basepython = python3
3543
description =

0 commit comments

Comments
 (0)