Skip to content

Commit 6eadaf5

Browse files
committed
Fixed the sidebar menu in the HTML report so that the first click collapses a collapsable item directly; and also fixed indentation for subitems.
Added an inline description to categories in the HTML report explaining why and how the data of the category can be useful.
1 parent b0daea9 commit 6eadaf5

File tree

3 files changed

+41
-29
lines changed

3 files changed

+41
-29
lines changed

src/gitxray/include/gx_output.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ def _create_html_output(self):
195195

196196
if len(data_rows) > 0:
197197
r_sidebar_links.append('<li class="nav-item"><a class="nav-link" href="#repository_'+str(sanitized_entity)+'_'+str(rtype)+'">'+str(rtype)+' '+gx_definitions.HTML_REPORT_EMOJIS.get(rtype,"")+'</a></li>')
198-
r_tables.append(templates['table'].replace("{{table_rows}}", "".join(data_rows)).replace("{{table_title}}", f"{rtype} {gx_definitions.HTML_REPORT_EMOJIS.get(rtype,'')}").replace("{{table_id}}", "repository_"+str(sanitized_entity)+"_"+rtype))
198+
r_tables.append(templates['table'].replace("{{table_rows}}", "".join(data_rows)).replace("{{table_title}}", f"{rtype} {gx_definitions.HTML_REPORT_EMOJIS.get(rtype,'')}").replace("{{table_id}}", "repository_"+str(sanitized_entity)+"_"+rtype).replace("{{table_description}}", f"{gx_definitions.HTML_REPORT_DESCRIPTIONS.get(rtype,'')}"))
199199

200200
if len(r_tables) > 0:
201-
repository_sidebar_links += '<ul class="nav flex-column mb-0"><li class="nav-item"><a class="nav-link collapsed" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="nav_'+str(sanitized_entity)+'" href="#nav_'+str(sanitized_entity)+'">'+str(sanitized_entity_raw)+' &#128193;</a><div class="collapse" id="nav_'+str(sanitized_entity)+'"><ul class="nav flex-column ms-3">'
201+
repository_sidebar_links += '<ul class="nav flex-column mb-0"><li class="nav-item"><a class="nav-link collapsed" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="nav_'+str(sanitized_entity)+'" href="#nav_'+str(sanitized_entity)+'">'+str(sanitized_entity_raw)+' &#128193;</a><div class="px-3 collapse" id="nav_'+str(sanitized_entity)+'"><ul class="nav flex-column ms-3">'
202202
repository_sidebar_links += "".join(r_sidebar_links)
203203
repository_sidebar_links += '</ul></div></li></ul>'
204204
r_template = r_template.replace("{{repository_tables}}", "".join(r_tables))
@@ -230,7 +230,8 @@ def _create_html_output(self):
230230
category_sidebar_links += '<ul class="nav flex-column mb-0"><li class="nav-item"><a href="#nav_category_'+str(rtype)+'">'+str(rtype)+' '+gx_definitions.HTML_REPORT_EMOJIS.get(rtype,"")+'</a></li></ul>'
231231
table_html = templates['table'].replace("{{table_rows}}", table_rows) \
232232
.replace("{{table_title}}", f"{rtype} {gx_definitions.HTML_REPORT_EMOJIS.get(rtype, '')}") \
233-
.replace("{{table_id}}", f"nav_category_{rtype}")
233+
.replace("{{table_id}}", f"nav_category_{rtype}") \
234+
.replace("{{table_description}}", f"{gx_definitions.HTML_REPORT_DESCRIPTIONS.get(rtype,'')}")
234235
category_sections += table_html
235236

236237

@@ -255,10 +256,10 @@ def _create_html_output(self):
255256

256257
if len(data_rows) > 0:
257258
c_sidebar_links.append('<li class="nav-item"><a class="nav-link" href="#contributor_'+str(sanitized_entity)+'_'+str(rtype)+'">'+str(rtype)+' '+gx_definitions.HTML_REPORT_EMOJIS.get(rtype,"")+'</a></li>')
258-
c_tables.append(templates['table'].replace("{{table_rows}}", "".join(data_rows)).replace("{{table_title}}", f"{rtype} {gx_definitions.HTML_REPORT_EMOJIS.get(rtype,'')}").replace("{{table_id}}", "contributor_"+str(sanitized_entity)+"_"+str(rtype)))
259+
c_tables.append(templates['table'].replace("{{table_rows}}", "".join(data_rows)).replace("{{table_title}}", f"{rtype} {gx_definitions.HTML_REPORT_EMOJIS.get(rtype,'')}").replace("{{table_id}}", "contributor_"+str(sanitized_entity)+"_"+str(rtype)).replace("{{table_description}}", f"{gx_definitions.HTML_REPORT_DESCRIPTIONS.get(rtype,'')}"))
259260

260261
if len(c_tables) > 0:
261-
contributor_sidebar_links += '<ul class="nav flex-column mb-0"><li class="nav-item"><a class="nav-link collapsed" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="nav_'+str(sanitized_entity)+'" href="#nav_'+str(sanitized_entity)+'">'+str(sanitized_entity)+' &#128193;</a><div class="collapse" id="nav_'+str(sanitized_entity)+'"><ul class="nav flex-column ms-3">'
262+
contributor_sidebar_links += '<ul class="nav flex-column mb-0"><li class="nav-item"><a class="nav-link collapsed" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="nav_'+str(sanitized_entity)+'" href="#nav_'+str(sanitized_entity)+'">'+str(sanitized_entity)+' &#128193;</a><div class="px-3 collapse" id="nav_'+str(sanitized_entity)+'"><ul class="nav flex-column ms-3">'
262263
contributor_sidebar_links += "".join(c_sidebar_links)
263264
contributor_sidebar_links += '</ul></div></li></ul>'
264265
c_template = c_template.replace("{{contributor_tables}}", "".join(c_tables))
@@ -269,7 +270,7 @@ def _create_html_output(self):
269270
sanitized_entity = "Anonymous"
270271
a_template = templates['non_contributor'].replace("{{non_contributor_id}}", str(sanitized_entity))
271272
a_template = a_template.replace("{{non_contributor_name}}", f'{sanitized_entity} &#128123;')
272-
more_sidebar_links += '<ul class="nav flex-column mb-0"><li class="nav-item"><a class="nav-link collapsed" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="nav_'+str(sanitized_entity)+'" href="#nav_'+str(sanitized_entity)+'">'+str(sanitized_entity)+' &#128123;</a><div class="collapse" id="nav_'+str(sanitized_entity)+'"><ul class="nav flex-column ms-3">'
273+
more_sidebar_links += '<ul class="nav flex-column mb-0"><li class="nav-item"><a class="nav-link collapsed" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="nav_'+str(sanitized_entity)+'" href="#nav_'+str(sanitized_entity)+'">'+str(sanitized_entity)+' &#128123;</a><div class="px-3 collapse" id="nav_'+str(sanitized_entity)+'"><ul class="nav flex-column ms-3">'
273274
a_tables = ""
274275
for rtype in data.keys():
275276
data_rows = []
@@ -281,7 +282,7 @@ def _create_html_output(self):
281282
if len(data_rows) > 0:
282283
more_sidebar_links += '<li class="nav-item"><a class="nav-link" href="#contributor_'+str(sanitized_entity)+'_'+str(rtype)+'">'+str(rtype)+'</a></li>'
283284

284-
a_tables += templates['table'].replace("{{table_rows}}", "".join(data_rows)).replace("{{table_title}}", str(rtype)).replace("{{table_id}}", "contributor_"+str(sanitized_entity)+"_"+str(rtype))
285+
a_tables += templates['table'].replace("{{table_rows}}", "".join(data_rows)).replace("{{table_title}}", str(rtype)).replace("{{table_id}}", "contributor_"+str(sanitized_entity)+"_"+str(rtype)).replace("{{table_description}}", f"{gx_definitions.HTML_REPORT_DESCRIPTIONS.get(rtype,'')}")
285286

286287
more_sidebar_links += '</ul></div></li></ul>'
287288
a_template = a_template.replace("{{non_contributor_tables}}", a_tables)
@@ -312,13 +313,14 @@ def _create_html_output(self):
312313
more_sidebar_links += '<ul class="nav flex-column mb-0"><li class="nav-item"><a href="#nav_more_'+str(rtype)+'">'+str(rtype)+' '+gx_definitions.HTML_REPORT_EMOJIS.get(rtype,"")+'</a></li></ul>'
313314
table_html = templates['table'].replace("{{table_rows}}", table_rows) \
314315
.replace("{{table_title}}", f"{rtype} {gx_definitions.HTML_REPORT_EMOJIS.get(rtype, '')}") \
315-
.replace("{{table_id}}", f"nav_more_{rtype}")
316+
.replace("{{table_id}}", f"nav_more_{rtype}") \
317+
.replace("{{table_description}}", f"{gx_definitions.HTML_REPORT_DESCRIPTIONS.get(rtype,'')}")
316318
more_sections += table_html
317319

318320

319321
# We now have all highlights under highlights_rows; let's fill the highlights table and section of the report
320322
if len(highlights_rows) > 0:
321-
highlights_section = templates['table'].replace("{{table_rows}}", "".join(highlights_rows)).replace("{{table_title}}", "Highlights").replace("{{table_id}}", "highlights")
323+
highlights_section = templates['table'].replace("{{table_rows}}", "".join(highlights_rows)).replace("{{table_title}}", "Highlights").replace("{{table_id}}", "highlights").replace("{{table_description}}", "")
322324
else: highlights_section = "<br/><h5>No results were highlighted by Gitxray.</h5>"
323325

324326
output = templates['main'].replace("{{repository_sections}}", repository_sections)

src/gitxray/include/html_report/template_main.html

Lines changed: 28 additions & 19 deletions
Large diffs are not rendered by default.

src/gitxray/include/html_report/template_table.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<div class="table-section py-3">
22
<div class="d-flex justify-content-between align-items-center">
33
<a id="{{table_id}}"></a>
4-
<h3 class="flex-grow-1 text-start">{{table_title}}</h3>
4+
<h3 class="flex-grow-1 text-start">{{table_title}}</h3>
55
<button class="btn btn-link" type="button" data-bs-toggle="collapse" data-bs-target="#tableCollapse_{{table_id}}" aria-expanded="true" aria-controls="tableCollapse_{{table_id}}">
66
<span class="toggle-icon">&#8661;</span>
77
</button>
88
</div>
99
<div class="collapse show" id="tableCollapse_{{table_id}}">
10+
<h6><i>{{table_description}}</i></h6>
1011
<table class="table table-striped table-bordered" style="width:100%">
1112
<thead>
1213
<tr>

0 commit comments

Comments
 (0)