1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-26 06:49:19 +00:00

Output human-readable generation parameters to HTML

Makes it easier to regenerate a file when you can see what the
column widths are supposed to be.
This commit is contained in:
Andy McFadden 2019-12-25 10:59:40 -08:00
parent 5a88a805d0
commit f11ef0dce4
2 changed files with 67 additions and 0 deletions

View File

@ -114,6 +114,8 @@ namespace SourceGen {
COUNT // number of elements, must be last COUNT // number of elements, must be last
} }
private string mParameterStringBase;
/// <summary> /// <summary>
/// Constructor. /// Constructor.
@ -126,6 +128,7 @@ namespace SourceGen {
mLeftFlags = leftFlags; mLeftFlags = leftFlags;
ConfigureColumns(leftFlags, rightWidths); ConfigureColumns(leftFlags, rightWidths);
mParameterStringBase = GenerateParameterStringBase(leftFlags, rightWidths);
} }
private void ConfigureColumns(ActiveColumnFlags leftFlags, int[] rightWidths) { private void ConfigureColumns(ActiveColumnFlags leftFlags, int[] rightWidths) {
@ -187,6 +190,68 @@ namespace SourceGen {
//} //}
} }
/// <summary>
/// Generates description of some parameters that we only have during construction.
/// </summary>
private static string GenerateParameterStringBase(ActiveColumnFlags leftFlags,
int[] rightWidths) {
StringBuilder sb = new StringBuilder();
sb.Append("cols=");
for (int i = 0; i < rightWidths.Length; i++) {
if (i != 0) {
sb.Append(',');
}
sb.Append(rightWidths[i]);
}
sb.Append(";extraCols=");
bool first = true;
foreach (ActiveColumnFlags flag in Enum.GetValues(typeof(ActiveColumnFlags))) {
if (flag == ActiveColumnFlags.ALL) {
continue;
}
if ((leftFlags & flag) != 0) {
if (!first) {
sb.Append(',');
}
sb.Append(flag);
first = false;
}
}
return sb.ToString();
}
/// <summary>
/// Generates a description of configured parameters. Intended to be human-readable,
/// but possibly machine-readable as well.
/// </summary>
private string GenerateParameterString() {
StringBuilder sb = new StringBuilder(mParameterStringBase);
sb.Append(";byteSpc=");
sb.Append(mFormatter.Config.mSpacesBetweenBytes.ToString());
sb.Append(";commaBulk=");
sb.Append(mFormatter.Config.mCommaSeparatedDense.ToString());
sb.Append(";nonuPfx='");
sb.Append(mFormatter.Config.mNonUniqueLabelPrefix);
sb.Append('\'');
sb.Append(";varPfx='");
sb.Append(mFormatter.Config.mLocalVariableLabelPrefix);
sb.Append('\'');
sb.Append(";labelBrk=");
sb.Append(LongLabelNewLine.ToString());
sb.Append(";notes=");
sb.Append(IncludeNotes.ToString());
sb.Append(";gfx=");
sb.Append(GenerateImageFiles.ToString());
// Not included: pseudo-op definitions; delimiter definitions
return sb.ToString();
}
/// <summary> /// <summary>
/// Converts the selected lines to formatted text. /// Converts the selected lines to formatted text.
/// </summary> /// </summary>
@ -449,6 +514,7 @@ namespace SourceGen {
string timeStr = DateTime.Now.ToString("HH:mm:ss zzz"); string timeStr = DateTime.Now.ToString("HH:mm:ss zzz");
tmplStr = tmplStr.Replace("$CurrentDate$", dateStr); tmplStr = tmplStr.Replace("$CurrentDate$", dateStr);
tmplStr = tmplStr.Replace("$CurrentTime$", timeStr); tmplStr = tmplStr.Replace("$CurrentTime$", timeStr);
tmplStr = tmplStr.Replace("$GenParameters$", GenerateParameterString());
// Generate and substitute the symbol table. This should be small enough that // Generate and substitute the symbol table. This should be small enough that
// we won't break the world by doing it with string.Replace(). // we won't break the world by doing it with string.Replace().

View File

@ -32,6 +32,7 @@ $SymbolTable$
<p>HTML generated by <a href="https://6502bench.com/">6502bench SourceGen</a> v$AppVersion$ <p>HTML generated by <a href="https://6502bench.com/">6502bench SourceGen</a> v$AppVersion$
on $CurrentDate$ <!--$CurrentTime$--></p> on $CurrentDate$ <!--$CurrentTime$--></p>
<p>Expression style: $ExpressionStyle$</p> <p>Expression style: $ExpressionStyle$</p>
<!-- parameters: $GenParameters$ -->
</div> </div>
</body> </body>
</html> </html>