Skip to content

Commit adc7e02

Browse files
committed
ci: fix docs generation flow
1 parent 8364caf commit adc7e02

File tree

3 files changed

+30
-35
lines changed

3 files changed

+30
-35
lines changed
Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: Build and Upload Python API Docs
22

33
on:
4-
pull_request:
4+
push:
5+
branches:
6+
- docs/api-docs
57
workflow_dispatch:
68

79
permissions: {}
@@ -10,13 +12,26 @@ jobs:
1012
build-docs:
1113
name: "Build and Upload API Documentation"
1214
runs-on: ubuntu-24.04
15+
container:
16+
image: quay.io/pypa/manylinux_2_28_x86_64
17+
env:
18+
PLAT: manylinux_2_28_x86_64
19+
PYBIN: "/opt/python/cp310-cp310/bin"
1320
steps:
1421
- name: "Checkout"
1522
uses: actions/checkout@v4
1623
with:
1724
submodules: recursive
1825
persist-credentials: false
1926
fetch-depth: 0
27+
28+
- name: "Install Rust 1.84.1"
29+
uses: actions-rs/toolchain@v1
30+
with:
31+
toolchain: 1.84.1
32+
33+
- name: "Configure Git safe directory"
34+
run: git config --global --add safe.directory /__w/bdk-python/bdk-python
2035

2136
- name: "Set up Python"
2237
uses: actions/setup-python@v4
@@ -25,17 +40,20 @@ jobs:
2540

2641
- name: "Install Sphinx and Theme"
2742
run: |
28-
python3 -m pip install --upgrade pip
29-
pip install sphinx sphinx_rtd_theme
43+
${PYBIN}/python -m pip install --upgrade pip
44+
${PYBIN}/pip install sphinx sphinx_rtd_theme
3045
31-
- name: "Build python API Documentation"
46+
- name: "Generate python API Documentation"
3247
run: |
3348
bash ./scripts/generate-linux.sh
34-
cd ./docs/
35-
python3 generate_docs.py
49+
${PYBIN}/python docs/generate_docs.py
50+
51+
- name: "Build HTML Documentation"
52+
run: |
53+
${PYBIN}/sphinx-build -b html -W --keep-going docs/source docs/_build/html
3654
3755
- name: "Upload API Docs"
3856
uses: actions/upload-artifact@v4
3957
with:
4058
name: artifact-python-api-docs
41-
path: /home/runner/work/bdk-python/bdk-python/docs/_build/html
59+
path: /home/runner/work/bdk-python/bdk-python/docs/_build/html

docs/generate_docs.py

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import subprocess
44
import shutil
55

6-
# ------------------------
7-
# Step 1: Generate API RST
8-
# ------------------------
6+
# ----------------
7+
# Generate API RST
8+
# ----------------
99

1010
# Define the directory where the Python source files are located
1111
src_dir = 'src/bdkpython'
@@ -48,27 +48,4 @@
4848
with open(output_file, 'w') as f:
4949
f.write(rst_content)
5050

51-
print(f"API documentation has been generated in {output_file}")
52-
53-
# -----------------------
54-
# Step 2: Build HTML docs
55-
# -----------------------
56-
57-
BUILD_DIR = 'docs/_build/html'
58-
SOURCE_DIR = 'docs/source'
59-
60-
# Clean previous HTML build
61-
if os.path.exists(BUILD_DIR):
62-
shutil.rmtree(BUILD_DIR)
63-
64-
# Run Sphinx build
65-
subprocess.run([
66-
"sphinx-build",
67-
"-b", "html",
68-
"-W", # treat warnings as errors
69-
"--keep-going", # continue despite warnings
70-
SOURCE_DIR,
71-
BUILD_DIR
72-
], check=True)
73-
74-
print(f"HTML documentation has been built in {BUILD_DIR}")
51+
print(f"API documentation has been generated in {output_file}")

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import os
77
import sys
8-
sys.path.insert(0, os.path.abspath('../../src/bdkpython'))
8+
sys.path.insert(0, os.path.abspath('../../src'))
99

1010

1111
# -- Project information -----------------------------------------------------

0 commit comments

Comments
 (0)