Use MarkDown tables in trait documentation export.

This commit is contained in:
Matthias Mailänder
2021-05-09 12:51:11 +02:00
committed by Paul Chote
parent 5bf4daddec
commit eba266aecf
3 changed files with 44 additions and 41 deletions

View File

@@ -78,8 +78,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
if (!infos.Any())
continue;
doc.AppendLine("<table>");
doc.AppendLine("<tr><th>Property</th><th>Default Value</th><th>Type</th><th>Description</th></tr>");
doc.AppendLine();
doc.AppendLine("| Property | Default Value | Type | Description |");
doc.AppendLine("| -------- | --------------| ---- | ----------- |");
var liveTraitInfo = t == typeof(WeaponInfo) ? null : objectCreator.CreateBasic(t);
foreach (var info in infos)
@@ -87,16 +88,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
var fieldDescLines = info.Field.GetCustomAttributes<DescAttribute>(true).SelectMany(d => d.Lines);
var fieldType = Util.FriendlyTypeName(info.Field.FieldType);
var defaultValue = liveTraitInfo == null ? "" : FieldSaver.SaveField(liveTraitInfo, info.Field.Name).Value.Value;
doc.Append($"<tr><td>{info.YamlName}</td><td>{defaultValue}</td><td>{fieldType}</td>");
doc.Append("<td>");
doc.Append($"| {info.YamlName} | {defaultValue} | {fieldType} | ");
foreach (var line in fieldDescLines)
doc.Append(line + " ");
doc.AppendLine("</td></tr>");
doc.AppendLine("|");
}
doc.AppendLine("</table>");
}
Console.Write(doc.ToString());