tabular view, sorted by namespace and given headers
This commit is contained in:
@@ -257,44 +257,41 @@ namespace OpenRA.Utility
|
||||
Game.modData = new ModData(args[1]);
|
||||
Rules.LoadRules(Game.modData.Manifest, new Map());
|
||||
|
||||
Console.WriteLine("## Documentation");
|
||||
Console.WriteLine(
|
||||
"This documentation is aimed at modders and contributors of OpenRA. It displays all traits with default values and developer commentary. " +
|
||||
"Please do not edit it directly, but add new `[Desc(\"String\")]` tags to the source code. This file has been automatically generated on {0}. " +
|
||||
"Type `make docs` to create a new one. A copy of this is uploaded to https://github.com/OpenRA/OpenRA/wiki/Traits " +
|
||||
"as well as compiled to HTML and shipped with every release during the automated packaging process.", DateTime.Now);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("```yaml");
|
||||
Console.WriteLine();
|
||||
"This documentation is aimed at modders. It displays all traits with default values and developer commentary. " +
|
||||
"Please do not edit it directly, but add new `[Desc(\"String\")]` tags to the source code. This file has been " +
|
||||
"automatically generated for version {0} of OpenRA.", Game.modData.Manifest.Mod.Version);
|
||||
|
||||
foreach (var t in Game.modData.ObjectCreator.GetTypesImplementing<ITraitInfo>())
|
||||
foreach (var t in Game.modData.ObjectCreator.GetTypesImplementing<ITraitInfo>().OrderBy(t => t.Namespace))
|
||||
{
|
||||
if (t.ContainsGenericParameters || t.IsAbstract)
|
||||
continue; // skip helpers like TraitInfo<T>
|
||||
|
||||
var traitName = t.Name.EndsWith("Info") ? t.Name.Substring(0, t.Name.Length - 4) : t.Name;
|
||||
var traitDescLines = t.GetCustomAttributes<DescAttribute>(false).SelectMany(d => d.Lines);
|
||||
Console.WriteLine("\t{0}:{1}", traitName, traitDescLines.Count() == 1 ? " # " + traitDescLines.First() : "");
|
||||
if (traitDescLines.Count() >= 2)
|
||||
foreach (var line in traitDescLines)
|
||||
Console.WriteLine("\t\t# {0}", line);
|
||||
Console.WriteLine("### {0}", traitName);
|
||||
foreach (var line in traitDescLines)
|
||||
Console.WriteLine(line);
|
||||
|
||||
var fields = t.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
|
||||
if (!fields.Any())
|
||||
continue;
|
||||
Console.WriteLine("<table>");
|
||||
Console.WriteLine("<tr><th>Property</th><th>Default Value</th><th>Type</th><th>Description</th></tr>");
|
||||
var liveTraitInfo = Game.modData.ObjectCreator.CreateBasic(t);
|
||||
|
||||
foreach (var f in t.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy))
|
||||
foreach (var f in fields)
|
||||
{
|
||||
var fieldDescLines = f.GetCustomAttributes<DescAttribute>(true).SelectMany(d => d.Lines);
|
||||
var fieldType = FriendlyTypeName(f.FieldType);
|
||||
var defaultValue = FieldSaver.SaveField(liveTraitInfo, f.Name).Value.Value;
|
||||
Console.WriteLine("\t\t{0}: {1} # Type: {2}{3}", f.Name, defaultValue, fieldType, fieldDescLines.Count() == 1 ? ". " + fieldDescLines.First() : "");
|
||||
if (fieldDescLines.Count() >= 2)
|
||||
foreach (var line in fieldDescLines)
|
||||
Console.WriteLine("\t\t# {0}", line);
|
||||
Console.Write("<tr><td>{0}</td><td>{1}</td><td>{2}</td>", f.Name, defaultValue, fieldType);
|
||||
Console.Write("<td>");
|
||||
foreach (var line in fieldDescLines)
|
||||
Console.Write(line);
|
||||
Console.WriteLine("</td></tr>");
|
||||
}
|
||||
Console.WriteLine("</table>");
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("```");
|
||||
}
|
||||
|
||||
[Desc("MAPFILE", "Generate hash of specified oramap file.")]
|
||||
|
||||
Reference in New Issue
Block a user