Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the infrastructure for auto-generating API documentation via sphinx and doxygen #383

Merged
merged 25 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dc2877d
[doxygen] Update doxygen config file
tmadlener Dec 23, 2022
2adad88
[doxygen] Make generated pages readable again
tmadlener Feb 28, 2023
48effcc
[wip] Add basic sphinx setup
tmadlener Feb 28, 2023
2b597a3
[wip] Make sphinx pick up doxygen output for c++ API
tmadlener Feb 28, 2023
b588878
[doc] Configure conf.py via cmake
tmadlener Feb 28, 2023
cdebf33
[doc] Make sphinx generate API docs for python bindings
tmadlener Feb 28, 2023
58fe447
[doc] Remove no longer necessary html and style files
tmadlener Feb 28, 2023
10ca278
Avoid installing the build subfolder
tmadlener Feb 28, 2023
aa83600
[wip] First attempt at getting readthedocs setup
tmadlener Dec 14, 2023
cf621fd
[wip] Add requirements for readthedocs
tmadlener Dec 14, 2023
4f0fa33
[wip] First attempt at running doxygen
tmadlener Dec 14, 2023
c610c9f
[wip] More doxygen tuning and addition of python auto generation
tmadlener Dec 15, 2023
e5b9860
Integrate generation back into cmake
tmadlener Dec 15, 2023
ccc49c6
Make pre-commit happy
tmadlener Dec 18, 2023
a7d0d3d
Properly ignore tests and podio_version
tmadlener Dec 20, 2023
66d0075
Fix minor warning from autodoc
tmadlener Dec 20, 2023
d8b2997
Import from the correct place
tmadlener Dec 20, 2023
1c62191
Add a workflow for building the docs
tmadlener Dec 20, 2023
7ab0e61
Make the documentation target depend on the necessary libs
tmadlener Jan 16, 2024
db47328
Remove readthedocs config and use pip-compile to nail down deps
tmadlener Dec 20, 2023
c720965
Remove doc/conf.py from gitignore since it is no longer configured
tmadlener Jan 18, 2024
9e4e6e1
Remove debugging branch trigger
tmadlener Jan 19, 2024
3e8c9c1
Cleanup sphinx config
tmadlener Jan 19, 2024
cbab859
Make filename and workflow name agree
tmadlener Jan 19, 2024
a84c005
Fix newline
tmadlener Jan 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: publish-doc

on:
push:
branches:
- 'master'
tags:
- v*-*
workflow_dispatch:

concurrency:
group: pages
cancel-in-progress: true

jobs:
build-doc:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: cvmfs-contrib/github-action-cvmfs@v3
- uses: aidasoft/run-lcg-view@v4
with:
container: el9
view-path: /cvmfs/sw-nightlies.hsf.org/key4hep
run: |
echo "::group::Install dependencies"
python3 -m pip install -r doc/requirements.txt
export PATH=/root/.local/bin:$PATH
export PYTHONPATH=/root/.local/lib/python3.10/site-packages:$PYTHONPATH

echo -e "::endgroup::\n::group::Build podio"
cmake -B build . --install-prefix=$(pwd)/install \
-GNinja -DENABLE_SIO=ON -DENABLE_RNTUPLE=ON \
-DBUILD_TESTING=OFF \
-DCMAKE_CXX_STANDARD=17
cmake --build build --target install
export PYTHONPATH=$(pwd)/install/python:$PYTHONPATH
export LD_LIBRARY_PATH=$(pwd)/install/lib*/:$LD_LIBRARY_PATH
export ROOT_INCLUDE_PATH=$(pwd)/install/include

echo -e "::endgroup::\n::group::build doc"
sphinx-build -M html doc doc_output

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: doc_output/html

publish-doc:
needs: build-doc
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
- uses: actions/download-artifact@v4
with:
name: github-pages
path: doc_artifact

- name: Update documentation
env:
TARGET_DIR: ${{ github.ref_name }}
run: |
mkdir -p ${TARGET_DIR}
rm -rf ${TARGET_DIR}/*
tar -xvf doc_artifact/artifact.tar --directory ${TARGET_DIR}
rm -r doc_artifact

- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_DIR: ${{ github.ref_name }}
run: |
git config --global user.email ${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com
git config --global user.name ${GITHUB_ACTOR}
git add ${TARGET_DIR}
git diff-index --quiet HEAD 2>&1 > /dev/null || git commit -m "Update documentation for ${TARGET_DIR}" && git push
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ spack*
/python/podio/__version__.py
/python/podio_version.py

# Populated by doc generation
/doc/py_api
/doc/_build
/doc/cpp_api/

# CLion artifacts
.idea/
cmake-build*/
8 changes: 8 additions & 0 deletions cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
find_program(SPHINX_BUILD_EXECUTABLE
NAMES sphinx-build
DOC "Path to sphinx-build executable")

include(FindPackageHandleStandardArgs)

# Handle standard arguments to find_package
find_package_handle_standard_args(Sphinx "Failed to find sphinx executable" SPHINX_BUILD_EXECUTABLE)
38 changes: 19 additions & 19 deletions cmake/podioDoxygen.cmake
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
find_package(Doxygen)
if(DOXYGEN_FOUND)
# temporarily override the version for doxy generation (for nightly snapshots)
set(tmp ${podio_VERSION})
if(DOXYVERSION)
set(podio_VERSION ${DOXYVERSION})
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/doxy-boot.js.in
${PROJECT_BINARY_DIR}/doxygen/html/doxy-boot.js)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM)
find_package(Sphinx)

install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen DESTINATION doxygen OPTIONAL)
# revert version to old value
set(podio_VERSION ${tmp})
unset(tmp)
endif(DOXYGEN_FOUND)
if(DOXYGEN_FOUND AND SPHINX_FOUND)
set(SPHINX_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/doc/_build)

add_custom_target(documentation
COMMAND
${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src/:$ENV{LD_LIBRARY_PATH};ROOT_INCLUDE_PATH=${CMAKE_SOURCE_DIR}/include;"
${SPHINX_BUILD_EXECUTABLE} -M html
${CMAKE_SOURCE_DIR}/doc ${SPHINX_OUTPUT_DIRECTORY}
COMMENT "Building documentation" VERBATIM
DEPENDS podio::podio podio::podioRootIO
)

install(DIRECTORY ${SPHINX_OUTPUT_DIRECTORY}/
DESTINATION ${CMAKE_INSTALL_DOCDIR}
OPTIONAL)
else()
message(WARNING "Could not generate documentation because either Doxygen or Sphinx could not be found")
endif()
Loading