|
19 | 19 | import os |
20 | 20 | import re |
21 | 21 | import shutil |
| 22 | +import sys |
22 | 23 | from contextlib import contextmanager |
| 24 | +from distutils.version import LooseVersion |
23 | 25 | from typing import Any, Generator |
24 | 26 |
|
25 | 27 | import git as gitpython |
| 28 | +import mkdocs |
26 | 29 | import pytest |
27 | 30 | from click.testing import CliRunner, Result |
28 | 31 | from git import Repo |
@@ -316,3 +319,26 @@ def test_fallback(tmp_path) -> None: |
316 | 319 | assert ( |
317 | 320 | result.exit_code == 0 |
318 | 321 | ), f"'mkdocs build' command failed. Error: {result.stdout}" |
| 322 | + |
| 323 | + |
| 324 | +# https://github.com/daizutabi/mkapi#:~:text=Python%203.10%20or,1.6%20or%20higher |
| 325 | +@pytest.mark.skipif(sys.version_info < (3, 10), reason="Requires Python 3.10 or higher") |
| 326 | +@pytest.mark.skipif( |
| 327 | + LooseVersion(mkdocs.__version__) < LooseVersion("1.6"), |
| 328 | + reason="Requires mkdocs 1.6 or higher", |
| 329 | +) |
| 330 | +def test_mkapi_v3(tmp_path) -> None: |
| 331 | + result = build_docs_setup("tests/basic_setup/mkdocs_mkapi.yml", tmp_path) |
| 332 | + assert ( |
| 333 | + result.exit_code == 0 |
| 334 | + ), f"'mkdocs build' command failed. Error: {result.stdout}" |
| 335 | + |
| 336 | + index_file = tmp_path / "index.html" |
| 337 | + assert index_file.exists(), f"{index_file} does not exist" |
| 338 | + |
| 339 | + contents = index_file.read_text() |
| 340 | + assert re.search("<span class='git-page-authors", contents) |
| 341 | + assert re.search( |
| 342 | + '<a href="#" class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-expanded="false">API</a>', |
| 343 | + contents, |
| 344 | + ) |
0 commit comments