diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000..9a8564b --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,73 @@ +--- +name: Publish API documentation to GitHub Pages + +on: + push: + branches: + - main + release: + types: [published] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +jobs: + deploy-docs: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.14" + + - name: Install dependencies + run: pip install . + + - name: Install pdoc + run: pip install pdoc + + - name: Get version + id: get_version + run: | + if [[ "${{ github.event_name }}" == "release" ]]; then + VERSION_RAW="${{ github.event.release.tag_name }}" + echo "VERSION=${VERSION_RAW#v}" >> $GITHUB_ENV + else + echo "VERSION=dev" >> $GITHUB_ENV + fi + + - name: Build docs + env: + VERSION: ${{ env.VERSION }} + run: | + pdoc src/spdx_python_model -o docs + # Copy files to versioned/dev directory + mkdir -p "pages/${{ env.VERSION }}" + cp -r docs/* "pages/${{ env.VERSION }}/" + # Create an index.html to redirect to the dev docs + if [[ "${{ env.VERSION }}" == "dev" ]]; then + echo '' > pages/index.html + fi + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v4 + with: + path: pages + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index 764716e..0a8805e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # spdx-python-model -Generated Python code for SPDX Spec version 3 +Generated Python code for [SPDX specification version 3][spdx-spec]. All bindings in this repository are generated using [shacl2code](https://github.com/JPEWdev/shacl2code) at the time the package is @@ -10,9 +10,11 @@ built. manipulating SPDX files. While they are fully functions, they lack higher level helper functions that may be useful for creating SPDX documents. If you want a higher level approach, please see the -[SPDX Python Tools](https://github.com/spdx/tools-python) (however this repo +[SPDX Python Tools](https://github.com/spdx/tools-python) (however, it doesn't yet support SPDX 3) +[spdx-spec]: https://spdx.org/specifications + ## Installation ### Install from PyPI @@ -31,7 +33,7 @@ python3 -m pip install git+https://github.com/spdx/spdx-python-model.git@main ``` Note that this will pull the latest version from the `main` branch. If you want -a specific commit, replace `main` with the git commit SHA +a specific commit, replace `main` with the git commit SHA. ### Install/build using local SPDX model files diff --git a/src/spdx_python_model/__init__.py b/src/spdx_python_model/__init__.py index f6df1d1..ad8a20e 100644 --- a/src/spdx_python_model/__init__.py +++ b/src/spdx_python_model/__init__.py @@ -1,7 +1,12 @@ # SPDX-FileType: SOURCE # SPDX-License-Identifier: Apache-2.0 # -"""SPDX 3 model.""" +""" +SPDX 3 model. + +.. include:: ../../README.md + :end-before: Testing +""" import importlib import json