Skip to content

Commit 11d8ba2

Browse files
authored
Docs improvements (#2709)
1 parent f78cba5 commit 11d8ba2

File tree

17 files changed

+213
-173
lines changed

17 files changed

+213
-173
lines changed

src/System.CommandLine/Argument.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace System.CommandLine
1111
{
1212
/// <summary>
13-
/// A symbol defining a value that can be passed on the command line to a <see cref="Command">command</see> or <see cref="Option">option</see>.
13+
/// Represents a symbol that defines a value that can be passed on the command line to a <see cref="Command">command</see> or <see cref="Option">option</see>.
1414
/// </summary>
1515
public abstract class Argument : Symbol
1616
{
@@ -22,7 +22,7 @@ public abstract class Argument : Symbol
2222
/// <summary>
2323
/// Initializes a new instance of the Argument class.
2424
/// </summary>
25-
/// <param name="name">The name of the argument. This can be used to look up the parsed value and is displayed in help</param>
25+
/// <param name="name">The name of the argument. This value can be used to look up the parsed value and is displayed in help if <see cref="HelpName" /> is null.</param>
2626
protected Argument(string name) : base(name, allowWhitespace: true)
2727
{
2828
}
@@ -48,18 +48,18 @@ public ArgumentArity Arity
4848
/// Gets or sets the placeholder name shown in usage help for the argument's value.
4949
/// The value will be wrapped in angle brackets (<c>&lt;</c> and <c>&gt;</c>).
5050
/// </summary>
51+
/// <value>
52+
/// The name to show as the placeholder for the argument's value.
53+
/// </value>
5154
/// <remarks>
52-
/// If <c>null</c>, the <see cref="Symbol.Name"/> of the argument will be used.
55+
/// If <c>null</c>, the <see cref="Symbol.Name"/> of the argument is used.
5356
/// </remarks>
5457
/// <example>
5558
/// An argument with <see cref="Symbol.Name"/> of <c>argument</c> and a
5659
/// <see cref="HelpName"/> of <c>Value</c> will be shown in usage help as:
5760
/// <c>&lt;Value&gt;</c>. If <see cref="HelpName"/> is not set,
5861
/// help output will show: <c>&lt;argument&gt;</c>.
5962
/// </example>
60-
/// <value>
61-
/// The name to show as the placeholder for the argument's value.
62-
/// </value>
6363
public string? HelpName { get; set; }
6464

6565
internal TryConvertArgument? ConvertArguments
@@ -107,12 +107,12 @@ public List<Func<CompletionContext, IEnumerable<CompletionItem>>> CompletionSour
107107
}
108108

109109
/// <summary>
110-
/// Gets or sets the <see cref="Type" /> that the argument's parsed tokens will be converted to.
110+
/// Gets the type that the argument's parsed tokens will be converted to.
111111
/// </summary>
112112
public abstract Type ValueType { get; }
113113

114114
/// <summary>
115-
/// Provides a list of argument validators. Validators can be used
115+
/// Gets a list of argument validators. Validators can be used
116116
/// to provide custom errors based on user input.
117117
/// </summary>
118118
public List<Action<ArgumentResult>> Validators => _validators ??= new ();
@@ -122,7 +122,7 @@ public List<Func<CompletionContext, IEnumerable<CompletionItem>>> CompletionSour
122122
/// <summary>
123123
/// Gets the default value for the argument.
124124
/// </summary>
125-
/// <returns>Returns the default value for the argument, if defined. Null otherwise.</returns>
125+
/// <returns>The default value for the argument, if defined; otherwise, <see langword="null" />.</returns>
126126
public object? GetDefaultValue()
127127
{
128128
var command = Parents.FlattenBreadthFirst(x => x.Parents)
@@ -135,7 +135,7 @@ public List<Func<CompletionContext, IEnumerable<CompletionItem>>> CompletionSour
135135
internal abstract object? GetDefaultValue(ArgumentResult argumentResult);
136136

137137
/// <summary>
138-
/// Specifies if a default value is defined for the argument.
138+
/// Gets a value that indicates if a default value is defined for the argument.
139139
/// </summary>
140140
public abstract bool HasDefaultValue { get; }
141141

src/System.CommandLine/Argument{T}.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ public class Argument<T> : Argument
1515
/// <summary>
1616
/// Initializes a new instance of the Argument class.
1717
/// </summary>
18-
/// <param name="name">The name of the argument. This can be used to look up the parsed value and is displayed in help</param>
18+
/// <param name="name">The name of the argument. This name can be used to look up the parsed value and is displayed in help.</param>
1919
public Argument(string name) : base(name)
2020
{
2121
}
2222

2323
/// <summary>
24-
/// The delegate to invoke to create the default value.
24+
/// Gets or sets the delegate to invoke to create the default value.
2525
/// </summary>
2626
/// <remarks>
27-
/// It's invoked when there was no parse input provided for given Argument.
28-
/// The same instance can be set as <see cref="CustomParser"/>, in such case
27+
/// This delegate is invoked when there was no parse input provided for given Argument.
28+
/// The same instance can be set as <see cref="CustomParser"/>. In that case,
2929
/// the delegate is also invoked when an input was provided.
3030
/// </remarks>
3131
public Func<ArgumentResult, T>? DefaultValueFactory
@@ -45,11 +45,11 @@ public Func<ArgumentResult, T>? DefaultValueFactory
4545
}
4646

4747
/// <summary>
48-
/// A custom argument parser.
48+
/// Gets or sets a custom argument parser.
4949
/// </summary>
5050
/// <remarks>
51-
/// It's invoked when there was parse input provided for given Argument.
52-
/// The same instance can be set as <see cref="DefaultValueFactory"/>, in such case
51+
/// The custom parser is invoked when there was parse input provided for a given Argument.
52+
/// The same instance can be set as <see cref="DefaultValueFactory"/>; in that case,
5353
/// the delegate is also invoked when no input was provided.
5454
/// </remarks>
5555
public Func<ArgumentResult, T?>? CustomParser

src/System.CommandLine/Command.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ namespace System.CommandLine
1818
/// Represents a specific action that the application performs.
1919
/// </summary>
2020
/// <remarks>
21-
/// Use the Command object for actions that correspond to a specific string (the command name). See
22-
/// <see cref="RootCommand"/> for simple applications that only have one action. For example, <c>dotnet run</c>
23-
/// uses <c>run</c> as the command.
21+
/// Use the Command object for actions that correspond to a specific string (the command name).
22+
/// For simple applications that only have one action, see <see cref="RootCommand"/>.
23+
/// For example, <c>dotnet run</c> uses <c>run</c> as the command.
2424
/// </remarks>
2525
public class Command : Symbol, IEnumerable
2626
{
@@ -57,28 +57,31 @@ public IEnumerable<Symbol> Children
5757
}
5858

5959
/// <summary>
60-
/// Represents all of the arguments for the command.
60+
/// Gets all of the arguments for the command.
6161
/// </summary>
6262
public IList<Argument> Arguments => _arguments ??= new(this);
6363

6464
internal bool HasArguments => _arguments?.Count > 0 ;
6565

6666
/// <summary>
67-
/// Represents all of the options for the command, inherited options that have been applied to any of the command's ancestors.
67+
/// Gets all of the options for the command.
6868
/// </summary>
69+
/// <remarks>
70+
/// This collection doesn't include options on parent commands where <see cref="Option.Recursive">Option.Recursive</see> is <see langword="true" />. Those options are valid under the current command but don't appear in this collection.
71+
/// </remarks>
6972
public IList<Option> Options => _options ??= new (this);
7073

7174
internal bool HasOptions => _options?.Count > 0;
7275

7376
/// <summary>
74-
/// Represents all of the subcommands for the command.
77+
/// Gets all of the subcommands for the command.
7578
/// </summary>
7679
public IList<Command> Subcommands => _subcommands ??= new(this);
7780

7881
internal bool HasSubcommands => _subcommands is not null && _subcommands.Count > 0;
7982

8083
/// <summary>
81-
/// Validators to the command. Validators can be used
84+
/// Gets the validators to the command. Validators can be used
8285
/// to create custom validation logic.
8386
/// </summary>
8487
public List<Action<CommandResult>> Validators => _validators ??= new ();
@@ -215,9 +218,9 @@ public void SetAction(Func<ParseResult, CancellationToken, Task<int>> action)
215218
/// </summary>
216219
/// <param name="argument">The option to add to the command.</param>
217220
public void Add(Argument argument) => Arguments.Add(argument);
218-
221+
219222
/// <summary>
220-
/// Adds a <see cref="Option"/> to the command.
223+
/// Adds an <see cref="Option"/> to the command.
221224
/// </summary>
222225
/// <param name="option">The option to add to the command.</param>
223226
public void Add(Option option) => Options.Add(option);
@@ -226,17 +229,17 @@ public void SetAction(Func<ParseResult, CancellationToken, Task<int>> action)
226229
/// Adds a <see cref="Command"/> to the command.
227230
/// </summary>
228231
/// <param name="command">The Command to add to the command.</param>
229-
public void Add(Command command) => Subcommands.Add(command);
232+
public void Add(Command command) => Subcommands.Add(command);
230233

231234
/// <summary>
232-
/// Gets or sets a value that indicates whether unmatched tokens should be treated as errors. For example,
233-
/// if set to <see langword="true"/> and an extra command or argument is provided, validation will fail.
235+
/// Gets or sets a value that indicates whether unmatched tokens should be treated as errors.
234236
/// </summary>
237+
/// <value><see langword="true"/> to fail validation when an extra command or argument is provided; otherwise, <see langword="false"/>.</value>
235238
public bool TreatUnmatchedTokensAsErrors { get; set; } = true;
236239

237240
/// <inheritdoc />
238241
[DebuggerStepThrough]
239-
[EditorBrowsable(EditorBrowsableState.Never)] // hide from intellisense, it's public for C# collection initializer
242+
[EditorBrowsable(EditorBrowsableState.Never)] // hide from intellisense, it's public for C# collection initializer
240243
IEnumerator IEnumerable.GetEnumerator() => Children.GetEnumerator();
241244

242245
/// <summary>

src/System.CommandLine/Completions/SuggestDirective.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace System.CommandLine.Completions;
44

55
/// <summary>
6-
/// Enables the use of the <c>[suggest]</c> directive which when specified in command line input short circuits normal command handling and writes a newline-delimited list of suggestions suitable for use by most shells to provide command line completions.
6+
/// Enables the use of the <c>[suggest]</c> directive, which, when specified in command-line input, short circuits normal command handling and writes a newline-delimited list of suggestions suitable for use by most shells to provide command line completions.
77
/// </summary>
88
/// <remarks>The <c>dotnet-suggest</c> tool requires the suggest directive to be enabled for an application to provide completions.</remarks>
99
public sealed class SuggestDirective : Directive
@@ -22,4 +22,4 @@ public override CommandLineAction? Action
2222
set => _action = value ?? throw new ArgumentNullException(nameof(value));
2323
}
2424

25-
}
25+
}

src/System.CommandLine/Directive.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
namespace System.CommandLine
99
{
1010
/// <summary>
11-
/// The purpose of directives is to provide cross-cutting functionality that can apply across command-line apps.
11+
/// Provides cross-cutting functionality that can apply across command-line apps.
12+
/// </summary>
13+
/// <remarks>
1214
/// Because directives are syntactically distinct from the app's own syntax, they can provide functionality that applies across apps.
13-
///
15+
///
1416
/// A directive must conform to the following syntax rules:
1517
/// * It's a token on the command line that comes after the app's name but before any subcommands or options.
1618
/// * It's enclosed in square brackets.
1719
/// * It doesn't contain spaces.
18-
/// </summary>
20+
/// </remarks>
1921
public class Directive : Symbol
2022
{
2123
/// <summary>

src/System.CommandLine/Help/HelpAction.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
namespace System.CommandLine.Help
44
{
55
/// <summary>
6-
/// Provides command line help.
6+
/// Provides command-line help.
77
/// </summary>
88
public sealed class HelpAction : SynchronousCommandLineAction
99
{
1010
private HelpBuilder? _builder;
1111
private int _maxWidth = -1;
1212

1313
/// <summary>
14-
/// The maximum width in characters after which help output is wrapped.
14+
/// Gets or sets the maximum width in characters after which help output is wrapped.
1515
/// </summary>
16-
/// <remarks>It defaults to <see cref="Console.WindowWidth"/>.</remarks>
16+
/// <value>The maximum width in characters after which help output is wrapped. The default is <see cref="Console.WindowWidth"/>.</value>
1717
public int MaxWidth
18-
{
18+
{
1919
get
2020
{
2121
if (_maxWidth < 0)
@@ -44,7 +44,7 @@ public int MaxWidth
4444
}
4545

4646
/// <summary>
47-
/// Specifies an <see cref="Builder"/> to be used to format help output when help is requested.
47+
/// Gets or sets the <see cref="Builder"/> to use to format help output.
4848
/// </summary>
4949
internal HelpBuilder Builder
5050
{
@@ -68,4 +68,4 @@ public override int Invoke(ParseResult parseResult)
6868

6969
public override bool ClearsParseErrors => true;
7070
}
71-
}
71+
}

src/System.CommandLine/Invocation/ParseErrorAction.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
namespace System.CommandLine.Invocation;
1111

1212
/// <summary>
13-
/// Provides command line output with error details in the case of a parsing error.
13+
/// Provides command-line output with error details in the case of a parsing error.
1414
/// </summary>
1515
public sealed class ParseErrorAction : SynchronousCommandLineAction
1616
{
1717
/// <summary>
18-
/// Indicates whether to show help along with error details when an error is found during parsing.
18+
/// Gets or sets a value that indicates whether to show help along with error details when an error is found during parsing.
1919
/// </summary>
20-
/// <remarks>When set to <see langword="true" />, indicates that help will be shown along with parse error details. When set to false, help will not be shown.</remarks>
20+
/// <value><see langword="true" /> to show help along with parse error details. <see langword="false" /> to not show help.</value>
2121
public bool ShowHelp { get; set; } = true;
2222

2323
/// <summary>
24-
/// Indicates whether to show typo suggestions along with error details when an error is found during parsing.
24+
/// Gets or sets a value that indicates whether to show typo suggestions along with error details when an error is found during parsing.
2525
/// </summary>
26-
/// <remarks>When set to <see langword="true" />, indicates that suggestions will be shown along with parse error details. When set to false, suggestions will not be shown.</remarks>
26+
/// <value><see langword="true" /> to show suggestions along with parse error details. <see langword="false" /> to now show suggestions.</value>
2727
public bool ShowTypoCorrections { get; set; } = true;
2828

2929
/// <inheritdoc />
@@ -232,4 +232,4 @@ static int GetDistance(string first, string second)
232232
}
233233

234234
private const int MaxLevenshteinDistance = 3;
235-
}
235+
}

src/System.CommandLine/InvocationConfiguration.cs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,46 @@ public class InvocationConfiguration
99
private TextWriter? _output, _error;
1010

1111
/// <summary>
12-
/// Enables a default exception handler to catch any unhandled exceptions thrown during invocation. Enabled by default.
12+
/// Gets or sets a value that indicates whether a default exception handler catches any unhandled exceptions thrown during invocation.
1313
/// </summary>
14+
/// <value><see langword="true"/> if a default exception handler catches any unhandled exceptions thrown during invocation. The default is <see langword="true"/>.</value>
1415
public bool EnableDefaultExceptionHandler { get; set; } = true;
1516

1617
/// <summary>
17-
/// Enables signaling and handling of process termination (Ctrl+C, SIGINT, SIGTERM) via a <see cref="CancellationToken"/>
18+
/// Gets or sets a time span that enables signaling and handling of process termination (Ctrl+C, SIGINT, SIGTERM) via a <see cref="CancellationToken"/>
1819
/// that can be passed to a <see cref="CommandLineAction"/> during invocation.
19-
/// If not provided, a default timeout of 2 seconds is enforced.
2020
/// </summary>
21-
public TimeSpan? ProcessTerminationTimeout { get; set; } = TimeSpan.FromSeconds(2);
21+
/// <value>The default is two seconds.</value>
22+
/// <remarks>
23+
/// If this property is set to <see langword="null" />, the termination request isn't handled by System.CommandLine. In that case, the process is terminated immediately unless some other part of the program adds a handler.
24+
/// </remarks>
25+
public TimeSpan? ProcessTerminationTimeout { get; set; } = TimeSpan.FromSeconds(2);
2226

2327
/// <summary>
24-
/// The standard output. Used by Help and other facilities that write non-error information.
25-
/// By default it's set to <see cref="Console.Out"/>.
26-
/// For testing purposes, it can be set to a new instance of <see cref="StringWriter"/>.
27-
/// If you want to disable the output, please set it to <see cref="TextWriter.Null"/>.
28+
/// Gets or sets the standard output.
2829
/// </summary>
30+
/// <value>The default is set to <see cref="Console.Out"/>.</value>
31+
/// <remarks>
32+
/// The standard output is used by Help and other facilities that write non-error information.
33+
/// For testing purposes, it can be set to a new instance of <see cref="StringWriter"/>.
34+
/// If you want to disable the output, set it to <see cref="TextWriter.Null"/>.
35+
/// </remarks>
2936
public TextWriter Output
3037
{
3138
get => _output ??= Console.Out;
3239
set => _output = value ?? throw new ArgumentNullException(nameof(value), "Use TextWriter.Null to disable the output");
3340
}
3441

3542
/// <summary>
36-
/// The standard error. Used for printing error information like parse errors.
37-
/// By default it's set to <see cref="Console.Error"/>.
38-
/// For testing purposes, it can be set to a new instance of <see cref="StringWriter"/>.
43+
/// Gets or sets the standard error used for printing error information like parse errors.
3944
/// </summary>
45+
/// <value>The default is set to <see cref="Console.Error"/>.</value>
46+
/// <remarks>
47+
/// For testing purposes, it can be set to a new instance of <see cref="StringWriter"/>.
48+
/// </remarks>
4049
public TextWriter Error
4150
{
4251
get => _error ??= Console.Error;
4352
set => _error = value ?? throw new ArgumentNullException(nameof(value), "Use TextWriter.Null to disable the output");
4453
}
45-
}
54+
}

0 commit comments

Comments
 (0)