diff --git a/src/Spectre.Console.Cli/Internal/Commands/XmlDocCommand.cs b/src/Spectre.Console.Cli/Internal/Commands/XmlDocCommand.cs index 8072518..7b7592c 100644 --- a/src/Spectre.Console.Cli/Internal/Commands/XmlDocCommand.cs +++ b/src/Spectre.Console.Cli/Internal/Commands/XmlDocCommand.cs @@ -84,6 +84,13 @@ internal sealed class XmlDocCommand : Command node.SetNullableAttribute("Settings", command.SettingsType?.FullName); + if (!string.IsNullOrWhiteSpace(command.Description)) + { + var descriptionNode = doc.CreateElement("Description"); + descriptionNode.InnerText = command.Description; + node.AppendChild(descriptionNode); + } + // Parameters if (command.Parameters.Count > 0) { @@ -103,6 +110,27 @@ internal sealed class XmlDocCommand : Command node.AppendChild(CreateCommandNode(doc, childCommand)); } + // Examples + if (command.Examples.Count > 0) + { + var exampleRootNode = doc.CreateElement("Examples"); + foreach (var example in command.Examples.SelectMany(static x => x)) + { + var exampleNode = CreateExampleNode(doc, example); + exampleRootNode.AppendChild(exampleNode); + } + + node.AppendChild(exampleRootNode); + } + + return node; + } + + private static XmlNode CreateExampleNode(XmlDocument document, string example) + { + var node = document.CreateElement("Example"); + node.SetAttribute("commandLine", example); + return node; } diff --git a/test/Spectre.Console.Cli.Tests/Expectations/Xml/Test_1.Output.verified.txt b/test/Spectre.Console.Cli.Tests/Expectations/Xml/Test_1.Output.verified.txt index 998a89b..e92f683 100644 --- a/test/Spectre.Console.Cli.Tests/Expectations/Xml/Test_1.Output.verified.txt +++ b/test/Spectre.Console.Cli.Tests/Expectations/Xml/Test_1.Output.verified.txt @@ -21,6 +21,7 @@ + The dog command. + The horse command.