diff --git a/.ci_environment_docs.yaml b/.ci_environment_docs.yaml new file mode 100644 index 0000000..a36c4dd --- /dev/null +++ b/.ci_environment_docs.yaml @@ -0,0 +1,8 @@ +channels: + - conda-forge +dependencies: + - cmake + - setuptools_scm + - xtensor + - doxygen + - eigen diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 7b2b726..6d0d3fc 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -1,46 +1,45 @@ name: gh-pages on: push: branches: - master jobs: publish: runs-on: ubuntu-latest defaults: run: shell: bash -l {0} steps: - name: Basic GitHub action setup uses: actions/checkout@v2 - - name: Set conda environment "test" - uses: conda-incubator/setup-miniconda@v2 + - name: Set conda environment (using micromamba for speed) + uses: mamba-org/provision-with-micromamba@main with: - mamba-version: "*" - channels: conda-forge,defaults - channel-priority: true - environment-file: docs/environment.yaml - activate-environment: test - auto-activate-base: false + environment-file: .ci_environment_docs.yaml + environment-name: myenv - - name: Run doxygen - working-directory: docs - run: doxygen + - name: Configure using CMake + run: cmake -Bbuild -DBUILD_DOCS=1 + + - name: Build the docs + working-directory: build + run: make docs - name: Deploy to GitHub Pages if: success() uses: crazy-max/ghaction-github-pages@v2 with: target_branch: gh-pages - build_dir: docs/html + build_dir: build/html jekyll: false keep_history: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index ab59814..e92c23e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,102 +1,150 @@ -# -# (c - GPLv3) T.W.J. de Geus (Tom) | tom@geus.me | www.geus.me | github.com/tdegeus/GooseFEM -# - -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.1..3.19) # Basic settings # ============== project(GooseFEM) -option(BUILD_TESTS "Build tests" OFF) -option(BUILD_EXAMPLES "Build examples" OFF) +option(BUILD_TESTS "${PROJECT_NAME}: Build tests" OFF) +option(BUILD_EXAMPLES "${PROJECT_NAME}: Build examples" OFF) +option(BUILD_DOCS "${PROJECT_NAME}: Build docs" OFF) +option(CHECK_DOCS "${PROJECT_NAME}: Check docs (throw error for every warning)" OFF) # Version # ======= IF(DEFINED ENV{PKG_VERSION}) set(GOOSEFEM_VERSION $ENV{PKG_VERSION}) else() execute_process( COMMAND python -c "from setuptools_scm import get_version; print(get_version())" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GOOSEFEM_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) endif() message(STATUS "Building ${PROJECT_NAME} ${GOOSEFEM_VERSION}") # Set target # ========== find_package(xtensor REQUIRED) add_library(GooseFEM INTERFACE) target_include_directories(GooseFEM INTERFACE $ $) target_link_libraries(GooseFEM INTERFACE xtensor) # Installation # ============ include(CMakePackageConfigHelpers) include(GNUInstallDirs) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include) configure_file("include/${PROJECT_NAME}/version.h" "${CMAKE_CURRENT_BINARY_DIR}/version.h" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/version.h" DESTINATION "include/${PROJECT_NAME}/") install(TARGETS GooseFEM EXPORT GooseFEM-targets) install( EXPORT GooseFEM-targets - FILE GooseFEMTargets.cmake - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/GooseFEM") + FILE "${PROJECT_NAME}Targets.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") set(_GOOSEFEM ${CMAKE_SIZEOF_VOID_P}) unset(CMAKE_SIZEOF_VOID_P) -write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/GooseFEMConfigVersion.cmake" +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" VERSION ${GOOSEFEM_VERSION} COMPATIBILITY AnyNewerVersion) set(CMAKE_SIZEOF_VOID_P ${_GOOSEFEM}) -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/GooseFEMConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/GooseFEMConfigVersion.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/GooseFEM") +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/GooseFEM.pc.in" - "${CMAKE_CURRENT_BINARY_DIR}/GooseFEM.pc" @ONLY) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" @ONLY) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/GooseFEM.pc" +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/") # Add builds # ========== -include("GooseFEMConfig.cmake") - +include("${PROJECT_NAME}Config.cmake") include(CTest) +# Tests + if(BUILD_TESTS) enable_testing() add_subdirectory(test/basic) enable_testing() add_subdirectory(test/gmat) endif() +# Examples + if(BUILD_EXAMPLES) enable_testing() add_subdirectory(docs/examples) endif() + +# Check docs: only this library, throw error for every warning + +if(CHECK_DOCS) + find_package(Doxygen REQUIRED) + + set(DOXYGEN_EXCLUDE_SYMBOLS detail) + set(DOXYGEN_CASE_SENSE_NAMES YES) + set(DOXYGEN_USE_MATHJAX YES) + set(DOXYGEN_QUIET YES) + set(DOXYGEN_WARN_IF_UNDOCUMENTED YES) + set(DOXYGEN_WARN_AS_ERROR YES) + + set(DOXYGEN_ALIASES + "rst=\\verbatim embed:rst:leading-asterisk" + "endrst=\\endverbatim" + "license=@par License:") + + doxygen_add_docs(check_docs "${CMAKE_CURRENT_SOURCE_DIR}/include") +endif() + +# Build docs: include dependencies + +if(BUILD_DOCS) + find_package(Doxygen REQUIRED) + + set(DOXYGEN_EXCLUDE_SYMBOLS detail) + set(DOXYGEN_CASE_SENSE_NAMES YES) + set(DOXYGEN_USE_MATHJAX YES) + set(DOXYGEN_GENERATE_TREEVIEW YES) + set(DOXYGEN_JAVADOC_AUTOBRIEF YES) + set(DOXYGEN_MACRO_EXPANSION YES) + set(DOXYGEN_SOURCE_BROWSER YES) + set(DOXYGEN_GENERATE_XML YES) + set(DOXYGEN_QUIET YES) + set(DOXYGEN_WARN_IF_UNDOCUMENTED YES) + + set(DOXYGEN_ALIASES + "rst=\\verbatim embed:rst:leading-asterisk" + "endrst=\\endverbatim" + "license=@par License:") + + set(DOXYGEN_STRIP_FROM_INC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") + set(DOXYGEN_STRIP_FROM_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") + doxygen_add_docs(docs "${CMAKE_CURRENT_SOURCE_DIR}/include") +endif() diff --git a/docs/Doxyfile b/docs/Doxyfile deleted file mode 100644 index 113cdca..0000000 --- a/docs/Doxyfile +++ /dev/null @@ -1,26 +0,0 @@ -PROJECT_NAME = "GooseFEM" -XML_OUTPUT = xml -INPUT = ../include doxy_landing.md -GENERATE_LATEX = NO -GENERATE_MAN = NO -GENERATE_RTF = NO -CASE_SENSE_NAMES = NO -GENERATE_HTML = YES -GENERATE_XML = YES -RECURSIVE = YES -QUIET = YES -JAVADOC_AUTOBRIEF = YES -WARN_IF_UNDOCUMENTED = NO -MACRO_EXPANSION = YES -PREDEFINED = IN_DOXYGEN -EXCLUDE_SYMBOLS = detail -GENERATE_TREEVIEW = YES -SOURCE_BROWSER = YES -# WARN_IF_UNDOCUMENTED = YES - -# Allow for rst directives and advanced functions e.g. grid tables -ALIASES = "rst=\verbatim embed:rst:leading-asterisk" -ALIASES += "endrst=\endverbatim" - -# Add license command -ALIASES += "license=@par License:" diff --git a/docs/conf.py b/docs/conf.py index 8dcfb60..94e3772 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,74 +1,74 @@ # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # import os import sys # sys.path.insert(0, os.path.abspath('.')) # -- Run Doxygen ------------------------------------------------------------- import subprocess read_the_docs_build = os.environ.get('READTHEDOCS', None) == 'True' if read_the_docs_build: subprocess.call('doxygen', shell=True) # -- Project information ----------------------------------------------------- project = 'GooseFEM' copyright = '2017-2021, Tom de Geus' author = 'Tom de Geus' # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ "breathe", 'sphinx.ext.imgmath', 'sphinx.ext.todo', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'sphinx_rtd_theme' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # -- Breathe configuration --------------------------------------------------- breathe_projects = { - "GooseFEM": "./xml/", + "GooseFEM": "../build/xml/", } diff --git a/docs/environment.yaml b/docs/environment.yaml deleted file mode 100644 index 3f7f02e..0000000 --- a/docs/environment.yaml +++ /dev/null @@ -1,10 +0,0 @@ -channels: - - conda-forge -dependencies: - - doxygen - - breathe - - sphinx - - sphinx_rtd_theme - - python-goosefem - - pyxtensor - - eigen