19 Commits
Author SHA1 Message Date
Rauhul Varma 10d80282e5 Enable swift-format checking (#711)
Adopts the common swift-mmio and swift-argument-parser format and enables CI checking.

Fixes: #702
2025-02-10 14:58:19 -08:00
Ross Goldberg aefbb6e28d Fix Swift 5.7 build errors. (#707) 2025-02-06 20:28:38 -08:00
Rauhul Varma 9289e315f8 Add generate-docc-reference plugin (#694)
Upstreams swiftly's generate-docs-plugin with minimal changes. Adds
tests against argument-parser's built in example tools.

The initial version of this tool is extremely minimal and should be
extended to output much more information contained in tool info, like
generate-manual does.
2025-02-05 10:05:45 -08:00
Rauhul Varma 25db036b71 Refactor serialization of dump help descriptions (#693)
Cleans up some lingering odds and ends from #647. Specifically switches
CommandInfoV0 to use the old style description and updates
ArgumentInfoV0 to emit value descriptions as a separate dictionary.
2025-02-04 17:04:42 -08:00
Ross Goldberg e4009c1616 Fix Swift 5.7 build errors (#676)
Insert missing comma in targets array in Package.swift to fix Swift 5.7 build
break from commit 83c5134a24.

Replace 2 if expressions (which are not supported by Swift 5.7) that were added
to ToolInfo.swift by commit 83c5134a24.

Replace switch expression (which is not supported by Swift 5.7) that was added
to GenerateManual.swift by commit 44dd206a85.

Replace switch expression (which is not supported by Swift 5.7) that was added
to DumpHelpGenerationTests.swift by commit 83c5134a24.

Fixes #675

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
2024-11-06 08:57:16 -08:00
Bri Peticca 83c5134a24 Add ability to provide descriptions for CaseEnumerable @Option values (#647)
Since `ExpressibleByArgument` already maintains a list of
enumerable values for an argument, we can extend this to serve
as an ordered list for a new dictionary property that maps the
value name to its description, if applicable. The new property
is a static variable on `ExpressibleByArgument` labelled
`allValueDescriptions`.

If the description string for a value is the same as the value
string, it's assumed that the description is not implemented.

The new value strings are used in the help screen, in the 
dump-help JSON output, and in the generated manual.
2024-09-30 14:17:48 -05:00
Joseph Heck 7f9f965856 removes hidden arguments for generate-manual (#667)
- adds check in single and multipage to leverage hidden description in
  help dump to determine if the argument should be displayed
- adds check in argument synopsis to only display synopsis if not hidden
- updates existing tests that _had_ hidden output displayed in the
  generate-manual output
2024-09-30 13:46:45 -05:00
Rauhul Varma 44dd206a85 Improve generate-manual error descriptions (#663)
Adds a human readable description to `GenerateManualError` and updates
the non-zero exit code error to include stderr to aid debugging.

Fixes: #653
2024-09-14 18:58:36 -07:00
Nate Cook d9182a9d33 Suppress retroactive conformance errors (#603)
These warnings are showing up in tests about types and protocols
that are defined within this package, so they don't pose a problem
for future library evolution. Instead of using the `@retroactive`
attribute, which isn't supported by older compilers, this change
fully qualifies the type and protocol in the relevant conformance
declarations, which suppresses the issue.

Re: https://github.com/apple/swift-evolution/blob/main/proposals/0364-retroactive-conformance-warning.md
2023-11-20 13:51:19 -06:00
Nate Cook b7f5d8cff2 Update GH models in changelog-authors (#589) 2023-10-26 10:02:12 -05:00
Rauhul Varma 5649a380d7 Add subcommand abstracts to single-page manuals (#552)
- Fixes a bug where signle-page manuals did not include subcommand
  abstracts because the DSL logic did not take to account root commands
  vs subcommands. This change adds a "root" property to the DSL element
  to allow for styling differences in the two cases.
2023-02-14 21:54:42 -08:00
Rauhul Varma b1b0595a96 Fix missing option value names in manuals (#473)
- Fixes a manual generation bug where options in the synopsis were not
  given a value name and flags were.
2022-08-26 00:08:04 -07:00
Rauhul Varma e978a3831f Default to single page manuals (#472)
- Changes the generate-manual --single-page argument to --multi-page, so
  generate-manual with create a single manual page with all subcommand
  information by default instead of many distinct files.
2022-08-26 00:03:35 -07:00
Rauhul Varma 4b93f3ecb3 Fix generate-manual plugin authors argument (#471)
- Fixes an issue where the --author option was passed without its value
  by the generate-manual plugin to the generate-manual tool resulting in
  plugin invocation failures or incorrect author information.
2022-08-25 09:47:57 -07:00
Rauhul Varma 48a799e04a Add experimental manual page generation (#332)
- Adds a swift package manager command plugin called
  GenerateManualPlugin. The plugin can be invoked from the command line
  using `swift package experimental-generate-manual`. The plugin is
  prefixed for now with "experimental-" to indicate it is not mature and
  may see breaking changes to its CLI and output in the future. The
  plugin can be can be used to generate a manual in MDoc syntax for any
  swift-argument-parser tool that can be executed via
  `tool --experimental-dump-info`.
- The plugin works by converting the `ToolInfoV0` structure from the
  `ArgumentParserToolInfo` library into MDoc AST nodes using a custom
  (SwiftUI-esk) result builder DSL. The MDoc AST is then lowered to a
  string and written to disk.
- The MDoc AST included is not general purpose and doesn't represent the
  true language exactly, so it is private to the underlying
  `generate-manual` tool. In the future it would be interesting to
  finish fleshing out this MDoc library and spin it out, however this is
  not a priority.
- Next steps include:
  - Improving the command line interface for the plugin.
  - Adding support for "extended discussions" to Commands and exposing
    this information in manuals.
  - Further improve the escaping logic to properly escape MDoc macros
    that might happen to appear in user's help strings.
  - Ingesting external content a-la swift-docc so the entire tool
    documentation does not need to be included in the binary itself.
  - Bug fixes and addressing developer/user feedback.

Built with love,
@rauhul
2022-06-06 11:09:34 -05:00
Nate Cook 1141ed1e1b Support an async entry point for commands (#404)
Adds a new `AsyncParsableCommand` protocol, which provides a
`static func main() async` entry point and can call through to the root
command's or a subcommand's asynchronous `run()` method. For this
asynchronous execution, the root command must conform to `AsyncParsableCommand`,
but its subcommands can be a mix of asynchronous and synchronous commands.

Due to an issue in Swift 5.5, you can only use `@main` on an
`AsyncParsableCommand` root command starting in Swift 5.6.
This change also includes a workaround for clients that are using Swift 5.5.
Declare a separate type that conforms to `AsyncMainProtocol` and add the `@main`
attribute to that type.

```
@main enum Main: AsyncMain {
    typealias Command = <#command#>
}
```
2022-03-14 18:14:09 -05:00
Nate Cook fe71d4007d Allow changelog authors tool to work with other repos (#311) 2021-05-17 15:32:17 -05:00
Nate CookandErik Little aad1ac085b Make ParsableCommand.run() a mutating method (#163)
Co-authored-by: Erik Little <nuclear.ace@gmail.com>
2020-06-02 14:07:16 -05:00
Nate Cook 5f49a17c6a Add a tool for getting the authors within a range of commits from GitHub (#146)
* Add a tool for getting the authors within a range of commits from GitHub

* Switch to 5.1 syntax
2020-05-15 15:01:12 -05:00