This document describes the Sphinx documentation setup for Mousetail.
- Location:
docs/conf.py - Theme: Furo (modern, clean theme)
- Extensions:
sphinx.ext.autodoc- Automatic API documentation from docstringssphinx.ext.napoleon- Support for Google/NumPy style docstringssphinx.ext.viewcode- Links to source codesphinx.ext.intersphinx- Links to other project docs (e.g., Python)sphinx_autodoc_typehints- Type hints in documentation
docs/
├── conf.py # Sphinx configuration
├── index.rst # Main documentation page
├── quickstart.rst # Quick start guide
├── api/
│ ├── index.rst # API overview
│ ├── server.rst # AnkiMCPServer docs
│ ├── tools.rst # Tool functions docs
│ └── collection_manager.rst # CollectionManager docs
├── _static/ # Static files (empty for now)
└── _build/ # Generated HTML (gitignored)
All Python modules now have comprehensive docstrings following Google style:
mousetail/mcp/server.py- MCP server implementationmousetail/mcp/tools.py- Tool implementationsmousetail/server/collection_manager.py- Collection management
Each function includes:
- Summary description
- Args section with type hints
- Returns section describing output
- Example usage where appropriate
Updated .github/workflows/docs.yml to:
- Install documentation dependencies
- Build Sphinx documentation
- Deploy to GitHub Pages automatically on push to main
Added to pyproject.toml:
[project.optional-dependencies]
docs = [
"sphinx>=7.0.0",
"furo>=2024.0.0",
"sphinx-autodoc-typehints>=2.0.0",
]uv pip install ".[docs]"uv run python -m sphinx -b html docs docs/_build/html# macOS
open docs/_build/html/index.html
# Linux
xdg-open docs/_build/html/index.html
# Windows
start docs/_build/html/index.htmlWhen adding new Python modules:
- Add comprehensive docstrings to the module and all public functions/classes
- Create a new
.rstfile indocs/api/(e.g.,docs/api/new_module.rst) - Add automodule directives:
New Module ========== .. automodule:: mousetail.new_module :members: :undoc-members: :show-inheritance:
- Add the new file to the toctree in
docs/api/index.rst
Use Google-style docstrings:
def example_function(arg1: str, arg2: int = 10) -> dict:
"""Brief description of the function.
More detailed explanation if needed. This can span
multiple lines and include additional context.
Args:
arg1: Description of arg1.
arg2: Description of arg2. Default is 10.
Returns:
Dict with 'key1' (str) and 'key2' (int).
Raises:
ValueError: If arg1 is empty.
KeyError: If required key is missing.
Example:
>>> result = example_function("test", 20)
>>> print(result['key1'])
'test'
"""
passEdit docs/quickstart.rst to update:
- Installation instructions
- Configuration examples
- Usage examples
- Troubleshooting tips
The Furo theme can be customized in docs/conf.py:
html_theme_options = {
"sidebar_hide_name": False,
"navigation_with_keys": True,
# Add more options as needed
}See Furo documentation for all available options.
Documentation is automatically deployed via GitHub Actions:
- Push to main branch triggers the workflow
- Workflow builds Sphinx docs
- Generated HTML is deployed to GitHub Pages
- Accessible at: https://listfold.github.io/mousetail/
The warnings about "duplicate object description" are normal and occur when using both:
.. automodule::(includes all members)- Explicit
.. autofunction::or.. autoclass::directives
These warnings don't affect the output. To suppress them, add :no-index: to the explicit directives.
If Sphinx can't import modules:
- Ensure all dependencies are installed:
uv pip install ".[docs]" - Check that
sys.path.insert(0, os.path.abspath('..'))is inconf.py - Verify the package structure has proper
__init__.pyfiles
If GitHub Actions fails:
- Check the workflow logs for specific errors
- Test the build locally first
- Ensure all doc dependencies are in
pyproject.toml - Verify Python version matches between local and CI (3.10)