Update to match normal output
@@ -283,6 +283,10 @@ func toCSV(input chan *FileJob) string {
return b.String()
}
+func toHtml(input chan *FileJob) string {
+ return `<html lang="en"><head><meta charset="utf-8" /><title>scc html output</title></head><body>` + toHtmlTable(input) + `</body></html>`
+}
+
func toHtmlTable(input chan *FileJob) string {
languages := map[string]LanguageSummary{}
var sumFiles, sumLines, sumCode, sumComment, sumBlank, sumComplexity int64 = 0, 0, 0, 0, 0, 0
@@ -337,7 +341,8 @@ func toHtmlTable(input chan *FileJob) string {
var str strings.Builder
- str.WriteString(`<table id="scc-table"><tr>
+ str.WriteString(`<table id="scc-table">
+ <thead><tr>
<th>Language</th>
<th>Files</th>
<th>Lines</th>
@@ -345,7 +350,8 @@ func toHtmlTable(input chan *FileJob) string {
<th>Comment</th>
<th>Code</th>
<th>Complexity</th>
- </tr>`)
+ </tr></thead>
+ <tbody>`)
for _, r := range language {
str.WriteString(fmt.Sprintf(`<tr>
@@ -359,7 +365,17 @@ func toHtmlTable(input chan *FileJob) string {
</tr>`, r.Name, len(r.Files), r.Lines, r.Blank, r.Comment, r.Code, r.Complexity))
}
- str.WriteString(`</table>`)
+ str.WriteString(fmt.Sprintf(`</tbody>
+ <tfoot><tr>
+ <td>Total</td>
+ <td>%d</td>
+ <td>%d</td>
+ <td>%d</td>
+ <td>%d</td>
+ <td>%d</td>
+ <td>%d</td>
+ </tr></tfoot>
+ </table>`, sumFiles, sumLines, sumBlank, sumComment, sumCode, sumComplexity))
return str.String()
}
@@ -375,6 +391,7 @@ func fileSummarize(input chan *FileJob) string {
case strings.ToLower(Format) == "csv":
return toCSV(input)
case strings.ToLower(Format) == "html":
+ return toHtml(input)
case strings.ToLower(Format) == "html-table":
return toHtmlTable(input)
}
