Skip to content

Commit 90abbb8

Browse files
mfisher87brichet
andauthored
Build docs and Lite deployment in ReadTheDocs (#275)
* [WIP] Attempt RTD build * Try building for RTD in an isolated environment * Restore docs/environment.yml, move docs dependencies to new file * Upgrade the versions of conda and mamba in RTD build * Use Micromamba instead of one of the out-of-the-box tool options Creating multiple environments with mamba exposed lots of problems: * RTD's default machinery expects a single environment YAML file when using conda/mamba. Injecting a 2nd environment into the normal build process gets confusing. * Other hidden assumptions in the default RTD build machinery; I don't remember all the problems I ran in to, but getting a working build required an unsustainable amount of trial-and-error. * Default-installed mamba is too old to support 'emscripten' platform, needs to be upgraded. When upgrading mamba, ran in to a weird issue where the build.html step could not find the python interpreter. It's possible to fully override build steps, but this is an _undocumented feature_. See: readthedocs/readthedocs.org#11551 Instead of overriding build steps, perhaps it will be best long-term to override the entire build with `build.commands`. See: https://blog.readthedocs.com/build-customization/ * Add JupyterLite badge and link to docs * Automate exposing RTD preview link in PR description Makes viewing PR previews more accessible! * Make the RTD PR preview link richer * Ignore the JupyterLite link in the link check automation * Switch bash commands in YAML from folded to literal blocks This feels significantly more intuitive to me. * Format YAML --------- Co-authored-by: Nicolas Brichet <[email protected]>
1 parent 4098bfd commit 90abbb8

File tree

6 files changed

+101
-29
lines changed

6 files changed

+101
-29
lines changed

.github/workflows/build.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ jobs:
242242
- uses: actions/checkout@v4
243243
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
244244
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
245+
with:
246+
ignore_links: 'lite/'
245247

246248
build-docs-and-lite:
247249
name: Build docs with JupyterLite deployment
@@ -294,11 +296,6 @@ jobs:
294296
path: ./docs/dist
295297
retention-days: 30
296298

297-
- name: Save artifact data
298-
uses: trungleduc/appsharingspace-pr-comment/.github/actions/save-artifact-link@v2
299-
with:
300-
artifact_link: 'https://github.com/${{ github.repository }}/actions/runs/${{github.run_id}}/artifacts/${{ steps.upload-docs-artifact.outputs.artifact_id }}'
301-
302299
deploy:
303300
needs: build-docs-and-lite
304301
if: github.ref == 'refs/heads/main'

.github/workflows/comment-on-pr.yml

-24
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,6 @@ permissions:
1010
pull-requests: write
1111

1212
jobs:
13-
comment-preview:
14-
runs-on: ubuntu-latest
15-
if: >
16-
${{ github.event.workflow_run.event == 'pull_request' &&
17-
github.event.workflow_run.conclusion == 'success' }}
18-
steps:
19-
- name: 'Comment APSS link on workflow'
20-
uses: trungleduc/appsharingspace-pr-comment/.github/actions/pr-comment@v2
21-
with:
22-
comment_prefix: '**Preview using JupyterLite:**'
23-
github_token: ${{ secrets.github_token }}
24-
index_path: lite/lab/index.html
25-
comment-docs-preview:
26-
runs-on: ubuntu-latest
27-
if: >
28-
${{ github.event.workflow_run.event == 'pull_request' &&
29-
github.event.workflow_run.conclusion == 'success' }}
30-
steps:
31-
- name: 'Comment APSS link on workflow'
32-
uses: trungleduc/appsharingspace-pr-comment/.github/actions/pr-comment@v2
33-
with:
34-
comment_prefix: '**Docs preview:**'
35-
github_token: ${{ secrets.github_token }}
36-
index_path: index.html
3713
comment-galata:
3814
runs-on: ubuntu-latest
3915
if: >

.github/workflows/pr-rtd-link.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# The ReadTheDocs preview link is "hidden" within the GitHub "Checks"
2+
# interface. For users who don't know this, finding the preview link may be
3+
# very difficult or frustrating. This workflow makes the link more
4+
# findable by updating PR descriptions to include it.
5+
name: 'Add ReadTheDocs preview link to PR description'
6+
7+
on:
8+
pull_request_target:
9+
types:
10+
- 'opened'
11+
12+
permissions:
13+
pull-requests: 'write'
14+
15+
jobs:
16+
autolink-rtd-previews:
17+
runs-on: 'ubuntu-latest'
18+
steps:
19+
- uses: 'readthedocs/actions/preview@v1'
20+
with:
21+
project-slug: 'jupytergis'
22+
message-template: |
23+
📚 Documentation preview: {docs-pr-index-url}
24+
💡 JupyterLite preview: {docs-pre-index-url}/lite

.readthedocs.yaml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html
2+
version: 2
3+
4+
build:
5+
os: "ubuntu-24.04"
6+
tools:
7+
nodejs: "20"
8+
jobs:
9+
# Install micromamba
10+
pre_create_environment:
11+
# The recommended syntax in the micromamba docs is process substitution.
12+
# RTD's default shell chokes on it, so we're doing it in multiple steps
13+
# instead.
14+
- curl -L micro.mamba.pm/install.sh > /tmp/micromamba-install.sh
15+
- chmod +x /tmp/micromamba-install.sh
16+
# For some reason, SHELL is not set. The install script requires it.
17+
- SHELL=/bin/bash /bin/bash /tmp/micromamba-install.sh
18+
19+
# Override the create_environment step (undocumented feature) to create
20+
# multiple environments.
21+
create_environment:
22+
# Create the env for building the docs
23+
- /bin/bash --login -c "micromamba env create -n jupytergis-docs -f docs/environment-docs.yml"
24+
# Create the isolated env for building JupyterGIS
25+
- /bin/bash --login -c "micromamba create -n jupytergis-build -c conda-forge yarn=3 hatch pip python=3.10"
26+
- /bin/bash --login -c "micromamba run -n jupytergis-build pip install -r requirements-build.txt"
27+
28+
# Override the install step to do nothing - we already created the envs
29+
install:
30+
- "echo 'Skipping! We already have the environments we need.'"
31+
32+
# Before building the docs, build JupyterGIS in its isolated environment,
33+
# then install the wheels into the docs environment.
34+
pre_build:
35+
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn install"
36+
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn dev"
37+
- /bin/bash --login -c "micromamba run -n jupytergis-build jupyter labextension list 2>&1 | grep -ie 'jupytergis-core.*OK'"
38+
- /bin/bash --login -c "micromamba run -n jupytergis-build jupyter labextension list 2>&1 | grep -ie 'jupytergis-lab.*OK'"
39+
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn build:packages"
40+
41+
- |-
42+
/bin/bash --login -c "micromamba run -n jupytergis-docs \
43+
python -m pip install \
44+
$(ls ./python/jupytergis_core/dist/jupytergis*.whl) \
45+
$(ls ./python/jupytergis_lab/dist/jupytergis*.whl) \
46+
$(ls ./python/jupytergis_qgis/dist/jupytergis*.whl)"
47+
48+
build:
49+
html:
50+
- |-
51+
/bin/bash --login -c "cd docs && micromamba run -n jupytergis-docs \
52+
python -m sphinx -T -b html -d _build/doctrees -D language=en . \
53+
$READTHEDOCS_OUTPUT/html"

docs/environment-docs.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: jupytergis-docs
2+
channels:
3+
- conda-forge
4+
- nodefaults
5+
dependencies:
6+
- python=3.10
7+
- pip # Needed to install jupytergis wheels in RTD build
8+
9+
# Build docs & JupyterLite
10+
- jupyterlite-core>=0.2.0,<0.3.0
11+
- jupyterlite-xeus>=0.1.2,<0.2
12+
- jupyterlite-sphinx
13+
- sphinx
14+
- sphinx-tabs
15+
- pydata-sphinx-theme
16+
- sphinx-autodoc-typehints
17+
18+
- xeus-python # TODO: Do we need this?

docs/index.rst

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
JupyterGIS
33
==========
44

5+
.. image:: https://jupyterlite.rtfd.io/en/latest/_static/badge.svg
6+
:alt: Try JupyterGIS now in JupyterLite!
7+
:target: lite/
8+
59
JupyterGIS is a JupyterLab extension for collaborative GIS (Geographical Information System). It is designed to
610
allow multiple people to work on the same geospatial project simultaneously, facilitating discussion and collaboration
711
around map layers, spatial analyses, and other GIS data being developed.

0 commit comments

Comments
 (0)