From fff3ac255e33a1a408561be5d07d48d545b58259 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 22 Jan 2016 19:52:17 +0300 Subject: [PATCH] Set-up Sphinx theme depending on its version --- CMakeModules/SalomeDocumentationMacros.cmake | 78 +++++++++++--------- dev/cmake/CMakeLists.txt | 4 +- dev/cmake/source/{conf.py => conf.py.in} | 0 dev/git/CMakeLists.txt | 4 +- dev/git/{conf.py => conf.py.in} | 0 5 files changed, 48 insertions(+), 38 deletions(-) rename dev/cmake/source/{conf.py => conf.py.in} (100%) rename dev/git/{conf.py => conf.py.in} (100%) diff --git a/CMakeModules/SalomeDocumentationMacros.cmake b/CMakeModules/SalomeDocumentationMacros.cmake index 70ee6bc..0d14fef 100644 --- a/CMakeModules/SalomeDocumentationMacros.cmake +++ b/CMakeModules/SalomeDocumentationMacros.cmake @@ -22,7 +22,7 @@ #---------------------------------------------------------------------------- # SALOME_ADD_SPHINX_DOC is a macro useful for generating sphinx documentation # -# USAGE: SALOME_ADD_SPHINX_DOC(sphinx_type [path1 path2 ... ]) +# USAGE: SALOME_ADD_SPHINX_DOC(sphinx_type sphinx_name src_dir cfg_dir) # # ARGUMENTS: # @@ -50,7 +50,10 @@ # # sphinx_name: IN - documentation target name # -# path : IN - optional arguments, list of the paths whese contains the sphinx configuration files. +# src_dir : IN - path to directory that contains the sphinx source files +# +# cfg_dir : IN - path to directory that contains sphinx configuration file (if not specified, +# it is considered equal to src_dir) # # ADDITIONAL SETTINGS: # @@ -61,46 +64,49 @@ # BUILDDIR - local sphinx build directory ("_build" by default) #---------------------------------------------------------------------------- -MACRO(SALOME_ADD_SPHINX_DOC sphinx_type sphinx_name) +MACRO(SALOME_ADD_SPHINX_DOC sphinx_type sphinx_name src_dir cfg_dir) -# Get type and additional settings - SET(SPHINX_TYPE ${sphinx_type}) - IF(${SPHINX_TYPE} STREQUAL "") - SET(SPHINX_TYPE html) - ENDIF(${SPHINX_TYPE} STREQUAL "") + # Get type and additional settings + SET(SPHINX_TYPE ${sphinx_type}) + IF(${SPHINX_TYPE} STREQUAL "") + SET(SPHINX_TYPE html) + ENDIF(${SPHINX_TYPE} STREQUAL "") - IF("${PAPER}" STREQUAL "") - SET(PAPER a4) - ENDIF() + IF("${PAPER}" STREQUAL "") + SET(PAPER a4) + ENDIF() - IF("${BUILDDIR}" STREQUAL "") - SET(BUILDDIR _build) - ENDIF() + IF("${BUILDDIR}" STREQUAL "") + SET(BUILDDIR _build) + ENDIF() + + SET(SPHINX_CFG ${cfg_dir}) + IF("${SPHINX_CFG}" STREQUAL "") + SET(SPHINX_CFG ${src_dir}) + ENDIF() - # Initialize internal variables - SET(PAPEROPT_a4 -D latex_paper_size=a4) - SET(PAPEROPT_letter -D latex_paper_size=letter) - SET(ALLSPHINXOPTS -d ${BUILDDIR}/doctrees ${PAPEROPT_${PAPER}} ${SPHINXOPTS}) - SET(I18NSPHINXOPTS ${PAPEROPT_${PAPER}} ${SPHINXOPTS}) + # Initialize internal variables + SET(PAPEROPT_a4 -D latex_paper_size=a4) + SET(PAPEROPT_letter -D latex_paper_size=letter) + SET(ALLSPHINXOPTS -d ${BUILDDIR}/doctrees ${PAPEROPT_${PAPER}} ${SPHINXOPTS}) + SET(I18NSPHINXOPTS ${PAPEROPT_${PAPER}} ${SPHINXOPTS}) - FOREACH(value ${ARGN}) - SET(ALLSPHINXOPTS ${ALLSPHINXOPTS} ${value}) - SET(I18NSPHINXOPTS ${I18NSPHINXOPTS} ${value}) - ENDFOREACH(value ${ARGN}) + SET(ALLSPHINXOPTS ${ALLSPHINXOPTS} ${src_dir}) + SET(I18NSPHINXOPTS ${I18NSPHINXOPTS} ${src_dir}) - # Set internal out directory - SET(_OUT_DIR ${sphinx_type}) - IF(${sphinx_type} STREQUAL "gettext") - SET(_OUT_DIR gettext) - SET(ALLSPHINXOPTS ${I18NSPHINXOPTS}) - ENDIF(${sphinx_type} STREQUAL "gettext") + # Set internal out directory + SET(_OUT_DIR ${SPHINX_TYPE}) + IF(${SPHINX_TYPE} STREQUAL "gettext") + SET(_OUT_DIR gettext) + SET(ALLSPHINXOPTS ${I18NSPHINXOPTS}) + ENDIF(${SPHINX_TYPE} STREQUAL "gettext") - # Build sphinx command - SET(_CMD_OPTIONS -b ${sphinx_type} ${ALLSPHINXOPTS} ${BUILDDIR}/${_OUT_DIR}) + # Build sphinx command + SET(_CMD_OPTIONS -b ${SPHINX_TYPE} -c ${SPHINX_CFG} ${ALLSPHINXOPTS} ${BUILDDIR}/${_OUT_DIR}) - # This macro mainly prepares the environment in which sphinx should run: - # this sets the PYTHONPATH and LD_LIBRARY_PATH to include OMNIORB, DOCUTILS, SETUPTOOLS, etc ... - SALOME_GENERATE_ENVIRONMENT_SCRIPT(_cmd env_script "${SPHINX_EXECUTABLE}" "${_CMD_OPTIONS}") - ADD_CUSTOM_TARGET(${sphinx_name} ALL ${_cmd}) + # This macro mainly prepares the environment in which sphinx should run: + # this sets the PYTHONPATH and LD_LIBRARY_PATH to include OMNIORB, DOCUTILS, SETUPTOOLS, etc ... + SALOME_GENERATE_ENVIRONMENT_SCRIPT(_cmd env_script "${SPHINX_EXECUTABLE}" "${_CMD_OPTIONS}") + ADD_CUSTOM_TARGET(${sphinx_name} ALL ${_cmd}) -ENDMACRO(SALOME_ADD_SPHINX_DOC sphinx_type) \ No newline at end of file +ENDMACRO(SALOME_ADD_SPHINX_DOC) \ No newline at end of file diff --git a/dev/cmake/CMakeLists.txt b/dev/cmake/CMakeLists.txt index 8dbde37..bd8f474 100644 --- a/dev/cmake/CMakeLists.txt +++ b/dev/cmake/CMakeLists.txt @@ -21,9 +21,11 @@ # ================== INCLUDE(SalomeDocumentationMacros) +SALOME_CONFIGURE_FILE(source/conf.py.in conf.py) + # Add sphinx documentation target # ============================ -SALOME_ADD_SPHINX_DOC( html cmake_doc ${CMAKE_CURRENT_SOURCE_DIR}/source) +SALOME_ADD_SPHINX_DOC(html cmake_doc ${CMAKE_CURRENT_SOURCE_DIR}/source ${CMAKE_CURRENT_BINARY_DIR}) # Install rules # ========== diff --git a/dev/cmake/source/conf.py b/dev/cmake/source/conf.py.in similarity index 100% rename from dev/cmake/source/conf.py rename to dev/cmake/source/conf.py.in diff --git a/dev/git/CMakeLists.txt b/dev/git/CMakeLists.txt index 611fa0c..8bb7daa 100644 --- a/dev/git/CMakeLists.txt +++ b/dev/git/CMakeLists.txt @@ -21,9 +21,11 @@ # ================== INCLUDE(SalomeDocumentationMacros) +SALOME_CONFIGURE_FILE(conf.py.in conf.py) + # Add sphinx documentation target # ============================ -SALOME_ADD_SPHINX_DOC( html git_doc ${CMAKE_CURRENT_SOURCE_DIR}) +SALOME_ADD_SPHINX_DOC( html git_doc ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) # Install rules # ========== diff --git a/dev/git/conf.py b/dev/git/conf.py.in similarity index 100% rename from dev/git/conf.py rename to dev/git/conf.py.in -- 2.39.2