Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Added conditional statement on build process to avoid compiling all o…
Browse files Browse the repository at this point in the history
…f the Fortran portion of the code when building documentation
  • Loading branch information
daminton committed Dec 20, 2023
1 parent e159e52 commit d48e71c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ build:
os: ubuntu-22.04
tools:
python: "3.11"
environment:
DOC_BUILD: 1
apt_packages:
- graphviz
jobs:
pre_build:
- ford fortran_docs.md
python:
install:
- method: pip
path: .
extra_requirements:
- docs
- requirements: docs/requirements.txt
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 6 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]

0 comments on commit d48e71c

Please sign in to comment.