Skip to content

Commit 7ec501d

Browse files
authored
Merge pull request #31 from negz/i-love-you-godoc
Generate and publish API docs to GitHub pages
2 parents 4569ef1 + 2c6a276 commit 7ec501d

File tree

3 files changed

+59
-6
lines changed

3 files changed

+59
-6
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ on:
1212
description: PyPI project version (e.g. v0.1.0)
1313
required: false
1414

15+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages.
16+
permissions:
17+
contents: read
18+
pages: write
19+
id-token: write
20+
21+
# Allow only one concurrent deployment, skipping runs queued between the run
22+
# in-progress and latest queued. However, do NOT cancel in-progress runs as we
23+
# want to allow these production deployments to complete.
24+
concurrency:
25+
group: "pages"
26+
cancel-in-progress: false
27+
1528
env:
1629
# Common versions
1730
PYTHON_VERSION: '3.11.5'
@@ -113,3 +126,36 @@ jobs:
113126
# be enabled, which makes sharing the account hard. We're waiting for
114127
# a crossplane org to be approved.
115128
password: ${{ secrets.PYPI_API_TOKEN }}
129+
130+
131+
docs:
132+
# The simple docs tool we're using doesn't support versions, so our docs
133+
# will only reflect what's in main.
134+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
135+
runs-on: ubuntu-22.04
136+
steps:
137+
- name: Checkout
138+
uses: actions/checkout@v4
139+
140+
- name: Setup Python
141+
uses: actions/setup-python@v5
142+
with:
143+
python-version: ${{ env.PYTHON_VERSION }}
144+
145+
- name: Setup Hatch
146+
run: pipx install hatch==1.7.0
147+
148+
- name: Build Documentation
149+
run: hatch run docs:pdoc -d google crossplane/function -o docs
150+
151+
- name: Setup Pages
152+
uses: actions/configure-pages@v4
153+
154+
- name: Upload artifact
155+
uses: actions/upload-pages-artifact@v3
156+
with:
157+
path: docs
158+
159+
- name: Deploy to GitHub Pages
160+
id: deployment
161+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,6 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161+
162+
# We don't commit our docs - instead we generate them and upload to GitHub pages.
163+
docs

pyproject.toml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ classifiers = [
1616
"Programming Language :: Python :: 3.11",
1717
]
1818

19-
dependencies = [
20-
"grpcio==1.*",
21-
"grpcio-reflection==1.*",
22-
"structlog==23.*",
23-
]
19+
dependencies = ["grpcio==1.*", "grpcio-reflection==1.*", "structlog==23.*"]
2420

2521
dynamic = ["version"]
2622

@@ -31,7 +27,7 @@ Source = "https://github.com/crossplane/function-sdk-python"
3127

3228
[tool.hatch.version]
3329
path = "crossplane/function/__version__.py"
34-
validate-bump = false # Allow going from 0.0.0.dev0+x to 0.0.0.dev0+y.
30+
validate-bump = false # Allow going from 0.0.0.dev0+x to 0.0.0.dev0+y.
3531

3632
[tool.hatch.envs.default]
3733
type = "virtual"
@@ -63,6 +59,14 @@ path = ".venv-test"
6359
[tool.hatch.envs.test.scripts]
6460
unit = "python -m unittest tests/*.py"
6561

62+
[tool.hatch.envs.docs]
63+
type = "virtual"
64+
path = ".venv-docs"
65+
dependencies = ["pdoc"]
66+
67+
[tool.hatch.envs.docs.scripts]
68+
generate = "pdoc -m google crossplane/function -o docs"
69+
6670
[tool.hatch.build.targets.wheel]
6771
packages = ["crossplane"]
6872

0 commit comments

Comments
 (0)