Skip to content
Snippets Groups Projects
Commit 2feb4bd5 authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony
Browse files

Refs #4411. Add a latex (for a pdf) target to sphinx.

The output PDF is not ideal at the moment but it is a start.
parent 301f0b8d
No related branches found
No related tags found
No related merge requests found
...@@ -8,8 +8,16 @@ find_package ( Sphinx ) ...@@ -8,8 +8,16 @@ find_package ( Sphinx )
if ( SPHINX_FOUND ) if ( SPHINX_FOUND )
# Fill in the config file and autogen file with build information # Fill in the config file and autogen file with build information
configure_file ( source/conf.py.in source/conf.py @ONLY ) configure_file ( source/conf.py.in source/conf.py @ONLY )
configure_file ( autogen_api.py.in autogen_api.py @ONLY ) configure_file ( autogen_api.py.in autogen_api.py @ONLY )
configure_file ( runsphinx.py.in runsphinx.py @ONLY )
# Two builders are required
set ( TARGET_NAME sphinx )
set ( SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/../../../${TARGET_NAME} )
set ( BUILDER html )
configure_file ( runsphinx.py.in runsphinx_html.py @ONLY )
set ( BUILDER latex )
configure_file ( runsphinx.py.in runsphinx_latex.py @ONLY )
# Sphinx seems to require the config file to be next to the rest of the source # Sphinx seems to require the config file to be next to the rest of the source
# files meaning we need to copy everything over to the build directory # files meaning we need to copy everything over to the build directory
...@@ -34,13 +42,31 @@ if ( SPHINX_FOUND ) ...@@ -34,13 +42,31 @@ if ( SPHINX_FOUND )
set ( SPHINX_CONF_FILES ${SPHINX_CONF_FILES} ${out_file} ) set ( SPHINX_CONF_FILES ${SPHINX_CONF_FILES} ${out_file} )
endforeach() endforeach()
set ( SPHINX_HTML_BUILD ${CMAKE_CURRENT_BINARY_DIR}/../../../python-sphinx/html )
# Sphinx is run as '${SPHINX_EXECUTABLE} -b sourcedir builddir'
add_custom_target ( python-sphinx # Both depend on the autogenerated API files
add_custom_target( ${TARGET_NAME}-generateapi
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MantidPlot -xq autogen_api.py COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MantidPlot -xq autogen_api.py
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MantidPlot -xq runsphinx.py
DEPENDS ${SPHINX_CONF_FILES} DEPENDS ${SPHINX_CONF_FILES}
COMMENT "Build Python Sphinx API documentation" COMMENT "Generating Python API for sphinx"
)
# HTML target
set ( SPHINX_HTML_BUILD ${SPHINX_BUILD}/html )
add_custom_target ( ${TARGET_NAME}-html
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MantidPlot -xq runsphinx_html.py
COMMENT "Build Sphinx html documentation"
)
add_dependencies( ${TARGET_NAME}-html ${TARGET_NAME}-generateapi )
# Latex target
set ( SPHINX_LATEX_BUILD ${SPHINX_BUILD}/latex )
add_custom_target ( ${TARGET_NAME}-latex
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MantidPlot -xq runsphinx_latex.py
COMMENT "Build Python Sphinx latex documentation"
) )
add_dependencies( ${TARGET_NAME}-latex ${TARGET_NAME}-generateapi )
endif () endif ()
...@@ -9,13 +9,13 @@ import os ...@@ -9,13 +9,13 @@ import os
from pkg_resources import load_entry_point from pkg_resources import load_entry_point
mantidplot = "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/MantidPlot" mantidplot = "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/MantidPlot"
builder = "html" builder = "@BUILDER@"
src_dir = "@CMAKE_CURRENT_BINARY_DIR@/source" src_dir = "@CMAKE_CURRENT_BINARY_DIR@/source"
output_dir = "@CMAKE_CURRENT_BINARY_DIR@/../../../python-sphinx/" + builder output_dir = os.path.join("@SPHINX_BUILD@", builder)
argv = [mantidplot,'-b', builder, src_dir, output_dir] argv = [mantidplot,'-b', builder, src_dir, output_dir]
if __name__ == '__main__': if __name__ == '__main__':
sys.exit( sys.exit(
load_entry_point('Sphinx==1.1.2', 'console_scripts', 'sphinx-build')(argv) load_entry_point('Sphinx==1.1.2', 'console_scripts', 'sphinx-build')(argv)
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment