diff --git a/Code/Mantid/docs/CMakeLists.txt b/Code/Mantid/docs/CMakeLists.txt index 44bd148403bff37c23b6163ec9b011de68c49f40..7977024b073fe7e2ab8d22fe8d9edd89180325f7 100644 --- a/Code/Mantid/docs/CMakeLists.txt +++ b/Code/Mantid/docs/CMakeLists.txt @@ -35,12 +35,14 @@ if ( SPHINX_FOUND ) # qt-assistant target if (QT_QCOLLECTIONGENERATOR_EXECUTABLE) set ( BUILDER qthelp ) + set ( SPHINX_CONF_DIR ${SPHINX_BUILD_DIR}/conf/${BUILDER} ) + configure_file ( conf.py.in ${SPHINX_CONF_DIR}/conf.py @ONLY ) configure_file ( runsphinx.py.in runsphinx_qthelp.py @ONLY ) add_custom_command ( OUTPUT qthelp/MantidProject.qhcp qthelp/MantidProject.qhp COMMAND ${DOCS_RUNNER_EXE} -xq runsphinx_qthelp.py - DEPENDS Framework MantidPlot + DEPENDS Framework MantidPlot ${CMAKE_CURRENT_BINARY_DIR}/runsphinx_qthelp.py COMMENT "Building qt-assistant index files") add_custom_command ( OUTPUT qthelp/MantidProject.qhc @@ -49,7 +51,7 @@ if ( SPHINX_FOUND ) COMMENT "Compiling qt-assistant documentation") add_custom_target ( ${TARGET_PREFIX}-qthelp - DEPENDS qthelp/MantidProject.qhc ) + DEPENDS qthelp/MantidProject.qhc ${SPHINX_CONF_DIR}/conf.py conf-qthelp.py ) # Group within VS and exclude from whole build set_target_properties ( ${TARGET_PREFIX}-qthelp PROPERTIES FOLDER "Documentation" @@ -64,10 +66,12 @@ if ( SPHINX_FOUND ) option (DOCS_HTML "Add target for building html docs" OFF) if (DOCS_HTML) set ( BUILDER html ) + set ( SPHINX_CONF_DIR ${SPHINX_BUILD_DIR}/conf/${BUILDER} ) + configure_file ( conf.py.in ${SPHINX_CONF_DIR}/conf.py @ONLY ) configure_file ( runsphinx.py.in runsphinx_html.py @ONLY ) add_custom_target ( ${TARGET_PREFIX}-html COMMAND ${DOCS_RUNNER_EXE} -xq runsphinx_html.py - DEPENDS Framework MantidPlot + DEPENDS Framework MantidPlot ${CMAKE_CURRENT_BINARY_DIR}/runsphinx_html.py ${SPHINX_CONF_DIR}/conf.py conf-html.py COMMENT "Building html documentation" ) # Group within VS and exclude from whole build @@ -78,10 +82,12 @@ if ( SPHINX_FOUND ) # doctest target set ( BUILDER doctest ) + set ( SPHINX_CONF_DIR ${SPHINX_BUILD_DIR}/conf/${BUILDER} ) + configure_file ( conf.py.in ${SPHINX_CONF_DIR}/conf.py @ONLY ) configure_file ( runsphinx.py.in runsphinx_doctest.py @ONLY ) add_custom_target ( ${TARGET_PREFIX}-test COMMAND ${DOCS_RUNNER_EXE} -xq runsphinx_doctest.py - DEPENDS Framework MantidPlot + DEPENDS Framework MantidPlot ${CMAKE_CURRENT_BINARY_DIR}/runsphinx_doctest.py ${SPHINX_CONF_DIR}/conf.py COMMENT "Running documentation tests" ) # Group within VS and exclude from whole build diff --git a/Code/Mantid/docs/conf-html.py b/Code/Mantid/docs/conf-html.py new file mode 100644 index 0000000000000000000000000000000000000000..116aae3b898aeb6ed888d8288ad66fe39a42ea23 --- /dev/null +++ b/Code/Mantid/docs/conf-html.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# All configuration values have a default; values that are commented out +# serve to show the default. +# +# Options here are applied and assumed to be those required when the builder is set the "html". +# For common options see conf.py.in. This file is presumed to be "execfiled" by the main conf.py.in + +# -- Override options for non-embedded standalone HTML output -------------------------------------------- + +# Theme-specific options to customize the look and feel of a theme. +# We config the bootstrap settings here, and apply CSS changes in +# custom.css rather than here. +html_theme_options = { + # Navigation bar title. + 'navbar_title': " ", # deliberate single space so it's not visible + # Tab name for entire site. + 'navbar_site_name': "Mantid", + # Add links to the nav bar. Third param of tuple is true to create absolute url. + 'navbar_links': [ + ("Home", "http://www.mantidproject.org", True), + ("Download", "http://download.mantidproject.org", True), + ("Documentation", "http://www.mantidproject.org/Documentation", True), + ("Contact Us", "http://www.mantidproject.org/Contact", True), + ], + # Do not show the "Show source" button. + 'source_link_position': "no", + # Remove the local TOC from the nav bar + 'navbar_pagenav': False, + # Hide the next/previous in the nav bar. + 'navbar_sidebarrel': False, + # Use the latest version. + 'bootstrap_version': "3", + # Ensure the nav bar always stays on top of page. + 'navbar_fixed_top': "false", +} diff --git a/Code/Mantid/docs/conf-qthelp.py b/Code/Mantid/docs/conf-qthelp.py new file mode 100644 index 0000000000000000000000000000000000000000..2c19289dc7be30dc1ac1fc1b0b90608d4b4a2844 --- /dev/null +++ b/Code/Mantid/docs/conf-qthelp.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# All configuration values have a default; values that are commented out +# serve to show the default. +# +# Options here are applied and assumed to be those required when the builder is set the "html". +# For common options see conf.py.in. This file is presumed to be "execfiled" by the main conf.py.in + +# -- Override options for non-embedded standalone HTML output -------------------------------------- + +# Theme-specific options to customize the look and feel of a theme. +# We config the bootstrap settings here, and apply CSS changes in +# custom.css rather than here. +html_theme_options = { + # Navigation bar title. + 'navbar_title': " ", # deliberate single space so it's not visible + # Tab name for entire site. + 'navbar_site_name': "Mantid", + # Add links to the nav bar. Third param of tuple is true to create absolute url. + 'navbar_links': [ + ], + # Do not show the "Show source" button. + 'source_link_position': "no", + # Remove the local TOC from the nav bar + 'navbar_pagenav': False, + # Hide the next/previous in the nav bar. + 'navbar_sidebarrel': False, + # Use the latest version. + 'bootstrap_version': "3", + # Ensure the nav bar always stays on top of page. + 'navbar_fixed_top': "false", +} diff --git a/Code/Mantid/docs/source/conf.py b/Code/Mantid/docs/conf.py.in similarity index 77% rename from Code/Mantid/docs/source/conf.py rename to Code/Mantid/docs/conf.py.in index 9a82e49c4e80f31d5c604718d48d70be10ea0f60..d14a6708c06647a2d1dc6f385f85d3812a143f1c 100644 --- a/Code/Mantid/docs/source/conf.py +++ b/Code/Mantid/docs/conf.py.in @@ -1,3 +1,4 @@ +# -*- mode: python -*- # -*- coding: utf-8 -*- # All configuration values have a default; values that are commented out # serve to show the default. @@ -15,7 +16,7 @@ except ImportError: # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('../sphinxext')) +sys.path.insert(0, '@CMAKE_CURRENT_SOURCE_DIR@/sphinxext') # -- General configuration ------------------------------------------------ @@ -45,7 +46,7 @@ extensions = [ # pass # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ['@CMAKE_CURRENT_SOURCE_DIR@/source/_templates'] # The suffix of source filenames. source_suffix = '.rst' @@ -92,39 +93,27 @@ pngmath_latex_preamble=r'\usepackage[active]{preview}' # See http://sphinx-doc.org/ext/math.html#confval-pngmath_use_preview pngmath_use_preview = True -# -- Options for HTML output ---------------------------------------------- +# -- Options for sphinxcontrib-doxylink output --------------------------------- + +# Need to figure out best way to get at the build directory. It would be nice +# if we didn't have to make this a file generated by CMake +#doxylink = { 'mantidcpp' : ('@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/../Framework/Doxygen/Mantid.tag', +# 'http://doxygen.mantidproject.org/') } + +# -- Options for breathe output ------------------------------------------------ + +#breathe_projects = { +# "mantid" : "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/../doxygen/xml/" +#} +#breathe_default_project = "mantid" + +# -- Common options HTML output -------------------------------------------- +# May be overridden in a conf-BUILDER.py file # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'bootstrap' -# Theme-specific options to customize the look and feel of a theme. -# We config the bootstrap settings here, and apply CSS changes in -# custom.css rather than here. -html_theme_options = { - # Navigation bar title. - 'navbar_title': " ", # deliberate single space so it's not visible - # Tab name for entire site. - 'navbar_site_name': "Mantid", - # Add links to the nav bar. Second param of tuple is true to create absolute url. - 'navbar_links': [ - ("Home", "http://www.mantidproject.org", True), - ("Download", "http://download.mantidproject.org", True), - ("Documentation", "http://www.mantidproject.org/Documentation", True), - ("Contact Us", "http://www.mantidproject.org/Contact", True), - ], - # Do not show the "Show source" button. - 'source_link_position': "no", - # Remove the local TOC from the nav bar - 'navbar_pagenav': False, - # Hide the next/previous in the nav bar. - 'navbar_sidebarrel': False, - # Use the latest version. - 'bootstrap_version': "3", - # Ensure the nav bar always stays on top of page. - 'navbar_fixed_top': "true", -} - # Add any paths that contain custom themes here, relative to this directory. html_theme_path = sphinx_bootstrap_theme.get_html_theme_path() @@ -134,12 +123,12 @@ html_title = "" # The name of an image file (relative to this directory) to place at the top # of the sidebar. -html_logo = os.path.relpath('../../Images/Mantid_Logo_Transparent.png') +html_logo = os.path.relpath('@CMAKE_CURRENT_SOURCE_DIR@/../Images/Mantid_Logo_Transparent.png') # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ['@CMAKE_CURRENT_SOURCE_DIR@/source/_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied @@ -156,16 +145,10 @@ html_show_sphinx = False # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. html_show_copyright = True -# -- Options for sphinxcontrib-doxylink output --------------------------------- -# Need to figure out best way to get at the build directory. It would be nice -# if we didn't have to make this a file generated by CMake -#doxylink = { 'mantidcpp' : ('@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/../Framework/Doxygen/Mantid.tag', -# 'http://doxygen.mantidproject.org/') } +# -- Options for selected builder output --------------------------------------- -# -- Options for breathe output ------------------------------------------------ - -#breathe_projects = { -# "mantid" : "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/../doxygen/xml/" -#} -#breathe_default_project = "mantid" +# Place in a separate file for clarity +builder_options_file = "@CMAKE_CURRENT_SOURCE_DIR@/conf-@BUILDER@.py" +if os.path.exists(builder_options_file): + execfile(builder_options_file) diff --git a/Code/Mantid/docs/runsphinx.py.in b/Code/Mantid/docs/runsphinx.py.in index 28f117aede4d0707543b633f0b13f3246ccfa523..7c5cebe99963e17fc0832adb659060855de820c6 100644 --- a/Code/Mantid/docs/runsphinx.py.in +++ b/Code/Mantid/docs/runsphinx.py.in @@ -3,21 +3,34 @@ arguments """ import os +import shutil import sys +#----------------------------------------------------------------------------------------------- +def pathjoin(left, *args): + """ + Similar to os.path.join but just uses "/" as it's populated with CMake-style paths that are + always "/" separated, even on Windows. + """ + return left + "/" + "/".join(args) +#----------------------------------------------------------------------------------------------- + # set environment screenshots_dir = "@SCREENSHOTS_DIR@" if screenshots_dir != "": os.environ["SCREENSHOTS_DIR"] = screenshots_dir +# All paths are cmake style so are "/" separated, even on Windows builder = "@BUILDER@" src_dir = "@CMAKE_CURRENT_SOURCE_DIR@/source" sphinx_build_dir = "@SPHINX_BUILD_DIR@" -output_dir = os.path.join(sphinx_build_dir, builder) -doctree_dir = os.path.join(sphinx_build_dir, "doctrees") +conf_dir = "@SPHINX_CONF_DIR@" + +output_dir = pathjoin(sphinx_build_dir, builder) +doctree_dir = pathjoin(sphinx_build_dir, "doctrees") if __name__ == "__main__": from sphinx import main - argv = [sys.executable, "-b", builder, "-d", doctree_dir, src_dir, output_dir] + argv = [sys.executable, "-b", builder, "-d", doctree_dir, "-c", conf_dir, src_dir, output_dir] sys.exit(main(argv)) diff --git a/Code/Mantid/docs/source/_static/custom.css b/Code/Mantid/docs/source/_static/custom.css index 86ec968ac188887dd9081f6b5965e280288b6a2a..76a9886d9abced4c15b1f2a5a384ba808f4a7131 100644 --- a/Code/Mantid/docs/source/_static/custom.css +++ b/Code/Mantid/docs/source/_static/custom.css @@ -21,7 +21,10 @@ a:hover { /*-------------------- $SPACING --------------------*/ body { font-size: 1.6em; } /* 16px */ -h1,h2 { margin-bottom: .5em; } + +h1{ + margin-top: 0; +} /*-------------------- $MATH ----------------------*/ diff --git a/Code/Mantid/docs/source/_templates/navbar.html b/Code/Mantid/docs/source/_templates/navbar.html index f726b0a77a56a132fc7224d4537fedf0d1bdc1aa..3990e9310cb9d8d8bcd1c7e52a7a5effef4f1e13 100644 --- a/Code/Mantid/docs/source/_templates/navbar.html +++ b/Code/Mantid/docs/source/_templates/navbar.html @@ -1,9 +1,11 @@ - {# Override the default bootstrap navbar so that the image link can go external #} - - +{# Copied from base bootstrap version and modified to: #} +{# Remove search box when in embedded mode (qthelp etc) #} +{# Point the main logo anchor to www.mantidproject.org in standard mode and the master document in embedded mode #} + <div id="navbar" class="{{ theme_navbar_class }} navbar-default {% if theme_navbar_fixed_top == 'true' -%} navbar-fixed-top{%- endif -%}"> <div class="container"> <div class="navbar-header"> + {% if (not embedded) %} <!-- .btn-navbar is used as the toggle for collapsed navbar content --> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> @@ -11,6 +13,9 @@ <span class="icon-bar"></span> </button> <a class="navbar-brand" href="http://www.mantidproject.org"> + {%- else -%} + <a class="navbar-brand" href="{{ pathto(master_doc) }}"> + {%- endif -%} {%- block sidebarlogo %} {%- if logo %}<img src="{{ pathto('_static/' + logo, 1) }}">{%- endif %} {%- endblock %} @@ -19,7 +24,11 @@ <span class="navbar-text navbar-version pull-left"><b>{{ version|e }}</b></span> </div> + {% if (not embedded) %} <div class="collapse navbar-collapse nav-collapse"> + {% else %} + <div> + {% endif %} <ul class="nav navbar-nav"> <li class="divider-vertical"></li> {% if theme_navbar_links %} @@ -44,10 +53,11 @@ <li class="hidden-sm">{% include "sourcelink.html" %}</li> {% endif %} </ul> - - {% block navbarsearch %} - {% include "navbarsearchbox.html" %} - {% endblock %} + {%- if (not embedded) -%} + {% block navbarsearch %} + {% include "navbarsearchbox.html" %} + {% endblock %} + {%- endif -%} </div> </div> </div>