Skip to content

Commit

Permalink
Merge pull request #10434 from dbaston/rtd
Browse files Browse the repository at this point in the history
Doc: Build documentation using ReadTheDocs
  • Loading branch information
dbaston committed Aug 27, 2024
2 parents f51490a + 0550a38 commit ea023c3
Show file tree
Hide file tree
Showing 17 changed files with 298 additions and 353 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ permissions:

jobs:
docs:
name: Docs
name: Documentation checks

runs-on: ubuntu-latest
strategy:
Expand All @@ -40,6 +40,7 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_APPS=OFF \
-DBUILD_TESTING=OFF \
-DGDAL_BUILD_OPTIONAL_DRIVERS=OFF \
-DOGR_BUILD_OPTIONAL_DRIVERS=OFF
cmake --build . -j$(nproc)
Expand Down Expand Up @@ -75,69 +76,14 @@ jobs:
run: |
mkdir -p doc/build
doxygen Doxyfile
- name: HTML
- name: Generated RST files
shell: bash -l {0}
run: |
make html O="-D enable_redirects=1"
working-directory: ./doc
- name: PDF
shell: bash -l {0}
run: |
make latexpdf
make generated_rst_files
working-directory: ./doc
- name: Spelling
shell: bash -l {0}
run: |
sed -i '/html_extra_path/d' source/conf.py # avoid WARNING: html_extra_path entry '../build/html_extra' is placed inside outdir
make spelling
working-directory: ./doc
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: PDF
path: doc/build/latex/gdal.pdf
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: HTML
path: doc/build/html/*
#- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
# with:
# name: Misspelled
# path: doc/build/spelling/output.txt
- name: Deploy ssh key
if: ${{ github.ref_name == 'master' && github.repository == 'OSGeo/gdal' }}
shell: bash -l {0}
run: |
apt install -y ssh
mkdir -p /root/.ssh && echo "${{ secrets.SSH_KEY_DOCS }}" > /root/.ssh/id_rsa
chmod 700 /root/.ssh && chmod 600 /root/.ssh/id_rsa
ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts
eval `ssh-agent -s`
ssh-add /root/.ssh/id_rsa
- name: Deploy to gdal.org
if: ${{ github.ref_name == 'master' && github.repository == 'OSGeo/gdal' }}
shell: bash -l {0}
run: |
set -x
set -e
cd /__w/gdal
mv gdal/doc/build/html gdal-docs
rm gdal-docs/gdal.pdf
cp gdal/doc/build/latex/gdal.pdf gdal-docs
cp gdal/data/gdalicon.png gdal-docs # For GDAL autotest...
cp -r gdal/resources gdal-docs # Do not change this without changing swig/python/gdal-utils/osgeo_utils/gdal2tiles.py
#
git clone https://github.com/OSGeo/libgeotiff
cp -r libgeotiff/geotiff/html/proj_list gdal-docs/
#
cd gdal-docs
wget http://download.osgeo.org/gdal/for_doc/javadoc.zip -O /tmp/javadoc.zip
unzip -q /tmp/javadoc.zip
git init
git config user.email "proj4bot@proj4.bot"
git config user.name "GDAL Bot"
git remote add origin git@github.com:OSGeo/gdal-docs.git
git remote -v
echo "gdal.org" > CNAME
touch .nojekyll
git add -A
git commit -m "Update with OSGeo/gdal commit $GITHUB_SHA"
git push -f origin master
42 changes: 42 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

build:
os: "ubuntu-24.04"
tools:
python: "3.12"

jobs:
post_checkout:
- (git --no-pager log --pretty="tformat:%s -- %b" -1 | grep -viqP "skip ci|ci skip") || exit 183
pre_build:
- ./doc/rtd/pre_build.sh
- cd doc && make doxygen generated_rst_files

apt_packages:
- ant
- cmake
- doxygen
- g++
- libproj-dev
- make
- openjdk-11-jdk-headless
- patchelf
- swig
- unzip

formats:
- htmlzip
- pdf

python:
install:
- requirements: doc/requirements.txt

sphinx:
configuration: doc/source/conf.py
fail_on_warning: true
20 changes: 4 additions & 16 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ $(BUILDDIR)/.doxygen_up_to_date:
rm -rf $(BUILDDIR)/xml; \
mkdir -p $(BUILDDIR)/xml; \
(cd .. && ((cat Doxyfile | sed "s/PREDEFINED = /PREDEFINED = DOXYGEN_XML /"; printf "GENERATE_HTML=NO\nGENERATE_XML=YES\nXML_OUTPUT=$$BUILDDIR_ABS/xml\nXML_PROGRAMLISTING=NO") | doxygen -)); \
rm -rf $(BUILDDIR)/doxygen_html; \
mkdir -p $(BUILDDIR)/doxygen_html; \
(cd .. && ((cat Doxyfile; printf "HTML_OUTPUT=$$BUILDDIR_ABS/doxygen_html\nINLINE_INHERITED_MEMB=YES") | doxygen -)); \
rm -rf $(BUILDDIR)/html_extra/doxygen; \
mkdir -p $(BUILDDIR)/html_extra/doxygen; \
(cd .. && ((cat Doxyfile; printf "HTML_OUTPUT=$$BUILDDIR_ABS/html_extra/doxygen\nINLINE_INHERITED_MEMB=YES") | doxygen -)); \
echo "Doxygen replaces -- with <ndash/>. This is not desirable, so revert that;"; \
for i in $(BUILDDIR)/xml/*.xml; do sed "s/<ndash\/>/--/g" < $$i > $$i.tmp; mv $$i.tmp $$i; done; \
touch $(BUILDDIR)/.doxygen_up_to_date
Expand All @@ -74,19 +74,7 @@ generated_rst_files: $(BUILDDIR)/.doxygen_up_to_date
.PHONY: html latexpdf
html: generated_rst_files
BUILDDIR="${BUILDDIR}" $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# Hack to hide the TOC
sed 's/<div class="toctree-wrapper compound">/<div class="toctree-wrapper compound" style="display: none;">/' < "$(BUILDDIR)/html/drivers/raster/index.html" > "$(BUILDDIR)/html/drivers/raster/index.html.mod"
mv "$(BUILDDIR)/html/drivers/raster/index.html.mod" "$(BUILDDIR)/html/drivers/raster/index.html"
sed 's/<div class="toctree-wrapper compound">/<div class="toctree-wrapper compound" style="display: none;">/' < "$(BUILDDIR)/html/drivers/vector/index.html" > "$(BUILDDIR)/html/drivers/vector/index.html.mod"
mv "$(BUILDDIR)/html/drivers/vector/index.html.mod" "$(BUILDDIR)/html/drivers/vector/index.html"
sed "s/python_api_ref\.html/\.\.\/python\/index\.html/" < "$(BUILDDIR)/html/api/index.html" > "$(BUILDDIR)/html/api/index.html.mod"
mv "$(BUILDDIR)/html/api/index.html.mod" "$(BUILDDIR)/html/api/index.html"
sed 's/<div class="toctree-wrapper compound">/<div class="toctree-wrapper compound" style="display: none;">/' < "$(BUILDDIR)/html/sponsors/index.html" > "$(BUILDDIR)/html/sponsors/index.html.mod"
mv "$(BUILDDIR)/html/sponsors/index.html.mod" "$(BUILDDIR)/html/sponsors/index.html"
rm -rf $(BUILDDIR)/html/doxygen
cp -r $(BUILDDIR)/doxygen_html $(BUILDDIR)/html/doxygen
ln -sf ../latex/gdal.pdf $(BUILDDIR)/html
cp -f "source/sponsors/Sustainable GDAL Sponsorship Prospectus.pdf" $(BUILDDIR)/html/sponsors

man: generated_rst_files
BUILDDIR="${BUILDDIR}" $(SPHINXBUILD) -M man "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Expand All @@ -99,6 +87,6 @@ spelling: generated_rst_files

clean:
rm -rf "$(BUILDDIR)/xml"
rm -rf "$(BUILDDIR)/doxygen_html"
rm -rf "$(BUILDDIR)/html_extra/doxygen"
rm -f "$(BUILDDIR)/.doxygen_up_to_date"
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
3 changes: 3 additions & 0 deletions doc/build/html_extra/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
User-agent: *
Allow: /en/latest/
Disallow: /en/
61 changes: 11 additions & 50 deletions doc/environment.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,16 @@
name: gdal-docs
channels:
- conda-forge
- defaults
dependencies:
- bzip2=1.0.6=h1de35cc_1002
- ca-certificates=2019.3.9=hecc5488_0
- certifi=2019.3.9=py37_0
- libcxx=8.0.0=2
- libcxxabi=8.0.0=2
- libffi=3.2.1=h6de7cb9_1006
- ncurses=6.1=h0a44026_1002
- openssl=1.1.1b=h01d97ff_2
- pip=19.1=py37_0
- python=3.7.3=h0d93f26_0
- readline=7.0=hcfe32e1_1001
- setuptools=41.0.1=py37_0
- sqlite=3.26.0=h1765d9f_1001
- tk=8.6.9=ha441bb4_1001
- wheel=0.33.4=py37_0
- xz=5.2.4=h1de35cc_1001
- zlib=1.2.11=h1de35cc_1004
- pip
- pip:
- alabaster==0.7.12
- babel==2.6.0
- beautifulsoup4==4.7.1
- breathe==4.13.0.post0
- bs4==0.0.1
- chardet==3.0.4
- docutils==0.14
- exhale==0.2.2
- idna==2.8
- imagesize==1.1.0
- jinja2==2.10.1
- lxml==4.3.3
- markupsafe==1.1.1
- packaging==19.0
- pygments==2.4.0
- pyparsing==2.4.0
- pytz==2019.1
- requests==2.21.0
- six==1.12.0
- snowballstemmer==1.2.1
- soupsieve==1.9.1
- sphinx==2.0.1
- sphinx-rtd-theme==0.4.3
- sphinxcontrib-applehelp==1.0.1
- sphinxcontrib-devhelp==1.0.1
- sphinxcontrib-htmlhelp==1.0.2
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==1.0.2
- sphinxcontrib-serializinghtml==1.1.3
- urllib3==1.24.3
prefix: /Users/hobu/miniconda3/envs/gdal-docs

- breathe
- numpy
- recommonmark
- sphinx
- sphinx-bootstrap-theme
- sphinx-markdown-tables
- sphinx-rtd-theme
- sphinxcontrib-bibtex
- sphinxcontrib-jquery
- sphinxcontrib-spelling
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file may be used to create an environment using:
# $ pip install --upgrade -r <this file>
numpy
sphinx
breathe
sphinx_bootstrap_theme
Expand Down
47 changes: 47 additions & 0 deletions doc/rtd/pre_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -ex

mkdir -p build-rtd
cd build-rtd

PREFIX=${READTHEDOCS_VIRTUALENV_PATH}

cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_INSTALL_RPATH=${PREFIX}/lib \
-DGDAL_PYTHON_INSTALL_PREFIX=${PREFIX} \
-DGDAL_BUILD_OPTIONAL_DRIVERS=OFF \
-DOGR_BUILD_OPTIONAL_DRIVERS=OFF \
-DBUILD_APPS=OFF \
-DBUILD_PYTHON_BINDINGS=ON \
-DBUILD_JAVA_BINDINGS=ON \
-DBUILD_TESTING=OFF \
-DGDAL_JAVA_GENERATE_JAVADOC=ON \
-DBASH_COMPLETIONS_DIR="" \
..

cmake --build . -j$(nproc)
cmake --install .

# set rpath for python libraries
find ${READTHEDOCS_VIRTUALENV_PATH} -wholename "*/osgeo/*.so" -exec patchelf --set-rpath ${READTHEDOCS_VIRTUALENV_PATH}/lib {} \;

# check python import (needed for doc build)
python3 -c "from osgeo import gdal; print(gdal.__version__)"

# unpack javadoc created during cmake --build into correct location
mkdir -p ../doc/build/html_extra
unzip -d ../doc/build/html_extra swig/java/javadoc.zip

# copy gdalicon.png into html_extra (used by test suite)
cp ../data/gdalicon.png ../doc/build/html_extra/

# copy proj_list documentation
# see https://github.com/OSGeo/gdal/issues/8221
git clone https://github.com/OSGeo/libgeotiff
cp -r libgeotiff/geotiff/html/proj_list ../doc/build/html_extra

# copy resources directory for gdal2tiles usage
# see https://github.com/OSGeo/gdal/pull/6276
cp -r ../resources ../doc/build/html_extra/resources # Do not change this without changing swig/python/gdal-utils/osgeo_utils/gdal2tiles.py
Loading

0 comments on commit ea023c3

Please sign in to comment.