feat: build each doc kind with its own MkDocs config and site
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import json
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from docforge.cli.main import cli
|
||||
@@ -55,8 +55,10 @@ def test_api_build_full_flow(
|
||||
index = (api_dir / "index.md").read_text(encoding="utf-8")
|
||||
assert '<swagger-ui src="openapi.json"/>' in index
|
||||
|
||||
config = (cwd / "mkdocs.yml").read_text(encoding="utf-8")
|
||||
assert "docs_dir: docs" in config
|
||||
config = (cwd / "docs" / "mkdocs.api.yml").read_text(encoding="utf-8")
|
||||
assert "docs_dir: api" in config
|
||||
assert "site_dir: ../site/api" in config
|
||||
assert "- API Reference: index.md" in config
|
||||
assert "site_name: Aetoskia Auth Server" in config
|
||||
assert "site_description: Auth docs" in config
|
||||
assert "site_author: Aetoskia Dev Team" in config
|
||||
@@ -90,10 +92,9 @@ def test_api_build_rejects_site_name_override(cli_runner):
|
||||
assert "cannot be overridden" in result.output
|
||||
|
||||
|
||||
def test_api_build_combined_with_mkdocs_allows_site_name_for_lib(
|
||||
def test_api_build_combined_with_mkdocs_emits_separate_configs(
|
||||
cli_runner, mock_mkdocs_build, mock_mkdocs_load_config
|
||||
):
|
||||
# site_name is accepted when --mkdocs is also present (lib mode owns it)
|
||||
with cli_runner.isolated_filesystem():
|
||||
cwd = Path.cwd()
|
||||
|
||||
@@ -105,13 +106,7 @@ def test_api_build_combined_with_mkdocs_allows_site_name_for_lib(
|
||||
spec_path = _write_spec(cwd)
|
||||
|
||||
nav_file = cwd / "docforge.nav.yml"
|
||||
nav_file.write_text(
|
||||
"home: lib/testpkg/index.md\n"
|
||||
"groups:\n"
|
||||
" API:\n"
|
||||
" - api/index.md\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
nav_file.write_text("home: lib/testpkg/index.md\ngroups: {}\n")
|
||||
|
||||
result = cli_runner.invoke(
|
||||
cli,
|
||||
@@ -128,7 +123,20 @@ def test_api_build_combined_with_mkdocs_allows_site_name_for_lib(
|
||||
|
||||
assert result.exit_code == 0, result.output
|
||||
|
||||
config = (cwd / "mkdocs.yml").read_text(encoding="utf-8")
|
||||
assert "docs_dir: docs" in config
|
||||
assert "swagger-ui-tag" in config
|
||||
assert "mkdocstrings" in config
|
||||
lib_config = cwd / "docs" / "mkdocs.lib.yml"
|
||||
api_config = cwd / "docs" / "mkdocs.api.yml"
|
||||
assert lib_config.exists()
|
||||
assert api_config.exists()
|
||||
|
||||
lib_text = lib_config.read_text(encoding="utf-8")
|
||||
assert "docs_dir: lib" in lib_text
|
||||
assert "site_dir: ../site/lib" in lib_text
|
||||
assert "Home: testpkg/index.md" in lib_text
|
||||
|
||||
api_text = api_config.read_text(encoding="utf-8")
|
||||
assert "docs_dir: api" in api_text
|
||||
assert "site_dir: ../site/api" in api_text
|
||||
assert "- API Reference: index.md" in api_text
|
||||
assert "site_name: Aetoskia Auth Server" in api_text
|
||||
assert "swagger-ui-tag" in api_text
|
||||
assert "mkdocstrings" in lib_text
|
||||
|
||||
Reference in New Issue
Block a user