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:
@@ -2,7 +2,7 @@ import json
|
||||
from pathlib import Path
|
||||
|
||||
from docforge import MCPRenderer
|
||||
from docforge.models import Project, Module
|
||||
from docforge.models import Module, Project
|
||||
|
||||
|
||||
def test_mcp_file_content(tmp_path: Path):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
from docforge import MCPRenderer
|
||||
from docforge.models import Project, Module
|
||||
from docforge.models import Module, Project
|
||||
|
||||
|
||||
def test_mcp_idempotent(tmp_path: Path):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
from docforge.loaders import GriffeLoader, discover_module_paths
|
||||
from docforge import MCPRenderer
|
||||
from docforge.loaders import GriffeLoader, discover_module_paths
|
||||
|
||||
|
||||
def test_mcp_emits_all_modules(tmp_path: Path) -> None:
|
||||
@@ -22,10 +22,7 @@ def test_mcp_emits_all_modules(tmp_path: Path) -> None:
|
||||
for p in (tmp_path / "modules").rglob("*.json")
|
||||
}
|
||||
|
||||
expected = {
|
||||
f"modules/{m.path}.json"
|
||||
for m in project.get_all_modules()
|
||||
}
|
||||
expected = {f"modules/{m.path}.json" for m in project.get_all_modules()}
|
||||
|
||||
missing = expected - emitted
|
||||
assert not missing, f"Missing MCP module JSON files: {missing}"
|
||||
|
||||
73
tests/renderers/mcp/test_mcp_signatures.py
Normal file
73
tests/renderers/mcp/test_mcp_signatures.py
Normal file
@@ -0,0 +1,73 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from docforge import MCPRenderer
|
||||
from docforge.loaders import GriffeLoader, discover_module_paths
|
||||
|
||||
|
||||
def _load_docforge_bundle(tmp_path: Path) -> Path:
|
||||
project_root = Path(__file__).resolve().parents[3]
|
||||
loader = GriffeLoader()
|
||||
paths = discover_module_paths("docforge", project_root=project_root)
|
||||
project = loader.load_project(paths)
|
||||
|
||||
out_dir = tmp_path / "mcp"
|
||||
MCPRenderer().generate_sources(project, out_dir)
|
||||
return out_dir
|
||||
|
||||
|
||||
def test_mcp_signatures_are_clean(tmp_path: Path) -> None:
|
||||
out_dir = _load_docforge_bundle(tmp_path)
|
||||
|
||||
object_payload = json.loads(
|
||||
(out_dir / "modules" / "docforge.models.object.json").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
)
|
||||
|
||||
cls = object_payload["content"]["objects"]["DocObject"]
|
||||
assert isinstance(cls["signature"], str)
|
||||
assert "bound method" not in cls["signature"]
|
||||
assert cls["signature"].startswith("DocObject(")
|
||||
|
||||
renderer_payload = json.loads(
|
||||
(out_dir / "modules" / "docforge.renderers.mcp_renderer.json").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
)
|
||||
|
||||
method = renderer_payload["content"]["objects"]["MCPRenderer"]["members"][
|
||||
"generate_sources"
|
||||
]
|
||||
assert isinstance(method["signature"], str)
|
||||
assert "bound method" not in method["signature"]
|
||||
assert method["signature"].startswith("generate_sources(")
|
||||
|
||||
|
||||
def test_mcp_skips_unresolvable_import_aliases(tmp_path: Path) -> None:
|
||||
out_dir = _load_docforge_bundle(tmp_path)
|
||||
|
||||
renderer_payload = json.loads(
|
||||
(out_dir / "modules" / "docforge.renderers.mcp_renderer.json").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
)
|
||||
|
||||
object_names = set(renderer_payload["content"]["objects"])
|
||||
assert "json" not in object_names
|
||||
assert "Path" not in object_names
|
||||
|
||||
|
||||
def test_mcp_keeps_resolvable_package_reexports(tmp_path: Path) -> None:
|
||||
out_dir = _load_docforge_bundle(tmp_path)
|
||||
|
||||
root_payload = json.loads(
|
||||
(out_dir / "modules" / "docforge.json").read_text(encoding="utf-8")
|
||||
)
|
||||
|
||||
discover = root_payload["content"]["objects"]["discover_module_paths"]
|
||||
assert discover["name"] == "discover_module_paths"
|
||||
assert isinstance(discover["signature"], str)
|
||||
assert "bound method" not in discover["signature"]
|
||||
assert discover["signature"].startswith("discover_module_paths(")
|
||||
assert discover["docstring"] is not None
|
||||
@@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
from docforge import MCPRenderer
|
||||
from docforge.models import Project, Module
|
||||
from docforge.models import Module, Project
|
||||
|
||||
|
||||
def test_mcp_directory_structure(tmp_path: Path):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
from docforge import MkDocsRenderer
|
||||
from docforge.models import Project, Module
|
||||
from docforge.models import Module, Project
|
||||
|
||||
|
||||
def test_mkdocs_file_content(tmp_path: Path):
|
||||
@@ -47,4 +47,4 @@ def test_generate_readme_source_root(tmp_path: Path):
|
||||
content = readme.read_text()
|
||||
|
||||
assert "# testpkg" in content
|
||||
assert "Test package documentation." in content
|
||||
assert "Test package documentation." in content
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
from docforge import MkDocsRenderer
|
||||
from docforge.models import Project, Module
|
||||
from docforge.models import Module, Project
|
||||
|
||||
|
||||
def test_mkdocs_idempotent(tmp_path: Path):
|
||||
@@ -50,4 +50,4 @@ def test_generate_readme_idempotent(tmp_path: Path):
|
||||
|
||||
second = readme.read_text()
|
||||
|
||||
assert first == second
|
||||
assert first == second
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
from docforge.loaders import GriffeLoader, discover_module_paths
|
||||
from docforge import MkDocsRenderer
|
||||
from docforge.loaders import GriffeLoader, discover_module_paths
|
||||
|
||||
|
||||
def test_mkdocs_emits_all_modules(tmp_path: Path) -> None:
|
||||
@@ -23,10 +23,7 @@ def test_mkdocs_emits_all_modules(tmp_path: Path) -> None:
|
||||
module_is_source=True,
|
||||
)
|
||||
|
||||
emitted = {
|
||||
p.relative_to(tmp_path).as_posix()
|
||||
for p in tmp_path.rglob("*.md")
|
||||
}
|
||||
emitted = {p.relative_to(tmp_path).as_posix() for p in tmp_path.rglob("*.md")}
|
||||
|
||||
module_paths = [m.path for m in project.get_all_modules()]
|
||||
|
||||
@@ -34,8 +31,7 @@ def test_mkdocs_emits_all_modules(tmp_path: Path) -> None:
|
||||
for path in module_paths:
|
||||
parts = path.split(".")
|
||||
is_package = any(
|
||||
other != path and other.startswith(path + ".")
|
||||
for other in module_paths
|
||||
other != path and other.startswith(path + ".") for other in module_paths
|
||||
)
|
||||
|
||||
if is_package:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
from docforge import MkDocsRenderer
|
||||
from docforge.models import Project, Module
|
||||
from docforge.models import Module, Project
|
||||
|
||||
|
||||
def test_mkdocs_directory_structure(tmp_path: Path):
|
||||
|
||||
Reference in New Issue
Block a user