{
- return field;
+ "Total",
+ secondColumn,
+ summary.Code.ToString(),
+ summary.Comment.ToString(),
+ summary.Blank.ToString(),
+ summary.Total.ToString()
+ };
+ if (!noHealth)
+ {
+ row.Add(string.Empty);
}
- return "\"" + field.Replace("\"", "\"\"") + "\"";
+ WriteRow(row);
}
-}
+}
\ No newline at end of file
diff --git a/src/Sloc.Cli/Output/HtmlRenderer.cs b/src/Sloc.Cli/Output/HtmlRenderer.cs
index e505ab3..b04a7c8 100644
--- a/src/Sloc.Cli/Output/HtmlRenderer.cs
+++ b/src/Sloc.Cli/Output/HtmlRenderer.cs
@@ -206,55 +206,15 @@ public HtmlRenderer(TextWriter? writer = null, DateTimeOffset? generatedAt = nul
}
///
- public void Render(AnalysisSummary summary, bool byFile, bool noHealth, bool detailed = false)
+ public void Render(AnalysisSummary summary, bool byFile, bool noHealth, bool detailed = false, string? sourcePath = null)
{
ArgumentNullException.ThrowIfNull(summary);
var sb = new StringBuilder();
- BuildDocument(sb, summary, byFile, noHealth, detailed);
+ BuildDocument(sb, summary, byFile, noHealth, detailed, sourcePath);
_writer.Write(sb);
}
- private void BuildDocument(StringBuilder sb, AnalysisSummary summary, bool byFile, bool noHealth, bool detailed)
- {
- sb.AppendLine("");
- sb.AppendLine("");
- sb.AppendLine("");
- sb.AppendLine(" ");
- sb.AppendLine(" ");
- sb.AppendLine($" {Encode("Sloc Report")}");
- sb.AppendLine(" ");
- sb.AppendLine("");
- sb.AppendLine("");
- sb.AppendLine($"{Encode("Sloc Report")}
");
- var generated = _generatedAt.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'");
- sb.AppendLine($"{"Generated:"} {Encode(generated)} | {summary.FileCount:N0} {"files"} | {summary.Total:N0} {"total lines"}
");
-
- if (detailed || !byFile)
- {
- BuildLanguageSection(sb, summary, noHealth);
- }
-
- if (detailed || byFile)
- {
- BuildFileSection(sb, summary, noHealth);
- }
-
- if (summary.Skipped.Count > 0)
- {
- BuildSkippedSection(sb, summary);
- }
-
- sb.AppendLine("");
-
- sb.AppendLine("");
- sb.AppendLine("");
- }
-
private static void BuildFileSection(StringBuilder sb, AnalysisSummary summary, bool noHealth)
{
sb.AppendLine($"{Encode("By File")}
");
@@ -598,6 +558,47 @@ private static string ToRelative(string path)
}
}
+ private void BuildDocument(StringBuilder sb, AnalysisSummary summary, bool byFile, bool noHealth, bool detailed, string? sourcePath)
+ {
+ sb.AppendLine("");
+ sb.AppendLine("");
+ sb.AppendLine("");
+ sb.AppendLine(" ");
+ sb.AppendLine(" ");
+ sb.AppendLine($" {Encode("Sloc Report")}");
+ sb.AppendLine(" ");
+ sb.AppendLine("");
+ sb.AppendLine("");
+ sb.AppendLine($"{Encode("Sloc Report")}
");
+ var generated = _generatedAt.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ var sourceMeta = string.IsNullOrEmpty(sourcePath) ? string.Empty : $" | {"Source:"} {Encode(sourcePath)}";
+ sb.AppendLine($"{"Generated:"} {Encode(generated)} | {summary.FileCount:N0} {"files"} | {summary.Total:N0} {"total lines"}{sourceMeta}
");
+
+ if (detailed || !byFile)
+ {
+ BuildLanguageSection(sb, summary, noHealth);
+ }
+
+ if (detailed || byFile)
+ {
+ BuildFileSection(sb, summary, noHealth);
+ }
+
+ if (summary.Skipped.Count > 0)
+ {
+ BuildSkippedSection(sb, summary);
+ }
+
+ sb.AppendLine("");
+
+ sb.AppendLine("");
+ sb.AppendLine("");
+ }
+
private sealed class FileEntry
{
public required FileAnalysis File
diff --git a/src/Sloc.Cli/Output/IResultRenderer.cs b/src/Sloc.Cli/Output/IResultRenderer.cs
index b0b8ec2..0d16597 100644
--- a/src/Sloc.Cli/Output/IResultRenderer.cs
+++ b/src/Sloc.Cli/Output/IResultRenderer.cs
@@ -17,5 +17,10 @@ public interface IResultRenderer
/// When , emit both the by-language summary and the per-file
/// breakdown together instead of one or the other.
///
- void Render(AnalysisSummary summary, bool byFile, bool noHealth, bool detailed = false);
+ ///
+ /// The path, list file, or git commit/tree-ish that was analyzed, included in report
+ /// metadata (where supported) so a saved or shared report can be traced back to its
+ /// source. omits it.
+ ///
+ void Render(AnalysisSummary summary, bool byFile, bool noHealth, bool detailed = false, string? sourcePath = null);
}
\ No newline at end of file
diff --git a/src/Sloc.Cli/Output/JsonRenderer.cs b/src/Sloc.Cli/Output/JsonRenderer.cs
index 96d0d74..11b4f5f 100644
--- a/src/Sloc.Cli/Output/JsonRenderer.cs
+++ b/src/Sloc.Cli/Output/JsonRenderer.cs
@@ -9,8 +9,8 @@ namespace Sloc.Cli.Output;
///