diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 64f0f835eb9f53aead5a77396a8e437e3515a0c1..b6f2acd2c0203d75e104eb4d5ad4a32b8629335b 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -29,7 +29,78 @@ set(DOXYGEN_DOT_TRANSPARENT YES) set(DOXYGEN_GENERATE_HTML YES) set(DOXYGEN_GENERATE_MAN NO) + +set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen) +set(MIXED_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mixedout) +set(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(SPHINX_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sphinx) + + doxygen_add_docs( sass-doxygen-docs ${PROJECT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Generates doxygen documentation" ) + +find_program( + SPHINX_EXECUTABLE + NAMES sphinx-build + DOC "Path to sphinx-build executable" +) + +if(NOT SPHINX_EXECUTABLE) + message(FATAL_ERROR "SASS_BUILD_DOCS or BUILD_DOCS was requested but Sphinx could not be found. " + "Install sphinx and its modules, or re-run CMake with doc building disabled.") +endif() + +# Install doxysphinx, used to convert Doxygen's output to markdown +find_program(DOXYSPHINX_EXECUTABLE doxysphinx) +if(NOT DOXYSPHINX_EXECUTABLE) + message( + FATAL_ERROR + "\ndoxysphinx (a Doxygen HTML to reStructureText converter) could not be found. " + "This tool is required to build the API documentation. Consider installing it by " + "following the directions at https://boschglobal.github.io/doxysphinx/docs/getting_started.html." + ) +endif() + +file(GLOB _sphinx_sources *.rst) +# add_custom_command( +# OUTPUT docs-sphinx +# COMMAND ${SPHINX_EXECUTABLE} -b html -d _build/doctrees . _build/html +# COMMENT "Building HTML documentation with Sphinx" +# ) + +file(GLOB _top_level_rst_and_md_files *.md *.rst) +add_custom_command( + OUTPUT docs-sass-doxysphinx + # Copy Sphinx sources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/sphinx ${MIXED_OUTPUT_DIRECTORY}/sphinx/docs + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_top_level_rst_and_md_files} ${MIXED_OUTPUT_DIRECTORY}/sphinx/docs + # Copy Doxygen sources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${DOXYGEN_OUTPUT_DIRECTORY} ${MIXED_OUTPUT_DIRECTORY}/sphinx/docs/doxygen + # Run doxysphinx to convert Doxygen output into Sphinx compatible output. + COMMAND ${DOC_PYTHON_ENV} ${DOXYSPHINX_EXECUTABLE} build ${MIXED_OUTPUT_DIRECTORY}/sphinx/docs + ${SPHINX_OUTPUT_DIRECTORY} ${MIXED_OUTPUT_DIRECTORY}/sphinx/docs/doxygen/html + # Call to run Doxygen prior to this block + DEPENDS sass-doxygen-docs + WORKING_DIRECTORY ${DOXYGEN_OUTPUT_DIRECTORY} + COMMENT "Preparing Sphinx and Doxygen files for merging" +) + +# Build Sphinx documentation +add_custom_command( + OUTPUT docs-sass-sphinx + COMMAND ${DOC_PYTHON_ENV} ${Python3_EXECUTABLE} ${SPHINX_EXECUTABLE} -b html ${MIXED_OUTPUT_DIRECTORY}/sphinx/docs + ${SPHINX_OUTPUT_DIRECTORY} -c ${CMAKE_CURRENT_LIST_DIR}/sphinx -Wj auto + WORKING_DIRECTORY ${MIXED_OUTPUT_DIRECTORY}/sphinx/docs + DEPENDS docs-sass-doxysphinx + MAIN_DEPENDENCY ${CMAKE_CURRENT_LIST_DIR}/sphinx/conf.py + COMMENT "Generating documentation with Sphinx" +) + +# Auto start generating documentation as part of ALL +add_custom_target( + docs-sass ALL + DEPENDS docs-sass-sphinx + COMMENT "Starting to generate Sphinx documentation." +) diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..4fa685731d1375b5a491c3bb34a882431ccfa612 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,4 @@ +Sassena +====== + +*Sassena* docs generated by sphinx