Skip to content

Commit e344426

Browse files
authored
Add documentation comments to generateHelpNames (#411)
1 parent e367368 commit e344426

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Sources/ArgumentParser/Usage/HelpGenerator.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ fileprivate extension CommandConfiguration {
265265
}
266266

267267
fileprivate extension NameSpecification {
268+
/// Generates a list of `Name`s for the help command at any visibility level.
269+
///
270+
/// If the `default` visibility is used, the help names are returned
271+
/// unmodified. If a non-default visibility is used the short names are
272+
/// removed and the long names (both single and double dash) are appended with
273+
/// the name of the visibility level. After the optional name modification
274+
/// step, the name are returned in descending order.
268275
func generateHelpNames(visibility: ArgumentVisibility) -> [Name] {
269276
self
270277
.makeNames(InputKey(rawValue: "help"))
@@ -285,8 +292,11 @@ fileprivate extension NameSpecification {
285292
}
286293

287294
internal extension BidirectionalCollection where Element == ParsableCommand.Type {
295+
/// Returns a list of help names at the request visibility level for the top
296+
/// most ParsableCommand in the command stack with custom helpNames. If the
297+
/// command stack contains no custom help names the default help names.
288298
func getHelpNames(visibility: ArgumentVisibility) -> [Name] {
289-
return self.last(where: { $0.configuration.helpNames != nil })
299+
self.last(where: { $0.configuration.helpNames != nil })
290300
.map { $0.configuration.helpNames!.generateHelpNames(visibility: visibility) }
291301
?? CommandConfiguration.defaultHelpNames.generateHelpNames(visibility: visibility)
292302
}

0 commit comments

Comments
 (0)