[PATCH] D57167: [opt-viewer] Add javascript to expand/hide full message for multiline remarks.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 24 09:59:35 PST 2019
fhahn created this revision.
fhahn added reviewers: hfinkel, anemet, thegameg.
Herald added a reviewer: serge-sans-paille.
In combination with D57159 <https://reviews.llvm.org/D57159>, this allows for better displaying of
multiline remarks in the html pages generated by opt-viewer.
The Javascript is very simple and should be supported by any recent
major browser.
https://reviews.llvm.org/D57167
Files:
llvm/tools/opt-viewer/opt-viewer.py
Index: llvm/tools/opt-viewer/opt-viewer.py
===================================================================
--- llvm/tools/opt-viewer/opt-viewer.py
+++ llvm/tools/opt-viewer/opt-viewer.py
@@ -120,12 +120,25 @@
indent = line[:max(r.Column, 1) - 1]
indent = re.sub('\S', ' ', indent)
+ # Create expanded message and link if we have a multiline message.
+ lines = r.message.split('\n')
+ if len(lines) > 1:
+ expand_link = '<a style="text-decoration: none;" href="" onclick="toggleExpandedMessage(this); return false;">+</a>'
+ message = lines[0]
+ expand_message = '<div style="display:none;" class="full-info"><pre> {} </pre></div>'.format('\n'.join(lines[1:]))
+ else:
+ expand_link = ''
+ expand_message = ''
+ message = r.message
print(u'''
<tr>
<td></td>
<td>{r.RelativeHotness}</td>
<td class=\"column-entry-{r.color}\">{r.PassWithDiffPrefix}</td>
-<td><pre style="display:inline">{indent}</pre><span class=\"column-entry-yellow\"> {r.message} </span></td>
+<td>
+ <pre style="display:inline">{indent}</pre><span class=\"column-entry-yellow\">{expand_link}{message} </span>
+ {expand_message}
+ </td>
<td class=\"column-entry-yellow\">{inlining_context}</td>
</tr>'''.format(**locals()), file=self.stream)
@@ -139,6 +152,23 @@
<meta charset="utf-8" />
<head>
<link rel='stylesheet' type='text/css' href='style.css'>
+<script type="text/javascript">
+/* Simple helper to show/hide the expanded message of a remark. */
+function toggleExpandedMessage(e) {{
+ var FullTextElems = e.parentElement.parentElement.getElementsByClassName("full-info");
+ if (!FullTextElems || FullTextElems.length < 1) {{
+ return false;
+ }}
+ var FullText = FullTextElems[0];
+ if (FullText.style.display == 'none') {{
+ e.innerHTML = '-';
+ FullText.style.display = 'block';
+ }} else {{
+ e.innerHTML = '+';
+ FullText.style.display = 'none';
+ }}
+}}
+</script>
</head>
<body>
<div class="centered">
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57167.183335.patch
Type: text/x-patch
Size: 2061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190124/8cb00a57/attachment.bin>
More information about the llvm-commits
mailing list