-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add --include-extended-types flag #34
Add --include-extended-types flag #34
Conversation
82a5a41
to
9f979e0
Compare
--include-extended-types
flag
--include-extended-types
flag04aed7c
to
e0b5fa9
Compare
@ethan-kusters this PR is ready for review now! |
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.
Looks great! Just added a few initial thoughts.
print("warning: detected '--emit-extension-block-symbols' option, which is incompatible with your swift version (required: 5.8)") | ||
#endif | ||
default: | ||
print("warning: detected unknown dump-symbol-graph option '\(argument)'") |
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.
Should we fatalError
here? This is a programmer error, right? It shouldn't be possible to receive an unknown flag 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.
For the incompatible version I'd prefer to do it the same way as in SwiftPM, i.e. emitting a warning (see swiftlang/swift-package-manager#5892 (comment)).
The typed configuration options you suggested make the default case for unknown flags redundant anyway.
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.
Plugins/SharedPackagePluginExtensions/Target+defaultSymbolGraphOptions.swift
Outdated
Show resolved
Hide resolved
Plugins/SharedPackagePluginExtensions/Target+defaultSymbolGraphOptions.swift
Show resolved
Hide resolved
@@ -19,10 +19,25 @@ public struct ParsedArguments { | |||
return arguments.contains("--help") || arguments.contains("-h") | |||
} | |||
|
|||
/// Returns the arguments that could be passed to `swift package dump-symbol-graph`. | |||
/// | |||
/// In practice, however we won't invoke the `dump-symbol-graph` command via the command line, |
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.
Should we consider a different way to represent this information instead of strings representing the flags since we're going to re-parse them anyway?
I think tying this implementation to swift package dump-symbol-graph
is kind of unnecessarily confusing for folks who might be familiar with SwiftPM plugins but not that specific command.
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 think that might be a good idea. I gave it a try based on the following protocol:
/// Transforms a set of arguments, transferring information to a typed configuration.
protocol ArgumentsTransformer: ArgumentsTransforming {
associatedtype Configuration
/// Apply the transformation to the given arguments and configuration.
func transform(arguments: inout Arguments, configuration: inout Configuration)
}
Please take a look and let me know what you think about it. I'm not super happy with the result, but I'm also not really happy with the whole CLI parsing setup in this plugin. I'm also wondering if a ArgumentParser based rewrite wouldn't be favorable in general.
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 also wondering if a ArgumentParser based rewrite wouldn't be favorable in general.
This is 100% what I'd like to do long-term. We're just blocked on SwiftPM support to allow command plugins to have dependencies: swiftlang/swift-package-manager#5574.
I'm worried this approach with the generic Configuration
is over-optimizing for what we need here. I'm curious if you've looked at the approach in #28? It's less extensible but since we're likely going to need to overhaul our argument parsing solution here in the long-term anyway I wonder if something along those lines would be more maintainable in the shorter term.
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.
This is 100% what I'd like to do long-term. We're just blocked on SwiftPM support to allow command plugins to have dependencies: swiftlang/swift-package-manager#5574.
Ah, yeah, I forgot about that :)
I'm worried this approach with the generic Configuration is over-optimizing for what we need here. I'm curious if you've looked at the approach in #28? It's less extensible but since we're likely going to need to overhaul our argument parsing solution here in the long-term anyway I wonder if something along those lines would be more maintainable in the shorter term.
I felt so too, and, now that I've looked at #28, I agree it's the better short-term solution. I adopted the approach, making sure to cause as little merge-conflicts as possible. I only kept the filter(for:)
function in ParsedArguments
from my approach, as I felt like without it it would be too easy to accidentally have flags passed to docc
that are not meant for it.
@swift-ci please test |
1 similar comment
@swift-ci please test |
959aa39
to
e4a1a48
Compare
@@ -19,10 +19,25 @@ public struct ParsedArguments { | |||
return arguments.contains("--help") || arguments.contains("-h") | |||
} | |||
|
|||
/// Returns the arguments that could be passed to `swift package dump-symbol-graph`. | |||
/// | |||
/// In practice, however we won't invoke the `dump-symbol-graph` command via the command line, |
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 also wondering if a ArgumentParser based rewrite wouldn't be favorable in general.
This is 100% what I'd like to do long-term. We're just blocked on SwiftPM support to allow command plugins to have dependencies: swiftlang/swift-package-manager#5574.
I'm worried this approach with the generic Configuration
is over-optimizing for what we need here. I'm curious if you've looked at the approach in #28? It's less extensible but since we're likely going to need to overhaul our argument parsing solution here in the long-term anyway I wonder if something along those lines would be more maintainable in the shorter term.
e4a1a48
to
e71e7c3
Compare
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.
Looks great! Thank you so much for your work here – really excited to get this in.
Could you add a of couple integration tests as well before landing this? I put together a patch just as an example (the integration test suite is a little tricky/weird) that I think gives enough basic coverage but feel free to expand from there or discard it entirely:
git apply add-integration-test.patch
You can open up the sub-package in the swift-docc-plugin/IntegrationTests
subdirectory to run the tests. (I think the parent package needs to be closed for things to work.)
@ethan-kusters I expanded your test with a protocol conformance, but I don't think it makes sense to go any further. After all, the tests here should just verify that the plugin invokes the toolchain correctly, which can easily be verified with these simple cases. Anything beyond that should be/is tested in |
@swift-ci please test |
1 similar comment
@swift-ci please test |
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.
Looks great! Thank you! 🚀
The --include-extended-types flag is transformed to the --emit-extension-block-symbols flag of the swift package dump-symbol-graph command. It is available starting from Swift 5.8.
ec963f0
to
a1f5339
Compare
@swift-ci please test |
@swift-ci please test |
Bug/issue #, if applicable: swiftlang/swift-docc#210
Summary
The
--include-extended-types
flag is transformed to the--emit-extension-block-symbols
flag of theswift package dump-symbol-graph
command. It is available starting from Swift 5.8.Dependencies
All dependencies have been merged. For an overview see swiftlang/swift-docc#210 (comment).
Testing
main
orrelease/5.8
branches after December 21stswift-docc-plugin
to yourPackage.swift
:--include-extended-types
flag when running your commandVerifying the basic functionality can be done with this sample repository. Running
swift package --disable-sandbox preview-documentation --include-extended-types --target NestedTypes
should produce the result shown below:Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded:Swift 5.7.2:
.bin/test
succeededSwift 5.8/main nightly:
.bin/test
succeeded after removing the--parallel
flag fromswift test
invocations in the script (Runningswift test --parallel
on any package fails for me with an error similar to the one described here. However, this is an issue with the nightly toolchains I've been getting for a while now.)