@@ -164,20 +164,23 @@ def _create_html_output(self):
164
164
# Load all template files
165
165
templates = {
166
166
name : open (os .path .join (TEMPLATE_DIR , f"template_{ name } .html" ), "r" , encoding = "utf-8" ).read ()
167
- for name in ["main" , "repository" , "contributor" , "non_contributor" , "table" ]
167
+ for name in ["main" , "repository" , "contributor" , "non_contributor" , "table" , "highlights" ]
168
168
}
169
169
170
170
category_sections = ""
171
171
contributor_sections = ""
172
172
more_sections = ""
173
+ highlights_section = ""
173
174
repository_sections = ""
174
175
repository_sidebar_links = ""
175
176
contributor_sidebar_links = ""
176
177
category_sidebar_links = ""
177
178
more_sidebar_links = ""
179
+ highlights_rows = []
178
180
179
181
for entity , data in self ._repositories .items ():
180
- sanitized_entity = self .html_data_sanitize_and_process (entity )
182
+ sanitized_entity_raw = self .html_data_sanitize_and_process (entity )
183
+ sanitized_entity = sanitized_entity_raw .replace ("/" ,"_" )
181
184
r_template = templates ['repository' ].replace ("{{repository_id}}" , str (sanitized_entity ))
182
185
183
186
r_tables = []
@@ -186,6 +189,7 @@ def _create_html_output(self):
186
189
if not self .debug_enabled () and ("debug" in rtype .lower ()): continue
187
190
data_rows = []
188
191
for line in data [rtype ]:
192
+ if "warning: " in line .lower (): highlights_rows .append (f"<tr><td>{ rtype } </td><td>{ self .html_data_sanitize_and_process (line )} </td></tr>" )
189
193
if self ._filters != None and (all (f .lower () not in f'{ rtype .lower ()} { line .lower ()} ' for f in self ._filters )): continue
190
194
data_rows .append (f"<tr><td>{ rtype } </td><td>{ self .html_data_sanitize_and_process (line )} </td></tr>" )
191
195
@@ -194,7 +198,7 @@ def _create_html_output(self):
194
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 ))
195
199
196
200
if len (r_tables ) > 0 :
197
- 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 )+ ' 📁</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 )+ ' 📁</a><div class="collapse" id="nav_' + str (sanitized_entity )+ '"><ul class="nav flex-column ms-3">'
198
202
repository_sidebar_links += "" .join (r_sidebar_links )
199
203
repository_sidebar_links += '</ul></div></li></ul>'
200
204
r_template = r_template .replace ("{{repository_tables}}" , "" .join (r_tables ))
@@ -245,6 +249,7 @@ def _create_html_output(self):
245
249
if not self .debug_enabled () and ("debug" in rtype .lower ()): continue
246
250
data_rows = []
247
251
for line in data [rtype ]:
252
+ if "warning: " in line .lower (): highlights_rows .append (f"<tr><td>{ rtype } </td><td>{ self .html_data_sanitize_and_process (line )} </td></tr>" )
248
253
if self ._filters != None and (all (f .lower () not in f'{ rtype .lower ()} { line .lower ()} ' for f in self ._filters )): continue
249
254
data_rows .append (f"<tr><td>{ sanitized_entity } </td><td>{ self .html_data_sanitize_and_process (line )} </td></tr>" )
250
255
@@ -269,6 +274,7 @@ def _create_html_output(self):
269
274
for rtype in data .keys ():
270
275
data_rows = []
271
276
for line in data [rtype ]:
277
+ if "warning: " in line .lower (): highlights_rows .append (f"<tr><td>{ rtype } </td><td>{ self .html_data_sanitize_and_process (line )} </td></tr>" )
272
278
if self ._filters != None and (all (f .lower () not in f'{ rtype .lower ()} { line .lower ()} ' for f in self ._filters )): continue
273
279
data_rows .append (f"<tr><td>{ rtype } </td><td>{ self .html_data_sanitize_and_process (line )} </td></tr>" )
274
280
@@ -310,6 +316,10 @@ def _create_html_output(self):
310
316
more_sections += table_html
311
317
312
318
319
+ # We now have all highlights under highlights_rows; let's fill the highlights table and section of the report
320
+ if len (highlights_rows ) > 0 :
321
+ highlights_section = templates ['table' ].replace ("{{table_rows}}" , "" .join (highlights_rows )).replace ("{{table_title}}" , "Highlights" ).replace ("{{table_id}}" , "highlights" )
322
+ else : highlights_section = "<br/><h5>No results were highlighted by Gitxray.</h5>"
313
323
314
324
output = templates ['main' ].replace ("{{repository_sections}}" , repository_sections )
315
325
# repository sidebar links
@@ -321,6 +331,9 @@ def _create_html_output(self):
321
331
# more sidebar links
322
332
output = output .replace ("{{more_sidebar_links}}" , more_sidebar_links )
323
333
334
+ # highlights section
335
+ output = output .replace ("{{highlights_section}}" , highlights_section )
336
+
324
337
output = output .replace ("{{category_sections}}" , category_sections )
325
338
output = output .replace ("{{contributor_sections}}" , contributor_sections )
326
339
output = output .replace ("{{report_date}}" , datetime .datetime .now ().strftime ("%B %d, %Y" ))
0 commit comments