diff --git a/Code/Mantid/docs/CMakeLists.txt b/Code/Mantid/docs/CMakeLists.txt index 6bb594dc56c88bdf9c24571520361d41cff8a152..b6a1bed994091806723448cade0d09b651f18ab7 100644 --- a/Code/Mantid/docs/CMakeLists.txt +++ b/Code/Mantid/docs/CMakeLists.txt @@ -1,3 +1,31 @@ +############################################################################### +# Sphinx documentation +############################################################################### +find_package ( Sphinx ) + +if ( SPHINX_FOUND ) + # Fill in the config file and autogen file with build information + + # We generate a target per build type, i.e docs-html + set ( SPHINX_BUILD ${CMAKE_BINARY_DIR}/docs ) + set ( BUILDER html ) + configure_file ( runsphinx.py.in runsphinx_html.py @ONLY ) + + # targets + set ( TARGET_PREFIX docs) + + # HTML target + add_custom_target ( ${TARGET_PREFIX}-html + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MantidPlot -xq runsphinx_html.py + COMMENT "Build Sphinx html documentation" + ) + +endif () + + +############################################################################### +# QtAssistant +############################################################################### if ( APPLE ) set ( ENABLE_QTASSISTANT False CACHE BOOL "Build qt-assistant documentation" ) else () diff --git a/Code/Mantid/docs/runsphinx.py.in b/Code/Mantid/docs/runsphinx.py.in new file mode 100644 index 0000000000000000000000000000000000000000..d675706b98195543b3a5d3212907ea6a8ecf915f --- /dev/null +++ b/Code/Mantid/docs/runsphinx.py.in @@ -0,0 +1,21 @@ +"""We need to run Sphinx inside MantidPlot to document the internal + module. This script calls the sphinx entry point with the necessary + arguments +""" + +__requires__ = 'Sphinx' +import sys +import os +from pkg_resources import load_entry_point + +mantidplot = "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/MantidPlot" +builder = "@BUILDER@" +src_dir = "@CMAKE_CURRENT_SOURCE_DIR@/source" +output_dir = os.path.join("@SPHINX_BUILD@", builder) +argv = [mantidplot,'-b', builder, src_dir, output_dir] + +if __name__ == '__main__': + sys.exit( + load_entry_point(__requires__, 'console_scripts', 'sphinx-build')(argv) + ) +