Thank you for your interest in contributing to sphinx-typesense! This guide will help you get set up and ready to contribute.
Table of Contents
Before you begin, ensure you have the following installed:
- Python 3.9+ - The project supports Python 3.9 through 3.13
- uv - Modern Python package manager (installation guide)
- Docker - Required for running integration tests with Typesense
- Git - For version control
Fork and clone the repository:
git clone https://github.com/YOUR_USERNAME/sphinx-typesense.git cd sphinx-typesenseRun the setup command:
make setup
This single command will:
- Install all development dependencies (docs, lint, test groups)
- Install pre-commit hooks for automatic code quality checks
Verify your setup:
make test-smoke
If all tests pass, you're ready to contribute!
The project uses Ruff for both formatting and linting. Before committing, format your code:
make fmtThis will:
- Format all Python code in
src/andtests/ - Auto-fix any fixable linting issues
To check formatting without making changes:
make fmt-checkRun the full linting suite (Ruff + mypy type checking):
make lintFor just type checking:
make typecheckRun the full test suite with coverage:
make testQuick smoke test (fast, excludes slow and integration tests):
make test-smokeRun tests without coverage (faster iteration):
make test-fastRun tests in parallel:
make test-parallelRun with verbose output:
make test-verboseBuild the documentation:
make docsLive preview with auto-rebuild (recommended for writing docs):
make docs-serveThis starts a local server that automatically rebuilds when you save changes and opens your browser.
Clean documentation build artifacts:
make docs-cleanIntegration tests require a running Typesense instance. The project includes a Docker Compose configuration to make this easy.
Run integration tests (automatically manages Typesense):
make test-integrationThis command will:
- Start a Typesense container
- Wait for it to be healthy
- Run the integration test suite
- Stop the container when done
Manual Typesense management:
# Start Typesense
make typesense-up
# Stop Typesense
make typesense-down
# Stop and remove all data
make typesense-cleanThe Typesense instance will be available at http://localhost:8108 with the
API key configured in tests/docker-compose.yml.
Fork the repository on GitHub
Create a feature branch from
main:git checkout -b feature/your-feature-name
Make your changes and ensure they follow the code style guidelines
Run the CI checks locally:
make ci
This runs the same checks as the CI pipeline:
- Format checking
- Linting (Ruff + mypy)
- Full test suite with coverage
Commit your changes with clear, descriptive commit messages:
feat: add support for custom document schemas - Add schema configuration option to extension config - Update indexer to use custom fields - Add tests for schema validation
Push your branch and open a pull request
Before submitting your PR, ensure:
- [ ]
make cipasses without errors - [ ] New features include appropriate tests
- [ ] Documentation is updated if needed
- [ ] Commit messages are clear and follow conventional format
We follow a conventional commit format:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changestest:- Test additions or modificationsrefactor:- Code refactoringchore:- Maintenance tasks
- Ruff handles both formatting and linting
- Line length is set to 120 characters
- Target Python version is 3.9 for compatibility
- Run
make fmtbefore committing to auto-format
The full Ruff configuration is in pyproject.toml under [tool.ruff].
Type hints are strongly encouraged and checked with mypy in strict mode:
def process_document(
content: str,
metadata: dict[str, Any] | None = None,
) -> ProcessedDocument:
"""Process a document for indexing.
Args:
content: The raw document content.
metadata: Optional metadata to include.
Returns:
A processed document ready for indexing.
"""
...All public APIs should have docstrings. We use Google style docstrings:
def create_collection(
name: str,
fields: list[FieldDefinition],
) -> Collection:
"""Create a new Typesense collection.
Creates a collection with the specified name and field definitions.
If a collection with the same name already exists, it will be updated.
Args:
name: The name of the collection to create.
fields: List of field definitions for the collection schema.
Returns:
The created or updated Collection object.
Raises:
TypesenseError: If the collection cannot be created.
Example:
>>> fields = [FieldDefinition(name="title", type="string")]
>>> collection = create_collection("docs", fields)
"""
...The project uses pre-commit hooks to maintain code quality. They're installed
automatically during make setup, but you can also manage them manually:
Install hooks:
make pre-commit-installRun hooks on all files:
make pre-commitThe hooks include:
- Trailing whitespace removal
- End-of-file fixing
- YAML/TOML validation
- Ruff linting and formatting
- Codespell for typo checking
- mypy type checking
- sphinx-lint for RST files
- GitHub Actions workflow validation
- Secret detection
Here's a quick reference of all available make targets:
Installation:
make install - Install production dependencies only
make dev - Install development dependencies
make dev-all - Install all dependency groups explicitly
make setup - Complete development setup (recommended)
Code Quality:
make fmt - Format code with Ruff
make fmt-check - Check formatting without changes
make lint - Run Ruff check and mypy
make lint-fix - Run Ruff with auto-fix
make typecheck - Run mypy only
Testing:
make test - Run tests with coverage
make test-smoke - Quick smoke test
make test-fast - Run tests without coverage
make test-verbose - Run tests with verbose output
make test-parallel - Run tests in parallel
make test-integration - Run integration tests (requires Docker)
Documentation:
make docs - Build documentation
make docs-serve - Live preview server
make docs-clean - Clean build artifacts
CI/CD:
make check - Run lint + test
make ci - Full CI pipeline (fmt-check, lint, test)
make pre-commit - Run pre-commit on all files
Cleanup:
make clean - Remove all build artifacts
make refresh - Clean and reinstall dependencies
Build:
make build - Build wheel and sdist
make build-check - Build and verify with twine
If you have questions or need help:
- Open an issue on GitHub
- Check existing issues and discussions for similar questions
Thank you for contributing!