diff --git a/Code/Mantid/docs/CMakeLists.txt b/Code/Mantid/docs/CMakeLists.txt
index af0d90065514bc04746a954545c44403e6cf1590..0a2cf07e029ac831a3ece0a94cf2d936ef546dcc 100644
--- a/Code/Mantid/docs/CMakeLists.txt
+++ b/Code/Mantid/docs/CMakeLists.txt
@@ -26,10 +26,7 @@ if ( SPHINX_FOUND )
   set ( SPHINX_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source )
   set ( SPHINX_BUILD_DIR ${DOCS_BUILDDIR} )
   set ( SCREENSHOTS_DIR ${SPHINX_BUILD_DIR}/screenshots )
-
-  file ( GLOB DIAGRAMS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/source/diagrams/*.dot" )
-  set ( DIAGRAMS_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/generate_diagrams.py )
-  set ( DIAGRAMS_OUT_DIR ${SPHINX_BUILD_DIR}/diagrams )
+  set ( DIAGRAMS_DIR ${SPHINX_BUILD_DIR}/diagrams )
 
   # targets
   set ( TARGET_PREFIX docs)
@@ -40,12 +37,6 @@ if ( SPHINX_FOUND )
     set ( DOCS_RUNNER_EXE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/MantidPlot )
   endif()
 
-  #Generate diagrams from .dot files
-  add_custom_target ( ${TARGET_PREFIX}-diagrams
-    COMMAND ${PYTHON_EXECUTABLE} ${DIAGRAMS_SCRIPT} -x ${DOT_EXECUTABLE} ${DIAGRAMS_OUT_DIR} ${DIAGRAMS_SRC}
-    SOURCES ${DIAGRAMS_SCRIPT} ${DIAGRAMS_SRC}
-    COMMENT "Generating .dot diagrams")
-
   # qthelp target
   if (QT_QCOLLECTIONGENERATOR_EXECUTABLE)
     set ( BUILDER qthelp )
diff --git a/Code/Mantid/docs/runsphinx.py.in b/Code/Mantid/docs/runsphinx.py.in
index c6559613786ce613a51156a59e751ae05537c0eb..79e23e6bfe97e1aad6648eaa5f11fbbcedb0e330 100644
--- a/Code/Mantid/docs/runsphinx.py.in
+++ b/Code/Mantid/docs/runsphinx.py.in
@@ -17,6 +17,8 @@ SRC_DIR = "@SPHINX_SRC_DIR@"
 CONF_DIR = "@SPHINX_CONF_DIR@"
 SPHINX_BUILD_DIR = "@SPHINX_BUILD_DIR@"
 SCREENSHOTS_DIR = "@SCREENSHOTS_DIR@"
+DIAGRAMS_DIR = "@DIAGRAMS_DIR@"
+DOT_EXECUTABLE = "@DOT_EXECUTABLE@"
 
 ###############################################################################
 # Main
@@ -46,6 +48,12 @@ def main(sysarg):
     if SCREENSHOTS_DIR != "":
         os.environ["SCREENSHOTS_DIR"] = SCREENSHOTS_DIR
 
+    if DIAGRAMS_DIR != "":
+        os.environ["DIAGRAMS_DIR"] = DIAGRAMS_DIR
+
+    if DOT_EXECUTABLE != "":
+        os.environ["DOT_EXECUTABLE"] = DOT_EXECUTABLE
+
     # Arguments for main
     output_dir = pathjoin(SPHINX_BUILD_DIR, BUILDER)
     doctree_dir = pathjoin(SPHINX_BUILD_DIR, "doctrees")
diff --git a/Code/Mantid/docs/source/algorithms/ReflectometryReductionOne-v1.rst b/Code/Mantid/docs/source/algorithms/ReflectometryReductionOne-v1.rst
index 5f54d03a2bc43ccd79703d0133f8e6c8024168ad..5049a19eb382d2f1683741e25364d0cdad74b814 100644
--- a/Code/Mantid/docs/source/algorithms/ReflectometryReductionOne-v1.rst
+++ b/Code/Mantid/docs/source/algorithms/ReflectometryReductionOne-v1.rst
@@ -20,7 +20,7 @@ script.
 Workflow
 ########
 
-.. image:: ../images/ReflectometryReductionOne-Workflow.png
+.. diagram:: ReflectometryReductionOne
 
 Analysis Modes
 ##############
diff --git a/Code/Mantid/docs/source/algorithms/ReflectometryReductionOneAuto-v1.rst b/Code/Mantid/docs/source/algorithms/ReflectometryReductionOneAuto-v1.rst
index 066776b0f6db191450dd79847b2eb208cd95938e..30947ebe624f77321d017fc61e188207c8960210 100644
--- a/Code/Mantid/docs/source/algorithms/ReflectometryReductionOneAuto-v1.rst
+++ b/Code/Mantid/docs/source/algorithms/ReflectometryReductionOneAuto-v1.rst
@@ -26,7 +26,7 @@ Workflow for WorkspaceGroups
 
 If a WorkspaceGroup is provided to ReflectometryReductionOneAuto, it will follow the steps shown in the diagram below to produce its output.
 
-.. image:: ../images/ReflectometryReductionOneAuto-Groups.png
+.. diagram:: ReflectometryReductionOneAuto-Groups
 
 Workflow for Polarization Correction
 ####################################
@@ -34,7 +34,7 @@ Workflow for Polarization Correction
 If polarization correction is enabled, it is performed as an additional step once the main processing has completed.
 The following diagram shows how the :ref:`algm-PolarizationCorrection` algorithm is used.
 
-.. image:: ../images/ReflectometryReductionOneAuto-Groups.png
+.. diagram:: ReflectometryReductionOneAuto-PolarizationCorrection
 
 Usage
 -----
diff --git a/Code/Mantid/docs/sphinxext/mantiddoc/directives/__init__.py b/Code/Mantid/docs/sphinxext/mantiddoc/directives/__init__.py
index 58dda55dc5ff7da61adde5abe573e269fc3b035b..6eae3ae3c18436c2c56e1b2cd5dfb9f2cffe4ed8 100644
--- a/Code/Mantid/docs/sphinxext/mantiddoc/directives/__init__.py
+++ b/Code/Mantid/docs/sphinxext/mantiddoc/directives/__init__.py
@@ -7,7 +7,7 @@
    'mantiddoc.directives' to be added to the Sphinx extensions configuration.
 """
 
-import algorithm, alias, attributes, categories, interface, properties, summary
+import algorithm, alias, attributes, categories, diagram, interface, properties, summary
 
 def setup(app):
     """
@@ -20,6 +20,7 @@ def setup(app):
     alias.setup(app)
     attributes.setup(app)
     categories.setup(app)
+    diagram.setup(app)
     interface.setup(app)
     properties.setup(app)
     summary.setup(app)
diff --git a/Code/Mantid/docs/sphinxext/mantiddoc/directives/diagram.py b/Code/Mantid/docs/sphinxext/mantiddoc/directives/diagram.py
new file mode 100644
index 0000000000000000000000000000000000000000..b1e981f8353c269d484bb7fdb0838661e7393268
--- /dev/null
+++ b/Code/Mantid/docs/sphinxext/mantiddoc/directives/diagram.py
@@ -0,0 +1,97 @@
+from base import BaseDirective
+from sphinx.locale import _
+import os, string, subprocess
+
+######################
+#CONFIGURABLE OPTIONS#
+######################
+
+STYLE = dict()
+
+STYLE["global_style"] = """
+fontname = Helvetica
+labelloc = t
+node[fontname="Helvetica", style = filled]
+edge[fontname="Helvetica"]
+"""
+
+STYLE['param_style']     = 'node[fillcolor = khaki, shape = oval]'
+STYLE['decision_style']  = 'node[fillcolor = limegreen, shape = diamond]'
+STYLE['algorithm_style'] = 'node[style = "rounded,filled", fillcolor = lightskyblue, shape = rectangle]'
+STYLE['process_style']   = 'node[fillcolor = lightseagreen, shape = rectangle]'
+STYLE['value_style']     = 'node[fontname = "Times-Roman", fillcolor = grey, shape = parallelogram]'
+
+#############################
+#END OF CONFIGURABLE OPTIONS#
+#############################
+
+
+class DiagramDirective(BaseDirective):
+
+    """
+    Adds a diagram from a dot source file
+
+    It requires a DIAGRAMS_DIR environment variable to be set to the
+    directory where a diagram should be generated. If it is not set then
+    a RuntimeError occurs
+    """
+
+    required_arguments, optional_arguments = 1, 0
+
+    def run(self):
+        """
+        The main entry point that docutils calls.
+        It calls self.execute to do the main work.
+        Derived classes should override execute() and insert
+        whatever rst they require with self.add_rst()
+        """
+        nodes = self.execute()
+        if self.rst_lines is not None:
+            self.commit_rst()
+        return nodes
+
+    def execute(self):
+        env = self.state.document.settings.env
+
+        try:
+            out_dir = os.environ["DIAGRAMS_DIR"]
+        except:
+            raise RuntimeError("The '.. diagram::' directive requires a DIAGRAMS_DIR environment variable to be set.")
+
+        try:
+            dot_executable = os.environ["DOT_EXECUTABLE"]
+        except:
+            raise RuntimeError("The '.. diagram::' directive requires a DIAGRAMS_DIR environment variable to be set.")
+
+        #Make sure we have an output directory
+        if not os.path.exists(out_dir):
+            os.makedirs(out_dir)
+
+        diagram_name = self.arguments[0]
+        in_path = os.path.join(env.srcdir, "diagrams", diagram_name + ".dot")
+        out_path = os.path.join(out_dir, diagram_name + ".png")
+
+        #Generate the diagram
+        in_src = open(in_path, 'r').read()
+        out_src = string.Template(in_src).substitute(STYLE)
+        gviz = subprocess.Popen([dot_executable,"-Tpng","-o",out_path], stdin=subprocess.PIPE)
+        gviz.communicate(input=out_src)
+        gviz.wait()
+
+        #relative path to image, in unix style
+        rel_path = os.path.relpath(out_path, env.srcdir).replace("\\","/")
+
+        self.add_rst(".. image:: /" + rel_path + "\n\n")
+
+        return []
+
+#------------------------------------------------------------------------------------------------------------
+
+def setup(app):
+    """
+    Setup the directives when the extension is activated
+
+    Args:
+      app: The main Sphinx application object
+    """
+    app.add_directive('diagram', DiagramDirective)