diff --git a/OpenRA.Utility/Command.cs b/OpenRA.Utility/Command.cs index 1605106831..6a54b607b1 100644 --- a/OpenRA.Utility/Command.cs +++ b/OpenRA.Utility/Command.cs @@ -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()) + foreach (var t in Game.modData.ObjectCreator.GetTypesImplementing().OrderBy(t => t.Namespace)) { if (t.ContainsGenericParameters || t.IsAbstract) continue; // skip helpers like TraitInfo var traitName = t.Name.EndsWith("Info") ? t.Name.Substring(0, t.Name.Length - 4) : t.Name; var traitDescLines = t.GetCustomAttributes(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(""); + Console.WriteLine(""); 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(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("", f.Name, defaultValue, fieldType); + Console.Write(""); } + Console.WriteLine("
PropertyDefault ValueTypeDescription
{0}{1}{2}"); + foreach (var line in fieldDescLines) + Console.Write(line); + Console.WriteLine("
"); } - - Console.WriteLine(); - Console.WriteLine("```"); } [Desc("MAPFILE", "Generate hash of specified oramap file.")]