diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 5cfd4b94c..3ca932223 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -15,6 +15,8 @@ build: os: ubuntu-22.04 tools: python: "3.11" + environment: + DOC_BUILD: 1 apt_packages: - graphviz jobs: @@ -22,4 +24,8 @@ build: - ford fortran_docs.md python: install: + - method: pip + path: . + extra_requirements: + - docs - requirements: docs/requirements.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ce195ac5..221a9b045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.6.0...3.27.1) SET(SKBUILD_PROJECT_NAME "swiftest" CACHE STRING "Name of project set by scikit-build") SET(SKBUILD_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/bin" CACHE STRING "Install location of binary executable") + # Get version stored in text file FILE(READ "version.txt" VERSION) PROJECT(${SKBUILD_PROJECT_NAME} LANGUAGES C Fortran VERSION ${VERSION}) @@ -114,10 +115,16 @@ IF (COMPILER_OPTIONS STREQUAL "Intel" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Window ENDIF () INCLUDE(SetSwiftestFlags) -# The source for the SWIFTEST binary and have it placed in the bin folder -ADD_SUBDIRECTORY(${SRC} ${CMAKE_INSTALL_BINDIR}) -ADD_SUBDIRECTORY(${PY}) +# Check if DOC_BUILD environment variable is set and skip build if it is +IF (DEFINED ENV{DOC_BUILD}) + MESSAGE(STATUS "DOC_BUILD is set. Skipping build process.") +ELSE() + + # The source for the SWIFTEST binary and have it placed in the bin folder + ADD_SUBDIRECTORY(${SRC} ${CMAKE_INSTALL_BINDIR}) + ADD_SUBDIRECTORY(${PY}) +ENDIF() # Add a distclean target to the Makefile ADD_CUSTOM_TARGET(distclean COMMAND ${CMAKE_COMMAND} -P "${CMAKE_SOURCE_DIR}/distclean.cmake" diff --git a/docs/conf.py b/docs/conf.py index 25d8509f5..b3bf79153 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,10 +8,11 @@ from sphinx.application import Sphinx from sphinx.util import logging -swiftest_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'swiftest')) -sys.path.insert(0, swiftest_path) +# Disable import of swiftest._bindings so that we don't have to build the Fortran code when building the docs +autodoc_mock_imports = ['swiftest._bindings'] + +import swiftest -autodoc_mock_imports = ['swiftest'] # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information @@ -168,7 +169,8 @@ def linkcode_resolve(domain, info): else: linespec = "" - fn = os.path.relpath(fn, start=os.path.dirname(swiftest_path)) + fn = os.path.relpath(fn, start=os.path.dirname()) + def html_page_context(app, pagename, templatename, context, doctree): diff --git a/pyproject.toml b/pyproject.toml index d1068a8bb..ee18493cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -142,3 +142,18 @@ CMAKE_INSTALL_LIBDIR="lib" path = "version.txt" location = "source" template = '''${version}''' + +[project.optional-dependencies] +docs = [ + "sphinx", + "sphinx-autosummary-accessors", + "sphinx-book-theme >= 0.3.0", + "sphinx-copybutton", + "sphinx-design", + "sphinx-inline-tabs", + "sphinxext-rediraffe", + "sphinxext-opengraph", + "nbsphinx", + "ipython", + "ford" +] \ No newline at end of file