docs: require specific version of doc tools

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
This commit is contained in:
Nicolas Oliver 2017-09-11 13:01:48 -07:00
parent 153d8cfb12
commit 40e73e648a
2 changed files with 60 additions and 46 deletions

View File

@ -310,55 +310,67 @@ endif()
# #
if (BUILDDOC) if (BUILDDOC)
# Add a target to generate API documentation with Doxygen # Add a target to generate API documentation with Doxygen
find_package (Doxygen REQUIRED) find_package (Doxygen 1.8 REQUIRED)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) if (DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_GREATER "1.8")
if (BUILDSWIGJAVA) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.java.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-java @ONLY) if (BUILDSWIGJAVA)
endif() configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.java.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-java @ONLY)
file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/icons/*.png) endif()
foreach(PNG_FILE ${PNG_FILES}) file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/icons/*.png)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY) foreach(PNG_FILE ${PNG_FILES})
endforeach() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY)
add_custom_target (doc endforeach()
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile add_custom_target (doc
COMMAND tar -czf html/xml.tar.gz -C xml . ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND tar -czf html/xml.tar.gz -C xml .
COMMENT "Generating API documentation with Doxygen" VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
) COMMENT "Generating API documentation with Doxygen" VERBATIM
)
else ()
message (SEND_ERROR "ERROR - Failed to find a compatible version of Doxygen. API doc will not be generated")
endif (DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_GREATER "1.8")
# Check if Sphinx is installed and add target to generate API documentation # Check if Sphinx is installed and add target to generate API documentation
# Currently, the per-module documentation for python is generated from the # Currently, the per-module documentation for python is generated from the
# python2 modules. # python2 modules.
if(BUILDSWIGPYTHON) if(BUILDSWIGPYTHON)
find_package (Sphinx REQUIRED) find_package (Sphinx 1.3 REQUIRED)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/pydoc/conf.py @ONLY) if (SPHINX_FOUND AND SPHINX_VERSION VERSION_GREATER "1.3")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/index.rst ${CMAKE_CURRENT_BINARY_DIR}/pydoc/index.rst COPYONLY) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/pydoc/conf.py @ONLY)
add_custom_target (pydoc ALL configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/index.rst ${CMAKE_CURRENT_BINARY_DIR}/pydoc/index.rst COPYONLY)
COMMAND rm -r -f ${CMAKE_BINARY_DIR}/pyupm && mkdir -p ${CMAKE_BINARY_DIR}/pyupm add_custom_target (pydoc ALL
COMMAND find ${CMAKE_BINARY_DIR}/src -name "_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \; COMMAND rm -r -f ${CMAKE_BINARY_DIR}/pyupm && mkdir -p ${CMAKE_BINARY_DIR}/pyupm
COMMAND find ${CMAKE_BINARY_DIR}/src -name "pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \; COMMAND find ${CMAKE_BINARY_DIR}/src -name "_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
COMMAND ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/pyupm COMMAND find ${CMAKE_BINARY_DIR}/src -name "pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
# TODO: use a separate cmake FILE module for string replacement instead COMMAND ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/pyupm
COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python # TODO: use a separate cmake FILE module for string replacement instead
COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python
COMMAND sed -i.bak s|[[:space:]][mM]odule</a>|</a>|g html/python/index.html html/python/modules.html COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html
DEPENDS doc COMMAND sed -i.bak s|[[:space:]][mM]odule</a>|</a>|g html/python/index.html html/python/modules.html
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS doc
COMMENT "Generating API documentation with Sphinx" VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
) COMMENT "Generating API documentation with Sphinx" VERBATIM
)
else ()
message (SEND_ERROR "ERROR - Failed to find a compatible version of Sphinx. Python API doc will not be generated")
endif ()
endif(BUILDSWIGPYTHON) endif(BUILDSWIGPYTHON)
# Check if Yuidoc is installed and add target for API documentation # Check if Yuidoc is installed and add target for API documentation
if(BUILDSWIGNODE) if(BUILDSWIGNODE)
find_package(Yuidoc REQUIRED) find_package (Yuidoc 0.10 REQUIRED)
add_custom_target(jsdoc ALL if (YUIDOC_FOUND AND YUIDOC_VERSION VERSION_GREATER "0.10")
COMMAND ${CMAKE_SOURCE_DIR}/doxy/doxygen2jsdoc/docgen.js -m upm -i xml -o jsdoc -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../ add_custom_target (jsdoc ALL
COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers ${CMAKE_SOURCE_DIR}/doxy/node/generators/yuidoc/helper.js --themedir ${CMAKE_SOURCE_DIR}/doxy/node/generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm COMMAND ${CMAKE_SOURCE_DIR}/doxy/doxygen2jsdoc/docgen.js -m upm -i xml -o jsdoc -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
COMMAND ${CMAKE_SOURCE_DIR}/doxy/doxygen2jsdoc/tolower.js -i html/node COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers ${CMAKE_SOURCE_DIR}/doxy/node/generators/yuidoc/helper.js --themedir ${CMAKE_SOURCE_DIR}/doxy/node/generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm
DEPENDS doc COMMAND ${CMAKE_SOURCE_DIR}/doxy/doxygen2jsdoc/tolower.js -i html/node
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS doc
COMMENT "Generating API documentation with Yuidoc" VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
) COMMENT "Generating API documentation with Yuidoc" VERBATIM
)
else ()
message (SEND_ERROR "ERROR - Failed to find a compatible version of Yuidoc. Node.js API doc will not be generated")
endif ()
endif(BUILDSWIGNODE) endif(BUILDSWIGNODE)
endif (BUILDDOC) endif (BUILDDOC)

View File

@ -17,14 +17,16 @@ find_package_handle_standard_args (Sphinx DEFAULT_MSG
SPHINX_API_EXECUTABLE SPHINX_API_EXECUTABLE
) )
# Get Sphinx version # Get Sphinx Version
if (SPHINX_EXECUTABLE) if (SPHINX_EXECUTABLE)
execute_process(COMMAND ${SPHINX_EXECUTABLE} --version execute_process(COMMAND ${SPHINX_EXECUTABLE} --version
OUTPUT_VARIABLE SPHINX_VERSION) OUTPUT_VARIABLE SPHINX_VERSION_STRING
if(SPHINX_VERSION) OUTPUT_STRIP_TRAILING_WHITESPACE
string(REGEX MATCH "([0-9]\\.[0-9]\\.[0-9])" SPHINX_VERSION_STR ${SPHINX_VERSION}) ERROR_STRIP_TRAILING_WHITESPACE)
message (STATUS "Sphinx version is ${SPHINX_VERSION_STR}") if (SPHINX_VERSION_STRING)
endif() string(REPLACE "Sphinx (sphinx-build) " "" SPHINX_VERSION ${SPHINX_VERSION_STRING})
message (STATUS "Sphinx version is ${SPHINX_VERSION}")
endif ()
endif () endif ()
mark_as_advanced (SPHINX_EXECUTABLE) mark_as_advanced (SPHINX_EXECUTABLE)