From 6bfffcd021e9fa7515b8821068d958cb721c27a1 Mon Sep 17 00:00:00 2001 From: Harry Jeffery <henry.jeffery@stfc.ac.uk> Date: Thu, 12 Feb 2015 09:03:18 +0000 Subject: [PATCH] Refs #11054 Use descriptive filenames for diagrams --- .../algorithms/ReflectometryReductionOne-v1.rst | 2 +- .../algorithms/ReflectometryReductionOneAuto-v1.rst | 4 ++-- ...e.dot => ReflectometryReductionOne-v1_wkflw.dot} | 0 ...flectometryReductionOneAuto-v1-Groups_wkflw.dot} | 0 ...tionOneAuto-v1-PolarizationCorrection_wkflw.dot} | 0 .../docs/sphinxext/mantiddoc/directives/diagram.py | 13 ++++++++++--- 6 files changed, 13 insertions(+), 6 deletions(-) rename Code/Mantid/docs/source/diagrams/{ReflectometryReductionOne.dot => ReflectometryReductionOne-v1_wkflw.dot} (100%) rename Code/Mantid/docs/source/diagrams/{ReflectometryReductionOneAuto-Groups.dot => ReflectometryReductionOneAuto-v1-Groups_wkflw.dot} (100%) rename Code/Mantid/docs/source/diagrams/{ReflectometryReductionOneAuto-PolarizationCorrection.dot => ReflectometryReductionOneAuto-v1-PolarizationCorrection_wkflw.dot} (100%) diff --git a/Code/Mantid/docs/source/algorithms/ReflectometryReductionOne-v1.rst b/Code/Mantid/docs/source/algorithms/ReflectometryReductionOne-v1.rst index 5049a19eb38..627e6cffd41 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 ######## -.. diagram:: ReflectometryReductionOne +.. diagram:: ReflectometryReductionOne-v1_wkflw.dot Analysis Modes ############## diff --git a/Code/Mantid/docs/source/algorithms/ReflectometryReductionOneAuto-v1.rst b/Code/Mantid/docs/source/algorithms/ReflectometryReductionOneAuto-v1.rst index 30947ebe624..809be7a9328 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. -.. diagram:: ReflectometryReductionOneAuto-Groups +.. diagram:: ReflectometryReductionOneAuto-v1-Groups_wkflw.dot 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. -.. diagram:: ReflectometryReductionOneAuto-PolarizationCorrection +.. diagram:: ReflectometryReductionOneAuto-v1-PolarizationCorrection_wkflw.dot Usage ----- diff --git a/Code/Mantid/docs/source/diagrams/ReflectometryReductionOne.dot b/Code/Mantid/docs/source/diagrams/ReflectometryReductionOne-v1_wkflw.dot similarity index 100% rename from Code/Mantid/docs/source/diagrams/ReflectometryReductionOne.dot rename to Code/Mantid/docs/source/diagrams/ReflectometryReductionOne-v1_wkflw.dot diff --git a/Code/Mantid/docs/source/diagrams/ReflectometryReductionOneAuto-Groups.dot b/Code/Mantid/docs/source/diagrams/ReflectometryReductionOneAuto-v1-Groups_wkflw.dot similarity index 100% rename from Code/Mantid/docs/source/diagrams/ReflectometryReductionOneAuto-Groups.dot rename to Code/Mantid/docs/source/diagrams/ReflectometryReductionOneAuto-v1-Groups_wkflw.dot diff --git a/Code/Mantid/docs/source/diagrams/ReflectometryReductionOneAuto-PolarizationCorrection.dot b/Code/Mantid/docs/source/diagrams/ReflectometryReductionOneAuto-v1-PolarizationCorrection_wkflw.dot similarity index 100% rename from Code/Mantid/docs/source/diagrams/ReflectometryReductionOneAuto-PolarizationCorrection.dot rename to Code/Mantid/docs/source/diagrams/ReflectometryReductionOneAuto-v1-PolarizationCorrection_wkflw.dot diff --git a/Code/Mantid/docs/sphinxext/mantiddoc/directives/diagram.py b/Code/Mantid/docs/sphinxext/mantiddoc/directives/diagram.py index 3daf8b8fa06..2d64928d29f 100644 --- a/Code/Mantid/docs/sphinxext/mantiddoc/directives/diagram.py +++ b/Code/Mantid/docs/sphinxext/mantiddoc/directives/diagram.py @@ -68,11 +68,18 @@ class DiagramDirective(BaseDirective): 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") + if diagram_name[-4:] != ".dot": + raise RuntimeError("Diagrams need to be referred to by their filename, including '.dot' extension.") + + in_path = os.path.join(env.srcdir, "diagrams", diagram_name) + out_path = os.path.join(out_dir, diagram_name[:-4] + ".png") #Generate the diagram - in_src = open(in_path, 'r').read() + try: + in_src = open(in_path, 'r').read() + except: + raise RuntimeError("Cannot find dot-file: '" + diagram_name + "' in '" + os.path.join(env.srcdir,"diagrams")) + 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) -- GitLab