Merge branch '4.x'

This commit is contained in:
Takeshi KOMIYA
2021-10-09 14:49:12 +09:00
10 changed files with 86 additions and 14 deletions

25
.github/workflows/docutils-latest.yml vendored Normal file
View File

@@ -0,0 +1,25 @@
name: Test with the HEAD of docutils
on:
schedule:
- cron: "0 0 * * SUN"
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Check Python version
run: python --version
- name: Unpin docutils
run: sed -i -e "s/'docutils>=.*'/'docutils'/" setup.py
- name: Install graphviz
run: sudo apt-get install graphviz
- name: Install dependencies
run: pip install -U tox codecov
- name: Run Tox
run: tox -e du-latest -- -vv

View File

@@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
name: [py36, py37, py38, py39]
name: [py36, py37, py38, py39, py310]
include:
- name: py36
python: 3.6
@@ -23,9 +23,12 @@ jobs:
python: 3.9
docutils: du17
coverage: "--cov ./ --cov-append --cov-config setup.cfg"
- name: py310-dev
python: 3.10-dev
- name: py310
python: "3.10"
docutils: du17
- name: py311-dev
python: 3.11-dev
docutils: py311
env:
PYTEST_ADDOPTS: ${{ matrix.coverage }}
@@ -47,6 +50,9 @@ jobs:
run: sudo apt-get install graphviz
- name: Install dependencies
run: pip install -U tox codecov
- name: Install the latest py package (for py3.11-dev)
run: pip install -U git+https://github.com/pytest-dev/py
if: ${{ matrix.python == '3.11-dev' }}
- name: Run Tox
run: tox -e ${{ matrix.docutils }} -- -vv
- name: codecov

View File

@@ -25,6 +25,8 @@ Release 4.3.0 (in development)
Dependencies
------------
* Support Python 3.10
Incompatible changes
--------------------

View File

@@ -207,6 +207,7 @@ setup(
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Framework :: Setuptools Plugin',

View File

@@ -13,6 +13,8 @@ from typing import TYPE_CHECKING, Any, Dict, List, Sequence
from docutils import nodes
from docutils.nodes import Element
from sphinx.util import docutils
if TYPE_CHECKING:
from sphinx.application import Sphinx
@@ -563,7 +565,6 @@ def setup(app: "Sphinx") -> Dict[str, Any]:
app.add_node(start_of_file)
app.add_node(highlightlang)
app.add_node(tabular_col_spec)
app.add_node(meta)
app.add_node(pending_xref)
app.add_node(number_reference)
app.add_node(download_reference)
@@ -571,6 +572,9 @@ def setup(app: "Sphinx") -> Dict[str, Any]:
app.add_node(literal_strong)
app.add_node(manpage)
if docutils.__version_info__ < (0, 18):
app.add_node(meta)
return {
'version': 'builtin',
'parallel_read_safe': True,

View File

@@ -14,7 +14,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Tuple, cast
from docutils import nodes
from docutils.nodes import Node, make_id, system_message
from docutils.parsers.rst import directives
from docutils.parsers.rst.directives import html, images, tables
from docutils.parsers.rst.directives import images, tables
from sphinx import addnodes
from sphinx.deprecation import RemovedInSphinx60Warning
@@ -27,6 +27,15 @@ from sphinx.util.nodes import set_source_info
from sphinx.util.osutil import SEP, os_path, relpath
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
@@ -60,19 +69,19 @@ class Figure(images.Figure):
return [figure_node]
class Meta(html.Meta, SphinxDirective):
class Meta(MetaBase, SphinxDirective):
def run(self) -> List[Node]:
result = super().run()
for node in result:
if (isinstance(node, nodes.pending) and
isinstance(node.details['nodes'][0], html.MetaBody.meta)):
isinstance(node.details['nodes'][0], meta_node)):
meta = node.details['nodes'][0]
meta.source = self.env.doc2path(self.env.docname)
meta.line = self.lineno
meta.rawcontent = meta['content'] # type: ignore
meta.rawcontent = meta['content']
# docutils' meta nodes aren't picklable because the class is nested
meta.__class__ = addnodes.meta # type: ignore
meta.__class__ = addnodes.meta
return result

View File

@@ -45,6 +45,7 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
default_settings: Dict[str, Any] = {
'embed_images': False,
'embed_stylesheet': False,
'cloak_email_addresses': True,
'pep_base_url': 'https://www.python.org/dev/peps/',
@@ -54,6 +55,7 @@ default_settings: Dict[str, Any] = {
'input_encoding': 'utf-8-sig',
'doctitle_xform': False,
'sectsubtitle_xform': False,
'section_self_link': False,
'halt_level': 5,
'file_insertion_enabled': True,
'smartquotes_locales': [],

View File

@@ -1399,9 +1399,16 @@ def test_slots(app):
def test_enum_class(app):
options = {"members": None}
actual = do_autodoc(app, 'class', 'target.enums.EnumCls', options)
if sys.version_info > (3, 11):
args = ('(value, names=None, *, module=None, qualname=None, '
'type=None, start=1, boundary=None)')
else:
args = '(value)'
assert list(actual) == [
'',
'.. py:class:: EnumCls(value)',
'.. py:class:: EnumCls' + args,
' :module: target.enums',
'',
' this is enum class',
@@ -2106,6 +2113,9 @@ def test_singledispatchmethod_automethod(app):
]
@pytest.mark.skipif(sys.version_info > (3, 11),
reason=('cython does not support python-3.11 yet. '
'see https://github.com/cython/cython/issues/4365'))
@pytest.mark.skipif(pyximport is None, reason='cython is not installed')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_cython(app):

View File

@@ -11,12 +11,17 @@
import pickle
import pytest
from docutils.parsers.rst.directives.html import MetaBody
from sphinx import addnodes
from sphinx.testing.util import SphinxTestApp
from sphinx.versioning import add_uids, get_ratio, merge_doctrees
try:
from docutils.parsers.rst.directives.html import MetaBody
meta = MetaBody.meta
except ImportError:
from docutils.nodes import meta
app = original = original_uids = None
@@ -64,7 +69,7 @@ def test_picklablility():
copy.settings.warning_stream = None
copy.settings.env = None
copy.settings.record_dependencies = None
for metanode in copy.traverse(MetaBody.meta):
for metanode in copy.traverse(meta):
metanode.__class__ = addnodes.meta
loaded = pickle.loads(pickle.dumps(copy, pickle.HIGHEST_PROTOCOL))
assert all(getattr(n, 'uid', False) for n in loaded.traverse(is_paragraph))

12
tox.ini
View File

@@ -1,6 +1,6 @@
[tox]
minversion = 2.4.0
envlist = docs,flake8,mypy,twine,coverage,py{36,37,38,39},du{14,15,16,17}
envlist = docs,flake8,mypy,twine,coverage,py{36,37,38,39,310},du{14,15,16,17}
[testenv]
usedevelop = True
@@ -15,13 +15,14 @@ passenv =
EPUBCHECK_PATH
TERM
description =
py{36,37,38,39}: Run unit tests against {envname}.
py{36,37,38,39,310}: Run unit tests against {envname}.
du{12,13,14}: Run unit tests with the given version of docutils.
deps =
du14: docutils==0.14.*
du15: docutils==0.15.*
du16: docutils==0.16.*
du17: docutils==0.17.*
py311: git+https://github.com/pytest-dev/py
extras =
test
setenv =
@@ -30,6 +31,13 @@ setenv =
commands=
python -X dev -m pytest --durations 25 {posargs}
[testenv:du-latest]
commands =
git clone https://repo.or.cz/docutils.git {temp_dir}/docutils
python -m pip install {temp_dir}/docutils/docutils
rm -rf {temp_dir}/docutils
{[testenv]commands}
[testenv:flake8]
basepython = python3
description =