Skip to content

Commit 8821bc7

Browse files
authored
docs: improve dart docs (#28)
1 parent e8585d6 commit 8821bc7

28 files changed

+138
-94
lines changed

.idea/runConfigurations/Integration_tests.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

doc/README.md

Whitespace-only changes.

lib/cli_completion.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@ library cli_completion;
44

55
export 'src/command_runner/commands/commands.dart';
66
export 'src/command_runner/completion_command_runner.dart';
7-
export 'src/handling/completion_result.dart';
8-
export 'src/handling/completion_state.dart';
9-
export 'src/system_shell.dart';

lib/install.dart

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/installer.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// Contains the functions related to the installation process
2+
/// {@canonicalFor system_shell.SystemShell}
3+
library installer;
4+
5+
export 'src/installer/completion_installation.dart';
6+
export 'src/installer/exceptions.dart';
7+
export 'src/installer/shell_completion_configuration.dart';
8+
export 'src/system_shell.dart';

lib/parser.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// Contains the classes and functions related to the creation of suggestions
2+
/// for the completion of commands.
3+
library parser;
4+
5+
export 'src/parser/completion_level.dart';
6+
export 'src/parser/completion_result.dart';
7+
export 'src/parser/completion_state.dart';
8+
export 'src/parser/parser.dart';
9+
export 'src/system_shell.dart';

lib/src/command_runner/commands/handle_completion_command.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import 'dart:async';
22

33
import 'package:args/command_runner.dart';
4-
import 'package:cli_completion/src/command_runner/completion_command_runner.dart';
5-
import 'package:cli_completion/src/handling/completion_level.dart';
6-
import 'package:cli_completion/src/handling/completion_state.dart';
7-
import 'package:cli_completion/src/handling/parser.dart';
4+
import 'package:cli_completion/cli_completion.dart';
5+
import 'package:cli_completion/parser.dart';
86

97
/// {@template handle_completion_request_command}
108
/// A hidden [Command] added by [CompletionCommandRunner] that handles the

lib/src/command_runner/commands/install_completion_files_command.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import 'dart:async';
22

33
import 'package:args/command_runner.dart';
4-
import 'package:cli_completion/src/command_runner/completion_command_runner.dart';
5-
4+
import 'package:cli_completion/cli_completion.dart';
65
import 'package:mason_logger/mason_logger.dart';
76

87
/// {@template install_completion_command}
9-
/// A hidden [Command] added by [CompletionCommandRunner] that can be used to
10-
/// manually install the completion files
8+
/// A hidden [Command] added by [CompletionCommandRunner] that handles the
9+
/// "install-completion-files" sub command.
10+
///
11+
/// It can be used to manually install the completion files
1112
/// (otherwise automatically installed by [CompletionCommandRunner]).
1213
/// {@endtemplate}
1314
///

lib/src/command_runner/completion_command_runner.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import 'dart:async';
33
import 'package:args/args.dart';
44
import 'package:args/command_runner.dart';
55
import 'package:cli_completion/cli_completion.dart';
6-
import 'package:cli_completion/src/exceptions.dart';
7-
import 'package:cli_completion/src/install/completion_installation.dart';
6+
import 'package:cli_completion/installer.dart';
7+
import 'package:cli_completion/parser.dart';
88
import 'package:mason_logger/mason_logger.dart';
99
import 'package:meta/meta.dart';
1010

lib/src/install/completion_installation.dart renamed to lib/src/installer/completion_installation.dart

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import 'dart:io';
22

3-
import 'package:cli_completion/src/exceptions.dart';
4-
import 'package:cli_completion/src/install/shell_completion_configuration.dart';
5-
import 'package:cli_completion/src/system_shell.dart';
3+
import 'package:cli_completion/installer.dart';
64
import 'package:mason_logger/mason_logger.dart';
75
import 'package:meta/meta.dart';
86
import 'package:path/path.dart' as path;
97

108
/// {@template shell_completion_installation}
11-
/// A description of a completion installation process for a specific shell.
9+
/// Manages the installation of completion scripts for the current shell.
1210
///
1311
/// Creation should be done via [CompletionInstallation.fromSystemShell].
1412
/// {@endtemplate}
@@ -22,7 +20,16 @@ class CompletionInstallation {
2220
required this.environment,
2321
});
2422

25-
/// Creates a [CompletionInstallation] given the current [SystemShell].
23+
/// Creates a [CompletionInstallation] given the current [systemShell].
24+
///
25+
/// If [systemShell] is null, it will assume that the current shell is
26+
/// unknown and [configuration] will be null.
27+
///
28+
/// Pass [isWindowsOverride] to override the default value of
29+
/// [Platform.isWindows].
30+
///
31+
/// Pass [environmentOverride] to override the default value of
32+
/// [Platform.environment].
2633
factory CompletionInstallation.fromSystemShell({
2734
required SystemShell? systemShell,
2835
required Logger logger,
@@ -54,11 +61,18 @@ class CompletionInstallation {
5461
/// equals to [Platform.environment].
5562
final Map<String, String> environment;
5663

57-
/// The associated [ShellCompletionConfiguration].
64+
/// The associated [ShellCompletionConfiguration] inferred from the current
65+
/// shell. It is null if the current shell is unknown.
5866
final ShellCompletionConfiguration? configuration;
5967

6068
/// Define the [Directory] in which the
6169
/// completion configuration files will be stored.
70+
///
71+
/// If [isWindows] is true, it will return the directory defined by
72+
/// %LOCALAPPDATA%/DartCLICompletion
73+
///
74+
/// If [isWindows] is false, it will return the directory defined by
75+
/// $HOME/.dart_cli_completion
6276
@visibleForTesting
6377
Directory get completionConfigDir {
6478
if (isWindows) {
@@ -72,8 +86,17 @@ class CompletionInstallation {
7286
}
7387
}
7488

75-
/// Install completion configuration hooks for a [rootCommand] in the
89+
/// Install completion configuration files for a [rootCommand] in the
7690
/// current shell.
91+
///
92+
/// It will create:
93+
/// - A completion script file in [completionConfigDir] that is named after
94+
/// the [rootCommand] and the current shell (e.g. `very_good.bash`).
95+
/// - A config file in [completionConfigDir] that is named after the current
96+
/// shell (e.g. `bash-config.bash`) that sources the aforementioned
97+
/// completion script file.
98+
/// - A line in the shell config file (e.g. `.bash_profile`) that sources
99+
/// the aforementioned config file.
77100
void install(String rootCommand) {
78101
final configuration = this.configuration;
79102

@@ -95,7 +118,10 @@ class CompletionInstallation {
95118
writeToShellConfigFile(rootCommand);
96119
}
97120

98-
/// Create a directory in which the completion config files shall be saved
121+
/// Create a directory in which the completion config files shall be saved.
122+
/// If the directory already exists, it will do nothing.
123+
///
124+
/// The directory is defined by [completionConfigDir].
99125
@visibleForTesting
100126
void createCompletionConfigDir() {
101127
final completionConfigDirPath = completionConfigDir.path;
@@ -117,6 +143,13 @@ class CompletionInstallation {
117143

118144
/// Creates a configuration file exclusively to [rootCommand] and the
119145
/// identified shell.
146+
///
147+
/// The file will be named after the [rootCommand] and the current shell
148+
/// (e.g. `very_good.bash`).
149+
///
150+
/// The file will be created in [completionConfigDir].
151+
///
152+
/// If the file already exists, it will do nothing.
120153
@visibleForTesting
121154
void writeCompletionScriptForCommand(String rootCommand) {
122155
final configuration = this.configuration!;
@@ -185,7 +218,7 @@ class CompletionInstallation {
185218
_resolveHome(configuration!.shellRCFile, environment);
186219

187220
/// Write a source to the completion global script in the shell configuration
188-
/// file, which its location is described by the [configuration]
221+
/// file, which its location is described by the [configuration].
189222
@visibleForTesting
190223
void writeToShellConfigFile(String rootCommand) {
191224
final configuration = this.configuration!;

0 commit comments

Comments
 (0)