Skip to content

Commit

Permalink
Convert doc to sphinx
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
jschueller committed Mar 20, 2024
1 parent c02c769 commit 1db1b66
Show file tree
Hide file tree
Showing 34 changed files with 820 additions and 2,301 deletions.
7 changes: 3 additions & 4 deletions .ci_support/run_docker_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ cd /tmp
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/.local \
-DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=32 \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -D_GLIBCXX_ASSERTIONS" \
-DSWIG_COMPILE_FLAGS="-O1 -Wno-unused-parameter" \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Wshadow -Werror -D_GLIBCXX_ASSERTIONS" \
-DSWIG_COMPILE_FLAGS="-O1 -Wno-unused-parameter -Wno-shadow" \
-DSPHINX_FLAGS="-W -T -j4" \
/io
make install
make tests
ctest --output-on-failure --timeout 100 ${MAKEFLAGS}

exit 0
uid=$1
gid=$2
if test -n "${uid}" -a -n "${gid}"
then
sudo cp -r ~/.local/share/*/doc/html /io
sudo cp -r ~/.local/share/doc/*/html /io
sudo chown -R ${uid}:${gid} /io/html
fi
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Build
on: [push, pull_request]
on:
push:
branches: [ master ]
pull_request:
jobs:
linux:
runs-on: ubuntu-latest
Expand All @@ -12,7 +15,6 @@ jobs:
- name: Upload
if: ${{ github.ref == 'refs/heads/master' }}
run: |
exit 0
git clone --depth 1 https://${{ secrets.GH_TOKEN }}@github.com/openturns/openturns.github.io.git /tmp/io
mkdir -p /tmp/io/otmixmod/master
cp -r html/* /tmp/io/otmixmod/master
Expand Down
29 changes: 14 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required (VERSION 3.13)

option ( BUILD_PYTHON "Build the python module for the library" ON )
option ( BUILD_DOC "Build the documentation" ON )
option ( BUILD_SHARED_LIBS "Build shared libraries" ON )
option (BUILD_PYTHON "Build the python module for the library" ON)
option (USE_SPHINX "Use sphinx for documentation" ON)
option (BUILD_SHARED_LIBS "Build shared libraries" ON)

# By default, build in Release mode. Must appear before project() command
set( CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
Expand Down Expand Up @@ -67,19 +67,21 @@ if (BUILD_PYTHON)
endif ()

if (Python_FOUND)
#include (FindPythonModule)
include (FindPythonModule)
find_python_module (matplotlib)
if (NOT TARGET Python::Module)
include (TargetLinkLibrariesWithDynamicLookup)
endif ()

if (USE_SPHINX)
find_program (SPHINX_EXECUTABLE NAMES sphinx-build DOC "Sphinx Documentation Builder (sphinx-doc.org)")
find_python_module (numpydoc)
if (SPHINX_EXECUTABLE AND NUMPYDOC_FOUND)
find_python_module (sphinx 1.1)
find_python_module (sphinx_gallery)
if (SPHINX_EXECUTABLE AND NUMPYDOC_FOUND AND SPHINX_GALLERY_FOUND AND MATPLOTLIB_FOUND)
find_python_module (sphinx)
endif ()
if (NOT SPHINX_FOUND)
message (STATUS "Disabling documentation (need sphinx/pandoc/numpydoc)")
message (STATUS "Disabling documentation (need sphinx/pandoc/numpydoc/sphinx-gallery/matplotlib)")
endif ()
endif ()

Expand Down Expand Up @@ -123,11 +125,11 @@ macro (ot_install_swig_file FILENAME)
install (FILES ${FILENAME} DESTINATION ${OTMIXMOD_SWIG_INCLUDE_DIRS})
endmacro ()

set ( INTERNAL_INCLUDE_DIRS "" CACHE INTERNAL "List of directories with header files needed for build" )
macro ( ot_add_current_dir_to_include_dirs )
set ( inc_dirs ${INTERNAL_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} )
set ( INTERNAL_INCLUDE_DIRS ${inc_dirs} CACHE INTERNAL "List of directories with header files needed for build" )
endmacro ( ot_add_current_dir_to_include_dirs )
set (INTERNAL_INCLUDE_DIRS "" CACHE INTERNAL "List of directories with header files needed for build")
macro (ot_add_current_dir_to_include_dirs)
set (inc_dirs ${INTERNAL_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
set (INTERNAL_INCLUDE_DIRS ${inc_dirs} CACHE INTERNAL "List of directories with header files needed for build")
endmacro ()


set ( CPACK_PACKAGE_NAME ${PACKAGE_NAME} )
Expand Down Expand Up @@ -162,9 +164,6 @@ if (Python_FOUND AND SWIG_FOUND)
add_dependencies (installcheck pyinstallcheck)
endif ()

if (BUILD_DOC)
add_subdirectory (doc)
endif ()

# uninstall target
configure_file (
Expand Down
83 changes: 83 additions & 0 deletions cmake/FindPythonModule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# - Macro to find a python module
#
# Usage:
# include (FindPythonModule)
# find_python_module (module [VERSION] [REQUIRED])
#
# The following variables are defined:
# MODULE_FOUND - true if found
# MODULE_LOCATION - directory of the module, or it's library file if binary module
# MODULE_VERSION_STRING - module version, if available through __version__
#
#=============================================================================
# Copyright 2005-2023 Airbus-EDF-IMACS-ONERA-Phimeca
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)

macro (find_python_module module)

string (TOUPPER ${module} module_upper)
if (NOT ${module_upper}_FOUND)

# parse arguments
set (${module}_FIND_OPTIONAL TRUE)
if (${ARGC} EQUAL 2)
if (${ARGV1} MATCHES REQUIRED)
set (${module}_FIND_OPTIONAL FALSE)
else ()
set (${module}_FIND_VERSION ${ARGV1})
endif ()
elseif (${ARGC} EQUAL 3)
if (${ARGV2} MATCHES REQUIRED)
set (${module}_FIND_OPTIONAL FALSE)
endif ()
set (${module}_FIND_VERSION ${ARGV1})
endif ()

# A module's location is usually a directory, but for binary modules it's a .so file.
execute_process (COMMAND "${Python_EXECUTABLE}" "-c"
"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
RESULT_VARIABLE _${module}_status
OUTPUT_VARIABLE _${module}_location
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT _${module}_status)
set (${module_upper}_LOCATION ${_${module}_location}
CACHE STRING "Location of Python module ${module}")
# retrieve version
execute_process (COMMAND "${Python_EXECUTABLE}" "-c" "import ${module}; print(${module}.__version__)"
RESULT_VARIABLE _${module}_status
OUTPUT_VARIABLE _${module}_version
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)

set (_${module_upper}_VERSION_MATCH TRUE)
if (NOT _${module}_status)
set (${module_upper}_VERSION_STRING ${_${module}_version})
if (${module}_FIND_VERSION)
if (${module}_FIND_VERSION VERSION_GREATER ${module_upper}_VERSION_STRING)
set (_${module_upper}_VERSION_MATCH FALSE)
endif ()
endif ()
mark_as_advanced (${module_upper}_VERSION_STRING)
endif ()
endif ()

# https://gitlab.kitware.com/cmake/cmake/-/issues/21505
if (CMAKE_VERSION VERSION_EQUAL 3.19.1)
set (CMAKE_FIND_PACKAGE_NAME "${module}")
endif ()
find_package_handle_standard_args (${module} REQUIRED_VARS ${module_upper}_LOCATION
${module}_FIND_OPTIONAL
_${module_upper}_VERSION_MATCH
VERSION_VAR ${module_upper}_VERSION_STRING
)
mark_as_advanced (${module_upper}_LOCATION)
endif (NOT ${module_upper}_FOUND)
endmacro (find_python_module)
Loading

0 comments on commit 1db1b66

Please sign in to comment.