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

Disable screenshot generating in doc-test mode.

They are not necessary and they slow down the build quite considerably.
Refs #9562
parent 99ea59ff
Branches parallel_systemtests_devdocs
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ if ( SPHINX_FOUND )
# doctest target
set ( BUILDER doctest )
set ( SCREENSHOTS_DIR "" ) # no screenshots
configure_file ( runsphinx.py.in runsphinx_doctest.py @ONLY )
add_custom_target ( ${TARGET_PREFIX}-test
COMMAND ${DOCS_RUNNER_EXE} -xq runsphinx_doctest.py
......
......@@ -6,7 +6,9 @@ import os
import sys
# set environment
os.environ["SCREENSHOTS_DIR"] = "@SCREENSHOTS_DIR@"
screenshots_dir = "@SCREENSHOTS_DIR@"
if screenshots_dir != "":
os.environ["SCREENSHOTS_DIR"] = screenshots_dir
builder = "@BUILDER@"
src_dir = "@CMAKE_CURRENT_SOURCE_DIR@/source"
......
......@@ -108,18 +108,23 @@ class AlgorithmDirective(BaseDirective):
Returns:
str: The full path to the created image
"""
from mantiddoc.tools.screenshot import algorithm_screenshot
notfoundimage = "/images/ImageNotFound.png"
try:
screenshots_dir = self._screenshot_directory()
except RuntimeError:
return notfoundimage
env = self.state.document.settings.env
screenshots_dir = self._screenshot_directory()
# Generate image
from mantiddoc.tools.screenshot import algorithm_screenshot
if not os.path.exists(screenshots_dir):
os.makedirs(screenshots_dir)
try:
imgpath = algorithm_screenshot(self.algorithm_name(), screenshots_dir, version=self.algorithm_version())
except Exception, exc:
env = self.state.document.settings.env
env.warn(env.docname, "Unable to generate screenshot for '%s' - %s" % (algorithm_name, str(exc)))
imgpath = os.path.join(screenshots_dir, "ImageNotFound.png")
imgpath = notfoundimage
return imgpath
......@@ -144,13 +149,18 @@ class AlgorithmDirective(BaseDirective):
filename = os.path.split(img_path)[1]
cfgdir = env.srcdir
screenshots_dir = self._screenshot_directory()
rel_path = os.path.relpath(screenshots_dir, cfgdir)
# This is a href link so is expected to be in unix style
rel_path = rel_path.replace("\\","/")
# stick a "/" as the first character so Sphinx computes relative location from source directory
path = "/" + rel_path + "/" + filename
try:
screenshots_dir = self._screenshot_directory()
rel_path = os.path.relpath(screenshots_dir, cfgdir)
# This is a href link so is expected to be in unix style
rel_path = rel_path.replace("\\","/")
# stick a "/" as the first character so Sphinx computes relative location from source directory
path = "/" + rel_path + "/" + filename
except RuntimeError:
# Use path as it is
path = img_path
caption = "A screenshot of the **" + self.algorithm_name() + "** dialog."
self.add_rst(format_str % (path, caption))
......
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