chore(release): 0.0.7

Squash-merge lib-standardisation: adopt repo standards across packaging,
tooling, docs, and CI.

- standardize pyproject.toml (canonical packaging, lint config, extras, GSDFC pydoclint)
- add py.typed marker, modernize type hints and Google-style docstrings
- nest generated docs under docs/lib and docs/mcp; add hand-written wiki
- adopt standard Type A PyPI CI pipeline (tag==version guard + quality gate)
- promote generated CHANGELOG.md; bump version to 0.0.7
This commit is contained in:
2026-10-17 02:16:44 +05:30
parent 8253c25928
commit 06ffd2febd
149 changed files with 7132 additions and 4594 deletions

View File

@@ -1,6 +1,8 @@
from pathlib import Path
from docforge.cli.main import cli
def test_mkdocs_build_full_flow(
cli_runner,
mock_mkdocs_build,
@@ -16,12 +18,8 @@ def test_mkdocs_build_full_flow(
(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.
nav_file.write_text("home: lib/testpkg/index.md\ngroups: {}\n")
result = cli_runner.invoke(
cli,
[
@@ -31,23 +29,27 @@ def test_mkdocs_build_full_flow(
"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()
config = cwd / "docs" / "mkdocs.lib.yml"
assert config.exists()
assert (cwd / "docs" / "lib" / "testpkg" / "mod.md").exists()
content = config.read_text(encoding="utf-8")
assert "docs_dir: lib" in content
assert "site_dir: ../site/lib" in content
assert "Home: testpkg/index.md" in content
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_without_site_name_uses_module_as_default_full_flow(
cli_runner,
mock_mkdocs_build,
@@ -63,37 +65,98 @@ def test_mkdocs_build_without_site_name_uses_module_as_default_full_flow(
(pkg / "__init__.py").write_text("")
(pkg / "mod.py").write_text("def f(): ...\n")
# Create nav spec expected by generate_config
# Create nav spec expected by build_lib_nav
nav_file = cwd / "docforge.nav.yml"
nav_file.write_text(
"home: testpkg/index.md\ngroups: {}\n",
"home: lib/testpkg/index.md\ngroups: {}\n",
encoding="utf-8",
)
result = cli_runner.invoke(
cli,
[
"build",
"--mkdocs",
"--module",
"testpkg",
"--docs-dir",
"docs",
"--mkdocs-yml",
"mkdocs.yml",
],
["build", "--mkdocs", "--module", "testpkg"],
)
assert result.exit_code == 0
assert mock_mkdocs_build() is True
# MkDocs config must exist
mkdocs_yml = cwd / "mkdocs.yml"
assert mkdocs_yml.exists()
# The per-kind MkDocs config must exist
config = cwd / "docs" / "mkdocs.lib.yml"
assert config.exists()
# Site name must default to module name
content = mkdocs_yml.read_text()
content = config.read_text(encoding="utf-8")
assert "site_name: testpkg" in content
# Docs must be generated
assert (cwd / "docs" / "testpkg" / "mod.md").exists()
# Docs must be generated under the nested docs/lib dir
assert (cwd / "docs" / "lib" / "testpkg" / "mod.md").exists()
def test_existing_lib_config_used_verbatim_without_refresh(
cli_runner,
mock_mkdocs_build,
mock_mkdocs_load_config,
):
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: lib/testpkg/index.md\ngroups: {}\n",
encoding="utf-8",
)
config = cwd / "docs" / "mkdocs.lib.yml"
config.parent.mkdir(parents=True)
sentinel = "site_name: Custom Lib\nnav: []\n"
config.write_text(sentinel, encoding="utf-8")
result = cli_runner.invoke(
cli,
["build", "--mkdocs", "--module", "testpkg"],
)
assert result.exit_code == 0, result.output
assert mock_mkdocs_build() is True
assert config.read_text(encoding="utf-8") == sentinel
assert "Using existing MkDocs config" in result.output
def test_refresh_rebases_existing_lib_config(
cli_runner,
mock_mkdocs_build,
mock_mkdocs_load_config,
):
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: lib/testpkg/index.md\ngroups: {}\n",
encoding="utf-8",
)
config = cwd / "docs" / "mkdocs.lib.yml"
config.parent.mkdir(parents=True)
config.write_text("site_name: Stale\nnav: []\n", encoding="utf-8")
result = cli_runner.invoke(
cli,
["build", "--mkdocs", "--module", "testpkg", "--refresh"],
)
assert result.exit_code == 0, result.output
assert mock_mkdocs_build() is True
content = config.read_text(encoding="utf-8")
assert "site_name: testpkg" in content
assert "docs_dir: lib" in content
assert "site_dir: ../site/lib" in content
assert "Home: testpkg/index.md" in content