- Consolidated CLI commands into [build](cci:1://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/mkdocs/logic.py:48:0-58:46) and [serve](cci:1://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/commands.py:70:0-92:32) using `--mkdocs` and `--mcp` flags. - Separated CLI orchestration logic into [docforge/cli/mkdocs/logic.py](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/mkdocs/logic.py:0:0-0:0) and [docforge/cli/mcp/logic.py](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/mcp/logic.py:0:0-0:0). - Moved command definitions to [docforge/cli/commands.py](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/commands.py:0:0-0:0), making [main.py](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/main.py:0:0-0:0) a thin entry point. - Aligned [.pyi](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/main.pyi:0:0-0:0) type stubs with [.py](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/tests/conftest.py:0:0-0:0) implementations across the package. - Added missing docstrings to internal helper functions and core classes. - Restructured tests into `tests/mkdocs/` and `tests/mcp/`. - Updated navigation specification to reflect the new project structure.
55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
from pathlib import Path
|
|
from docforge.cli.main import cli
|
|
|
|
def test_mkdocs_build_full_flow(
|
|
cli_runner,
|
|
mock_mkdocs_build,
|
|
mock_mkdocs_load_config,
|
|
tmp_path,
|
|
):
|
|
# This test covers what used to be generate + mkdocs + build
|
|
with cli_runner.isolated_filesystem():
|
|
cwd = Path.cwd()
|
|
pkg = cwd / "testpkg"
|
|
pkg.mkdir()
|
|
(pkg / "__init__.py").write_text("")
|
|
(pkg / "mod.py").write_text("def f(): ...\n")
|
|
|
|
nav_file = cwd / "docforge.nav.yml"
|
|
nav_file.write_text("home: testpkg/index.md\ngroups: {}\n")
|
|
|
|
# We need to create a dummy testpkg/index.md for nav resolution if it's there
|
|
# But generate_sources will create it.
|
|
# Wait, the current logic runs generate_sources first, THEN generate_config.
|
|
|
|
result = cli_runner.invoke(
|
|
cli,
|
|
[
|
|
"build",
|
|
"--mkdocs",
|
|
"--module",
|
|
"testpkg",
|
|
"--site-name",
|
|
"Test Site",
|
|
"--docs-dir",
|
|
"docs",
|
|
"--mkdocs-yml",
|
|
"mkdocs.yml",
|
|
],
|
|
)
|
|
|
|
assert result.exit_code == 0
|
|
assert mock_mkdocs_build() is True
|
|
assert (cwd / "mkdocs.yml").exists()
|
|
assert (cwd / "docs" / "testpkg" / "mod.md").exists()
|
|
|
|
def test_mkdocs_build_missing_module_fails(cli_runner):
|
|
result = cli_runner.invoke(cli, ["build", "--mkdocs", "--site-name", "Test"])
|
|
assert result.exit_code != 0
|
|
assert "--module is required" in result.output
|
|
|
|
def test_mkdocs_build_missing_site_name_fails(cli_runner):
|
|
result = cli_runner.invoke(cli, ["build", "--mkdocs", "--module", "testpkg"])
|
|
assert result.exit_code != 0
|
|
assert "--site-name is required" in result.output
|