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 6c78b1c..068a89e 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 @@ -13,7 +13,9 @@ higher level approach, please see the [SPDX Python Tools](https://github.com/spdx/tools-python) (however this repo doesn't yet support SPDX 3) -## Installation (PyPi) +[spdx-spec]: https://spdx.org/specifications + +## Installation (PyPI) ```shell python3 -m pip install spdx-python-model @@ -22,7 +24,7 @@ python3 -m pip install spdx-python-model ## Installation (Git) If you would like to pull the bindings directly from Git instead of using a -released version from PyPi, the following command can be used: +released version from PyPI, the following command can be used: ```shell python3 -m pip install git+https://github.com/spdx/spdx-python-model.git@main @@ -78,4 +80,4 @@ make a new release in GitHub with the name `v` + *VERSION*, where *VERSION* matches the version number specified in `version.py` (e.g. `v1.0.0`). After this, GitHub actions will do the rest to build the package and publish it -to PyPi +to PyPI. diff --git a/src/spdx_python_model/__init__.py b/src/spdx_python_model/__init__.py index c3918ed..f6e8bbb 100644 --- a/src/spdx_python_model/__init__.py +++ b/src/spdx_python_model/__init__.py @@ -1,6 +1,10 @@ # # SPDX-License-Identifier: Apache-2.0 # +""" +.. include:: ../../README.md + :end-before: Testing +""" from .bindings import * from .version import VERSION