-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SR-15314: Update help information for command #10
SR-15314: Update help information for command #10
Conversation
@@ -22,7 +22,7 @@ public struct DocumentationBundleOption: ParsableArguments { | |||
/// The path to a bundle to be compiled by DocC. | |||
@Argument( | |||
help: ArgumentHelp( | |||
"Path to a documentation bundle directory.", | |||
"Path to a documentation archive ('.doccarchive') data directory of JSON files.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the of JSON files
, I considered:
- omitting it completely
- current wording
- using
containing
instead ofof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this PR.
DocumentationBundleOption
is used by both the convert action (Convert.swift) and the index action (Index.swift) for its validation and fallback logic. This change would update the help text for both.
Since the convert command is passed a “documentation catalog” (.docc) and the index command is passed a “documentation archive” (.doccarchive) I think that it would be good if these could have different ArgumentHelp
information but continue to share the validation and fallback logic.
@d-ronnqvist Sorry, I missed that the option was used for both commands, what I did to keep the logic shared was create a new Does this seem like the correct approach to you? I may be missing language features that could simplify this solution, but this appeared to be the most logical. I also added screenshots of the help output for both commands in the PR body. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a protocol to share this logic looks great. Since it’s a public protocol I would want to document why it exists and what it does. I would also like to find a more specific name for this protocol.
Perhaps something something like this:
/// A parsable argument for an optional directory path.
///
/// This option validates the the provided path exists and that it's a directory.
public protocol DirectoryPathOption: ParsableArguments { ... }
|
||
/// Resolves and validates a URL value that provides the path to a documentation directory. | ||
public protocol DocumentationOption: ParsableArguments { | ||
var url: URL? { get } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea.
It could be taken further by instead having the ArgumentHelp
in the protocol
var url: URL? { get } | |
/// The help information for this directory's `url` argument. | |
static var argumentHelp: ArgumentHelp? |
and defining the url
in the extension
:
extension DirectoryPathOption {
/// The path to a directory.
@Argument(
help: argumentHelp,
transform: URL.init(fileURLWithPath:))
public var url: URL?
/// The provided ``url`` or the "current directory" if the user didn't provide an argument.
public var urlOrFallback: URL {
return url ?? URL(fileURLWithPath: ".")
}
public mutating func validate() throws { … }
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@d-ronnqvist I like this idea, but Swift doesn't support stored properties in extensions right? From what I can tell, we also can't use wrappers in extensions either.
I was looking around to see if I can find a solution, but I'm not sure if there's a very clean one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies. I though that that would work if the extension was declared in the same file as the protocol but it doesn’t. I tried and even if the url
property wasn’t stored it still couldn’t have a property wrapper in the extension. What you’ve done looks like the best solution here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. This looks great.
The Linux builds are currently failing because of https://bugs.swift.org/browse/SR-15362. Once that has landed in a toolchain I will rerun the tests and merge this PR once the CI has passed.
|
||
/// Resolves and validates a URL value that provides the path to a documentation archive. | ||
/// | ||
/// This option is used by the ``Docc/Index`` subcommand. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. A symbol link helps put this option in context. 👍
@swift-ci test |
@franklinsch I updated the branch with main but that seems to have wiped the test results, sorry |
No need to apologize! Triggering a new one: @swift-ci please test |
Bug/issue #, if applicable: SR-15314
Summary
The
docc index
command expects adata
directory from a Documentation Archive, this was not clearly conveyed in the help message, the goal of this PR is to make this a bit more clear.Dependencies
No dependencies
Testing
Run
docc index --help
Index command help
Convert command help
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded - No: Some tests are failing but seems unrelated to my PR, created SR-15349