diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b27df12..97cc657 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,9 +2,8 @@ name: website # build the documentation whenever there are new commits on main on: - push: - branches: - - main + release: + types: [published] # Alternative: only build for tags. # tags: # - '*' @@ -30,6 +29,34 @@ jobs: cache-dependency-glob: "uv.lock" - name: Install the project run: uv sync --all-extras --dev + - name: Extract version from tag + run: | + VERSION=${GITHUB_REF#refs/tags/} + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "Building docs for version: $VERSION" + - name: Create version wrapper + run: | + mv docs generated-docs + mkdir -p docs + cat > docs/index.html << 'EOF' + + + + + Documentation + + + +
+ Documentation for version $VERSION +
+

Documentation for version $VERSION

+

Redirecting to documentation...

+ + + EOF + mv generated-docs docs/ + - run: uv run pdoc -o docs/ redlines - uses: actions/upload-pages-artifact@v3 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c798ce6..14ea30c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -152,6 +152,37 @@ and respectful in your tone. To preview documentation, you can clone the project, install development dependencies, and then run `pdoc redlines` to see your changes. +## Documentation + +Our documentation is automatically generated from source code using `pdoc`. + +### How It Works +- Documentation builds automatically **when a new release is published**. +- The release tag (for example `v1.2.3`) is extracted by the CI workflow and exposed to the build as the `VERSION` environment variable. +- The version number is displayed in the published documentation. + +### To Update Documentation +1. Make code changes and update docstrings as needed. +2. Create and publish a new release on GitHub (use tags like `vMAJOR.MINOR.PATCH`). +3. The documentation workflow will run automatically and rebuild the docs for that release. +4. Check the deployed docs to verify the version banner and content. + +### Manual Documentation Build (for testing) +To build docs locally before releasing: + +```bash +# install pdoc locally +pip install pdoc + +# generate HTML into docs/ +pdoc --html --output-dir docs/ your_package_name + +# preview locally +cd docs +python -m http.server 8000 +# then open http://localhost:8000 in your browser +``` + ## Styleguides For code, we use the [Black formatter](https://black.readthedocs.io/en/stable/index.html). Please be encouraged to use