Commit ef926972 authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

Added a "hivestatus" role that prints the text with the same colour as beekeeper/guiHive

parent b8c335e1
......@@ -21,7 +21,7 @@ import sphinx_rtd_theme
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('.'))
from xhive import hive_setup_if_needed, HiveDiagramDirective
from xhive import *
......@@ -355,3 +355,8 @@ epub_exclude_files = ['search.html']
def setup(app):
app.add_directive('hive_diagram', HiveDiagramDirective)
app.add_role('hivestatus', hivestatus_role)
html = (visit_hivestatus_html, depart_hivestatus_html),
latex = (visit_hivestatus_latex, depart_hivestatus_latex),
......@@ -135,7 +135,7 @@ Making sense of the beekeeper's output
#. The status of the analysis (typically, "LOADING", "READY", "ALL_CLAIMED", possibly "FAILED"). Analyses that are done are not shown in this table.
#. A job summary, showing the number of [r]eady, [s]emaphored, [i]n-progress, and [d]one jobs in the analysis
#. A job summary, showing the number of [r]eady, [s]emaphored, :hivestatus:`<INPROGRESS> [i]n-progress`, and [d]one jobs in the analysis
#. Average runtime for jobs in the analysis,
......@@ -9,6 +9,8 @@ from docutils import nodes
from docutils.parsers.rst import directives
from docutils.parsers.rst import Directive
__all__ = ["HiveDiagramDirective", "hive_setup_if_needed", "hivestatus", "hivestatus_role", "visit_hivestatus_html", "depart_hivestatus_html", "visit_hivestatus_latex", "depart_hivestatus_latex"]
class HiveDiagramDirective(Directive):
# defines the parameter the directive expects
......@@ -96,6 +98,7 @@ def generate_diagram(pipeconfig_content, target_image_filename):
hive_colours = {}
def hive_setup_if_needed():
if os.environ.get("READTHEDOCS", None) == "True":
......@@ -108,4 +111,41 @@ def hive_setup_if_needed():
if True or any(not os.path.exists(os.path.join(doxygen_target, _)) for _ in ["perl", "python3", "java"]):
mkdoc_path = os.path.join(os.environ["EHIVE_ROOT_DIR"], "scripts", "")[mkdoc_path, "-no_schema_desc"])
# eHive's default configuration file
default_config_file = os.environ["EHIVE_ROOT_DIR"] + os.path.sep + "hive_config.json"
with open(default_config_file, "r") as fc:
conf_content = json.load(fc)
as_hash = conf_content["Graph"]["Node"]["AnalysisStatus"]
for s in as_hash:
if isinstance(as_hash[s], dict):
hive_colours[s] = as_hash[s]["Colour"]
js_hash = conf_content["Graph"]["Node"]["JobStatus"]
for s in js_hash:
if isinstance(js_hash[s], dict):
hive_colours[s] = js_hash[s]["Colour"]
class hivestatus(nodes.Element):
def hivestatus_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
status = text[1:text.index('>')]
text = (text[text.index('>')+1:]).strip()
hivestatus_node = hivestatus()
hivestatus_node['status'] = status
return [hivestatus_node], []
def visit_hivestatus_html(self, node):
self.body.append('<span style="background-color:%s">' % hive_colours[node['status']])
def depart_hivestatus_html(self, node):
def visit_hivestatus_latex(self, node):
self.body.append('\n\\colorbox{%s}{' % hive_colours[node['status']])
def depart_hivestatus_latex(self, node):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment