in src/python/pants/reporting/html_reporter.py [0:0]
def _render_message(self, *msg_elements):
# Identifies all details in this message, so that opening one can close all the others.
detail_class = str(uuid.uuid4())
html_fragments = ['<div>']
detail_divs = []
for element in msg_elements:
# Each element can be a message or a (message, detail) pair, as received by handle_log().
#
# However, as an internal implementation detail, we also allow an element to be a tuple
# (message, detail, detail_initially_visible[, detail_id])
#
# - If the detail exists, clicking on the text will toggle display of the detail and close
# all other details in this message.
# - If detail_initially_visible is True, the detail will be displayed by default.
#
# We allow detail_id to be explicitly specified, so that the open/closed state can be
# preserved through refreshes. For example, when looking at the artifact cache stats,
# if "hits" are open and "misses" are closed, we want to remember that even after
# the cache stats are updated and the message re-rendered.
if isinstance(element, string_types):
element = [element]
# zip_longest assumes None for missing values, so this generator will pick the default for those.
default_values = ('', None, None, False)
(text, detail, detail_id, detail_initially_visible) = (x or y for x, y in zip_longest(element, default_values))
htmlified_text = self._htmlify_text(text)
if detail is None:
html_fragments.append(htmlified_text)
else:
detail_id = detail_id or str(uuid.uuid4())
detail_visibility_class = '' if detail_initially_visible else 'nodisplay'
html_fragments.append(self._detail_a_fmt_string.format(
text=htmlified_text, detail_id=detail_id, detail_class=detail_class))
detail_divs.append(self._detail_div_fmt_string.format(
detail_id=detail_id, detail=detail, detail_class=detail_class,
detail_visibility_class=detail_visibility_class
))
html_fragments.extend(detail_divs)
html_fragments.append('</div>')
return ''.join(html_fragments)