Maintainer Guide¶
This page summarizes how the API, CLI, and documentation site are wired together.
Public API boundary¶
The stable Python API is exported from:
The public API is organized into content translation helpers, path rewriting helpers, project orchestration, and review:
from co_op_translator.api import (
ImageTranslationOptions,
MarkdownTranslationOptions,
NotebookTranslationOptions,
run_review,
run_translation,
rewrite_markdown_paths,
rewrite_notebook_paths,
translate_image_content,
translate_markdown_content,
translate_notebook_content,
translate_project,
)
When adding new public APIs, update:
src/co_op_translator/api/__init__.pydocs/api.md- relevant API tests under
tests/co_op_translator/, such astest_api.pyortest_review_api.py
Avoid documenting lower-level core modules as stable API unless the project intends to support them directly.
CLI entry points¶
The package defines these Poetry scripts:
[tool.poetry.scripts]
translate = "co_op_translator.__main__:main"
evaluate = "co_op_translator.__main__:main"
migrate-links = "co_op_translator.__main__:main"
co-op-review = "co_op_translator.__main__:main"
co-op-translator-mcp = "co_op_translator.mcp.server:main"
src/co_op_translator/__main__.py dispatches by script name:
translatecallsco_op_translator.cli.translate.translate_commandevaluatecallsco_op_translator.cli.evaluate.evaluate_commandmigrate-linkscallsco_op_translator.cli.migrate_links.migrate_links_commandco-op-reviewcallsco_op_translator.cli.review.review_command
co-op-translator-mcp bypasses __main__.py and calls co_op_translator.mcp.server:main directly.
When adding or changing CLI options, update:
- the relevant
src/co_op_translator/cli/*.pycommand docs/cli.md- CLI-related tests, if behavior changes
MCP server¶
The MCP server is implemented in:
The server intentionally wraps the public Python API rather than calling lower-level core modules. Keep this boundary intact so MCP clients, Python callers, and the CLI share the same behavior.
When adding or changing MCP tools, update:
src/co_op_translator/mcp/server.pytests/co_op_translator/test_mcp_server.pydocs/mcp.mddocs/api.mdif the public API surface changes
Repository translation tools are model-callable through MCP and can write many files. Keep dry_run=True as the default and require confirm_write=True before non-dry-run project translation.
Translation flow¶
The high-level project translation flow is:
- Parse CLI arguments or API parameters.
- Validate LLM configuration with
LLMConfig. - Validate Azure AI Vision when image translation is selected.
- Normalize language codes.
- Detect legacy language folder aliases.
- Estimate translation volume.
- Update README language/course sections when applicable.
- Delegate project translation to
ProjectTranslator. ProjectTranslatordelegates file processing toTranslationManager.
TranslationManager is composed from focused file-type mixins:
ProjectMarkdownTranslationMixinhandles Markdown file reads, content translation, path rewriting, metadata, disclaimers, and writes.ProjectNotebookTranslationMixinhandles notebook file reads, Markdown-cell translation, path rewriting, metadata, disclaimers, and writes.ProjectImageTranslationMixinhandles image discovery, text extraction/translation, rendered image writes, and metadata.
The lower-level content APIs skip the project workflow:
translate_markdown_contentandtranslate_notebook_contenttranslate in-memory content only.translate_image_contenttranslates text in a single image and returns a rendered image object.rewrite_markdown_pathsandrewrite_notebook_pathsare explicit post-processing helpers. They perform no translation and no project writes.
Review flow¶
The deterministic review flow is:
- Parse CLI arguments or API parameters.
- Normalize requested language codes.
- Build one or more review targets from
root_dir,root_dirs, orgroups. - Optionally limit source files with
--changed-from. - Run deterministic checks for structure, translation freshness, Markdown integrity, and local link/image paths.
- Print either text output or GitHub-flavored Markdown.
- Exit with a failure when review errors are found.
The review flow does not require API keys and should remain suitable for pull request CI. The pull request workflow writes a check summary on every run and only posts a PR comment when co-op-review fails.
Documentation site¶
The docs site is configured by:
The docs/ directory is the canonical documentation source. Do not add new end-user guides outside this directory unless the project intentionally introduces another published documentation surface.
Build locally:
Preview locally:
The generated site is written to site/, which is ignored by git.
GitHub Pages workflow¶
.github/workflows/docs.yml builds the site on pull requests and deploys it on pushes to main.
The workflow installs:
Installing runtime dependencies before docs dependencies lets mkdocstrings import the package and render the public Python API reference.
Docs quality bar¶
Before merging documentation changes, run:
Use strict builds so broken links, invalid navigation entries, and API rendering issues fail early.