Skip to content

Sphinx documentation update #1719

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

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7ad4007
update creation of sphinx documentation
Davknapp Jun 23, 2025
f5e07fb
Add configuration file for readthedocs
Davknapp Jun 23, 2025
f0f8fa9
readthedocs specializations
Davknapp Jun 23, 2025
87da7a4
update paths to Doxyfile.in
Davknapp Jun 23, 2025
f63e014
generate xml output
Davknapp Jun 23, 2025
ce2e21e
Added requirements
Davknapp Jun 24, 2025
2e3554f
try relative paths
Davknapp Jun 24, 2025
94e7b5e
try other folder
Davknapp Jun 24, 2025
6a90182
mv requirements back and activate install part in yaml-file
Davknapp Jun 24, 2025
6c23c0b
fix indent in yaml
Davknapp Jun 24, 2025
aab33b3
another indent fix
Davknapp Jun 24, 2025
aefeae9
add all requirements
Davknapp Jun 24, 2025
909cc8b
update requirements
Davknapp Jun 24, 2025
e3d03e6
configure and build doxygen
Davknapp Jun 24, 2025
7ecf515
try fix
Davknapp Jun 24, 2025
5b58cf8
Add cmake to the tools used
Davknapp Jun 24, 2025
0099e0c
try typo fix
Davknapp Jun 24, 2025
7fd9ec6
fix cmake tool
Davknapp Jun 24, 2025
3567547
fix cmake usage
Davknapp Jun 24, 2025
35765fa
install sphinx as apt-package
Davknapp Jun 24, 2025
cd80d40
search for sphinx-build
Davknapp Jun 24, 2025
a49237b
add hints to find sphinx
Davknapp Jun 24, 2025
4f8046f
Move build process
Davknapp Jun 24, 2025
475b6f9
call script
Davknapp Jun 24, 2025
c324902
move bash call
Davknapp Jun 24, 2025
f5dbafe
build the documentation
Davknapp Jun 24, 2025
72740d6
try to build via ninja
Davknapp Jun 24, 2025
1dace73
update confi.in file
Davknapp Jun 24, 2025
b2e44ae
use the pre-build step to write var
Davknapp Jun 24, 2025
9d7e210
another try
Davknapp Jun 24, 2025
216285c
try to generte conf.py again
Davknapp Jun 24, 2025
a1f9112
try to fetch tags too
Davknapp Jun 24, 2025
506258e
Build t8code without mpi for documenation
Davknapp Jun 24, 2025
a966c8f
move script call to build step
Davknapp Jun 24, 2025
17098d1
try post_build
Davknapp Jun 24, 2025
530fd66
Update configure
Davknapp Jun 24, 2025
0ff009b
try post-install
Davknapp Jun 24, 2025
b01e7b5
import subprocess
Davknapp Jun 24, 2025
cd943ad
Merge branch 'main' into sphinx_documentation_update
Davknapp Jun 25, 2025
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
64 changes: 64 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This file is part of t8code.
# t8code is a C library to manage a collection (a forest) of multiple
# connected adaptive space-trees of general element types in parallel.
#
# Copyright (C) 2025 the developers
#
# t8code is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# t8code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with t8code; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
apt_packages:
- cmake
- ninja-build
jobs:
post_checkout:
- git fetch --unshallow --tags || true # Fetch all tags to ensure we can build documentation for any version
post_install:
- bash ./scripts/configure_for_rtd.sh

# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: doc/source/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: doc/requirements.txt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- requirements: doc/requirements.txt
- requirements: doc/requirements.txt

17 changes: 15 additions & 2 deletions cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,25 @@
# along with t8code; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

include(FindPackageHandleStandardArgs)

find_package(PythonInterp)
if(PYTHONINTERP_FOUND)
get_filename_component(_PYTHON_DIR "${PYTHON_EXECUTABLE}" DIRECTORY)
set(
_PYTHON_PATHS
"${_PYTHON_DIR}"
"{_PYTHON_DIR}/bin"
"{_PYTHON_DIR}/Scripts"
)
endif()

#Look for an executable called sphinx-build
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
NAMES sphinx-build sphinx-build.exe sphinx-build.py
HINTS ${_PYTHON_PATHS}
DOC "Path to sphinx-build executable")

include(FindPackageHandleStandardArgs)

#Handle standard arguments to find_package like REQUIRED and QUIET
find_package_handle_standard_args(Sphinx
Expand Down
10 changes: 5 additions & 5 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ if(T8CODE_BUILD_DOCUMENTATION)

add_custom_command( OUTPUT ${DOXYGEN_INDEX_FILE}
DEPENDS ${T8_PUBLIC_HEADERS}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMENT "Generating documentation"
VERBATIM)

Expand All @@ -53,9 +53,9 @@ endif(T8CODE_BUILD_DOCUMENTATION)

if (T8CODE_BUILD_DOCUMENTATION_SPHINX)
find_package(Sphinx REQUIRED)

configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)

if (SPHINX_FOUND)
set(SPHINX_SOURCE ${PROJECT_SOURCE_DIR}/doc/source)
set(SPHINX_BUILD ${PROJECT_BINARY_DIR}/doc/sphinx)
Expand Down Expand Up @@ -85,7 +85,7 @@ if (T8CODE_BUILD_DOCUMENTATION_SPHINX)
MAIN_DEPENDENCY ${SPHINX_SOURCE}/conf.py
COMMENT "Generating documentation with Sphinx")


# Nice named target so we can run the job easily
add_custom_target(Sphinx ALL DEPENDS ${SPHINX_INDEX_FILE})
else (SPHINX_FOUND)
Expand Down
2 changes: 1 addition & 1 deletion doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ MAN_LINKS = NO
# captures the structure of the code including all documentation.
# The default value is: NO.

GENERATE_XML = NO
GENERATE_XML = YES

# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
Expand Down
4 changes: 4 additions & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
breathe
exhale
sphinx
sphinx-rtd-theme
34 changes: 32 additions & 2 deletions doc/source/conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import subprocess, os

project = 't8code'
copyright = '2024, Johannes Holke, David Knapp, Sandro Elsweijer, Ioannis Lilikakis, Lukas Dreyer, Jakob Fußbroich, Carsten Burstedde, Chiara Hergl, Johannes Markert, Niklas Boeing, Florian Becker, Prasanna Ponnusamy'
author = 'Johannes Holke, David Knapp, Sandro Elsweijer, Ioannis Lilikakis, Lukas Dreyer, Jakob Fußbroich, Carsten Burstedde, Chiara Hergl, Johannes Markert, Niklas Boeing, Florian Becker, Prasanna Ponnusamy'
Expand All @@ -14,7 +16,7 @@ version = '@VERSION@'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [ "breathe", "exhale", "sphinx.ext.mathjax", "sphinx.ext.graphviz" ]
extensions = [ 'breathe', 'exhale', 'sphinx.ext.mathjax', 'sphinx.ext.graphviz' ]

templates_path = ['_templates']
exclude_patterns = []
Expand All @@ -23,11 +25,39 @@ exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

# Breathe Configuration
breathe_projects = {}

def configureDoxyfile(input_dir, output_dir):
with open('../Doxyfile.in', 'r') as file :
filedata = file.read()

filedata = filedata.replace('@DOXYGEN_INPUT_DIR@', input_dir)
filedata = filedata.replace('@DOXYGEN_OUTPUT_DIR@', output_dir)

with open('../Doxyfile', 'w') as file:
file.write(filedata)

# Check if we're running on Read the Docs' servers
read_the_docs_build = os.environ.get('READTHEDOCS', None) == 'True'


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

breathe_projects = {}

if read_the_docs_build:
input_dir = '../../src'
output_dir = 'build'
configureDoxyfile(input_dir, output_dir)
subprocess.call('doxygen', shell=True)
breathe_projects["T8code"] = output_dir + '/xml'

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
html_logo = '../../t8code_logo.png'

# Breathe Configuration
breathe_default_project = "T8code"
breathe_implementation_filename_extensions = ['.c', '.cpp']

Expand Down
19 changes: 19 additions & 0 deletions scripts/configure_for_rtd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

git submodule init
git submodule update

# Create the build directory
mkdir build

# Navigate into the build directory
cd build

# Run cmake with the specified options
cmake .. -DT8CODE_BUILD_DOCUMENTATION=ON -DT8CODE_BUILD_DOCUMENTATION_SPHINX=ON -DT8CODE_ENABLE_MPI=OFF

# Build the project with make
make -j V=0

# Return to the parent directory
cd ..