|
12 | 12 | from autodoc2.render.rst_ import RstRenderer |
13 | 13 | from autodoc2.utils import yield_modules |
14 | 14 | import pytest |
| 15 | +import sphinx |
15 | 16 | from sphinx.testing.util import SphinxTestApp |
16 | | -from sphinx.testing.util import path as sphinx_path |
| 17 | + |
| 18 | +if sphinx.version_info >= (7, 2): |
| 19 | + sphinx_path = Path |
| 20 | +else: |
| 21 | + from sphinx.testing.path import path as sphinx_path |
17 | 22 |
|
18 | 23 |
|
19 | 24 | @pytest.mark.parametrize( |
@@ -224,6 +229,25 @@ def test_sphinx_build_directives(tmp_path: Path, file_regression): |
224 | 229 | doctree = app.env.get_doctree("index") |
225 | 230 | doctree["source"] = "index.rst" |
226 | 231 | content = "\n".join([line.rstrip() for line in doctree.pformat().splitlines()]) |
| 232 | + if sphinx.version_info < (7, 1): |
| 233 | + content = content.replace( |
| 234 | + '<document source="index.rst">', |
| 235 | + "<document source=\"index.rst\" translation_progress=\"{'total': 0, 'translated': 0}\">", |
| 236 | + ) |
| 237 | + content = content.replace( |
| 238 | + '<desc_parameterlist xml:space="preserve">', |
| 239 | + '<desc_parameterlist multi_line_parameter_list="False" xml:space="preserve">', |
| 240 | + ) |
| 241 | + if sphinx.version_info < (7, 2): |
| 242 | + content = content.replace( |
| 243 | + '<desc classes="py function" desctype="function" domain="py"', |
| 244 | + '<desc classes="py function" desctype="function" domain="py" no-contents-entry="False" no-index="False" no-index-entry="False" no-typesetting="False"', |
| 245 | + ) |
| 246 | + if sphinx.version_info < (8, 2): |
| 247 | + content = content.replace( |
| 248 | + '<desc_parameterlist multi_line_parameter_list="False"', |
| 249 | + '<desc_parameterlist multi_line_parameter_list="False" multi_line_trailing_comma="True"', |
| 250 | + ) |
227 | 251 | file_regression.check(content, extension=".xml") |
228 | 252 |
|
229 | 253 |
|
|
0 commit comments