Skip to content

Commit bd3a466

Browse files
authored
XML documentation (Argument, Option, Command) (#1181)
1 parent 98a466e commit bd3a466

10 files changed

+43
-20
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
the-root-command:
1+
the-root-command:
22
Test description
33

44
Usage:

src/System.CommandLine.Tests/ApprovalTests/Help/HelpBuilderTests.Approval.cs renamed to src/System.CommandLine.Tests/Help/HelpBuilderTests.Approval.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using Xunit;
5-
using System.CommandLine.Help;
65
using System.IO;
76
using ApprovalTests;
87

@@ -77,10 +76,8 @@ public void Help_describes_default_values_for_complex_root_command_scenario()
7776
};
7877
command.Name = "the-root-command";
7978

80-
HelpBuilder helpBuilder = GetHelpBuilder(LargeMaxWidth);
81-
helpBuilder.Write(command);
82-
var output = _console.Out.ToString();
83-
Approvals.Verify(output);
79+
GetHelpBuilder(LargeMaxWidth).Write(command);
80+
Approvals.Verify(_console.Out.ToString());
8481
}
8582

8683
}

src/System.CommandLine/Argument.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace System.CommandLine
1111
{
1212
/// <summary>
13-
/// Represents a value passed to an <see cref="Option"/> or <see cref="Command"/>.
13+
/// A symbol defining a value that can be passed on the command line to a <see cref="ICommand">command</see> or <see cref="IOption">option</see>.
1414
/// </summary>
1515
public class Argument : Symbol, IArgument
1616
{
@@ -108,7 +108,7 @@ public List<ISuggestionSource> Suggestions
108108
}
109109

110110
/// <summary>
111-
/// Gets or sets the <see cref="System.Type" /> that the argument will be converted to.
111+
/// Gets or sets the <see cref="Type" /> that the argument token(s) will be converted to.
112112
/// </summary>
113113
public Type ArgumentType
114114
{
@@ -226,13 +226,16 @@ internal void AddAllowedValues(IEnumerable<string> values)
226226
.Containing(textToMatch ?? "");
227227
}
228228

229+
/// <inheritdoc />
229230
public override string ToString() => $"{nameof(Argument)}: {Name}";
230231

231232
/// <inheritdoc />
232233
IArgumentArity IArgument.Arity => Arity;
233234

235+
/// <inheritdoc />
234236
string IValueDescriptor.ValueName => Name;
235237

238+
/// <inheritdoc />
236239
Type IValueDescriptor.ValueType => ArgumentType;
237240
}
238241
}

src/System.CommandLine/ArgumentArity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ internal static IArgumentArity Default(Type type, Argument argument, ISymbolSet
121121
return Zero;
122122
}
123123

124-
var parent = parents.FirstOrDefault();
124+
var parent = parents.Count > 0 ? parents[0] : default;
125125

126126
if (typeof(IEnumerable).IsAssignableFrom(type) &&
127127
type != typeof(string))

src/System.CommandLine/IArgument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace System.CommandLine
77
{
88
/// <summary>
9-
/// Defines a symbol with an arity.
9+
/// A symbol defining a value that can be passed on the command line to a <see cref="ICommand">command</see> or <see cref="IOption">option</see>.
1010
/// </summary>
1111
public interface IArgument :
1212
ISymbol,

src/System.CommandLine/IArgumentArity.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ namespace System.CommandLine
66
/// <summary>
77
/// Defines the arity of an argument.
88
/// </summary>
9-
/// <remarks>The arity of an option or command's argument refers to the number of values that can be passed if that
10-
/// option or command is specified. Arity is expressed with a minimum value and a maximum value.
9+
/// <remarks>The arity of an argument refers to the number of values that can be passed on the command line.
1110
/// </remarks>
1211
public interface IArgumentArity
1312
{
1413
/// <summary>
15-
/// Gets the minimum number of values required for the argument.
14+
/// Gets the minimum number of values required for an <see cref="IArgument">argument</see>.
1615
/// </summary>
1716
int MinimumNumberOfValues { get; }
1817

1918
/// <summary>
20-
/// Gets the maximum number of values allowed for the argument.
19+
/// Gets the maximum number of values allowed for an <see cref="IArgument">argument</see>.
2120
/// </summary>
2221
int MaximumNumberOfValues { get; }
2322
}

src/System.CommandLine/ICommand.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,29 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using System.Collections.Generic;
5+
using System.CommandLine.Parsing;
56

67
namespace System.CommandLine
78
{
9+
/// <summary>
10+
/// A symbol definining an action that can be performed.
11+
/// </summary>
12+
/// <remarks>This is also often called a verb.</remarks>
813
public interface ICommand : IIdentifierSymbol
914
{
15+
/// <summary>
16+
/// Gets a value indicating whether unmatched tokens contribute errors to <see cref="ParseResult.Errors"/>>.
17+
/// </summary>
1018
bool TreatUnmatchedTokensAsErrors { get; }
1119

20+
/// <summary>
21+
/// Gets the <see cref="IArgument">arguments</see> that can be provided to the command.
22+
/// </summary>
1223
IReadOnlyList<IArgument> Arguments { get; }
1324

25+
/// <summary>
26+
/// Gets the <see cref="IOption">options</see> that can be provided to the command.
27+
/// </summary>
1428
IReadOnlyList<IOption> Options { get; }
1529
}
1630
}

src/System.CommandLine/IIdentifierSymbol.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
namespace System.CommandLine
77
{
88
/// <summary>
9-
/// Defines a symbol with aliases.
9+
/// Defines a symbol which is an identifier on the command line, such as a <see cref="ICommand">command</see> or <see cref="IOption">option</see>.
1010
/// </summary>
1111
public interface IIdentifierSymbol : ISymbol
1212
{
1313
/// <summary>
14-
/// Gets the aliases for the symbol.
14+
/// Gets the set of alternative strings that can be used on the command line to specify the symbol.
1515
/// </summary>
1616
IReadOnlyCollection<string> Aliases { get; }
1717

1818
/// <summary>
1919
/// Determines whether the alias has already been defined.
2020
/// </summary>
2121
/// <param name="alias">The alias to search for.</param>
22-
/// <returns><c>true</c> if the alias has already been defined; otherwise <c>false</c>.</returns>
22+
/// <returns><see langkeyword="true">true</see> if the alias has already been defined; otherwise <see langkeyword="true">false</see>.</returns>
2323
bool HasAlias(string alias);
2424
}
2525
}

src/System.CommandLine/IOption.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
namespace System.CommandLine
77
{
88
/// <summary>
9-
/// Defines a symbol with an argument.
9+
/// A symbol defining a named parameter and a value for that parameter.
1010
/// </summary>
1111
public interface IOption : IIdentifierSymbol, IValueDescriptor
1212
{
1313
/// <summary>
14-
/// Gets the argument for the option.
14+
/// Gets the <see cref="IArgument">argument</see> for the option.
1515
/// </summary>
1616
IArgument Argument { get; }
1717

@@ -21,8 +21,18 @@ public interface IOption : IIdentifierSymbol, IValueDescriptor
2121
bool IsRequired { get; }
2222

2323
/// <summary>
24-
/// Gets a value that indicates whether multiple argument values are allowed.
24+
/// Gets a value that indicates whether multiple argument tokens are allowed for each option identifier token.
2525
/// </summary>
26+
/// <example>
27+
/// If set to <see langword="true"/>, the following command line is valid for passing multiple arguments:
28+
/// <code>
29+
/// > --opt 1 2 3
30+
/// </code>
31+
/// The following is equivalent is always valid:
32+
/// <code>
33+
/// > --opt 1 --opt 2 --opt 3
34+
/// </code>
35+
/// </example>
2636
bool AllowMultipleArgumentsPerToken { get; }
2737
}
2838
}

0 commit comments

Comments
 (0)