First off, thank you for considering contributing to Attachments! It's people like you that make Attachments such a great tool.
This document provides guidelines for contributing to the project. Please feel free to propose changes to this document in a pull request.
- Reporting bugs
- Suggesting enhancements
- Writing documentation
- Submitting pull requests for code changes
- Ensure you have a GitHub account.
- Fork the repository on GitHub.
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/attachments.git - Create a new branch for your changes:
git checkout -b your-branch-name
This project uses Python and uv for managing dependencies within a virtual environment.
-
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows, use: .venv\Scripts\activate
-
Install dependencies:
uv pip install -e '.[dev]'
The project documentation is built using MyST Markdown and the mystmd command-line tool.
The necessary tools for documentation (including mystmd) are installed as part of the development dependencies (see "Development Environment Setup" above).
- Ensure your virtual environment is activated and dependencies are installed.
- Build the documentation:
From the project root directory, run:
This command builds the documentation and usually starts a local web server (e.g., at
myst build --html
http://localhost:3000or a similar port). The build output is generated in the_build/html/directory at the project root.
- Page Content: Documentation source files are primarily located in the
docs/directory (e.g.,docs/index.md,docs/api_reference.md). These are written in MyST Markdown. - Site Structure & Configuration: The main configuration for the documentation site, including the overall Table of Contents (TOC) and navigation, is in the
myst.ymlfile at the project root.- To update the main Table of Contents based on the files in
docs/andREADME.md, you can run:This will update themyst init --write-toc
toc:section inmyst.yml.
- To update the main Table of Contents based on the files in
myst.yml: (Project Root) Defines the project structure, site metadata, navigation, and the global Table of Contents.docs/index.md: The main landing page for the documentation section of the site.docs/api_reference.md: Placeholder for detailed API documentation.README.md: (Project Root) Also included in the documentation site.
Documentation is automatically built and deployed to GitHub Pages whenever changes are pushed to the main branch. This is handled by the GitHub Actions workflow defined in .github/workflows/deploy-docs.yml.
Tutorials are a great way to help users learn how to use the attachments library. We use a workflow that starts with a Python script and converts it to a Jupyter Notebook for the documentation.
-
Write the Tutorial as a Python Script:
- Create a new Python (
.py) file in thedocs/example_scripts/directory. - Structure your script using cell markers for compatibility with
jupytextand direct execution:- Use
# %%for code cells. - Use
# %% [md]for Markdown cells.
- Use
- Ensure the script is self-contained and clearly explains the concepts.
- Create a new Python (
-
Install
jupytext: If you haven't already, installjupytextin your development environment:uv pip install jupytext
-
Convert the Script to a Jupyter Notebook: Use the
jupytextcommand-line tool to convert your Python script to a.ipynbfile. Place the output notebook in thedocs/examples/directory.jupytext --to notebook --output docs/examples/your_tutorial_name.ipynb docs/example_scripts/your_tutorial_name.py
Replace
your_tutorial_name.pyandyour_tutorial_name.ipynbwith the actual names of your files. -
Add the Notebook to Documentation: Edit the
myst.ymlfile at the project root. Add a reference to your new notebook file (docs/examples/your_tutorial_name.ipynb) under the appropriate section in thetoc(Table of Contents), usually within the "Examples" section. -
Build and Verify: Build the documentation locally to ensure your new tutorial renders correctly:
myst build --html
- Commit your changes:
git commit -m "Your descriptive commit message" - Push to your fork:
git push origin your-branch-name - Open a pull request on the original repository.
- Please ensure your code lints and tests pass before submitting a pull request.
- (Add any specific coding style guidelines here, e.g., Black, Flake8)
Run tests using:
uv run pytestWe use pre-commit to enforce formatting, linting, and run a fast test pass before commits.
What runs:
- Black: formats Python code.
- Ruff: lints and auto-fixes common issues (exits non‑zero when it fixes files).
- Pytest: runs a quick test run (
--maxfail=1 -q).
Set up locally:
uv tool install pre-commit # or: pip install pre-commit
pre-commit install # install git hook in .git/hooks
# Optional: run on the whole repo
pre-commit run --all-filesTips:
- If Ruff reports “Found N errors (N fixed, 0 remaining)”, re-run pre-commit so the next hook sees the updated files.
- Our configuration lives in
.pre-commit-config.yaml. Black excludesdocs/scripts/how_splitting_works.pybecause it contains fenced blocks that are intentionally kept for docs generation. - Ruff rules and per‑file‑ignores are configured in
pyproject.tomlunder[tool.ruff].
CI runs the same hooks, so keeping your local hooks up to date helps ensure green PRs.
This project uses GitHub Actions to automate building and publishing the package to PyPI when a new version tag is pushed.
- Update Version: Update the
versioninpyproject.toml(e.g.,version = "0.2.5"). - Commit Changes: Commit the version update:
git commit -am "Bump version to 0.2.5" - Create Git Tag: Tag the commit with the same version, prefixed by
v:git tag v0.2.5 - Push Tag: Push the tag to GitHub:
git push origin v0.2.5
This will trigger the workflow defined in .github/workflows/publish-to-pypi.yml.
Note on PyPI Token: The publishing workflow requires a PyPI API token stored as a GitHub secret named PYPI_API_TOKEN. Ensure this is configured in the repository settings under "Secrets and variables" > "Actions".
Thank you for your contribution!