Skip to content

Fix a bug where targets with multiple dependencies was only passed one dependency #98

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

Merged
merged 11 commits into from
Sep 10, 2024

Conversation

d-ronnqvist
Copy link
Contributor

Bug/issue #, if applicable: #97

Summary

This fixes an issue where the plugin would only pass one --dependency value when building combined documentation.

@sofiaromorales and I worked together on the initial fix and made some additional API refinements to the way that the plugin works with command line arguments to make it ensure that an option always has the same behavior at every call site and that an option can't accidentally be used as a flag or vice-versa.

After what Sofía and I worked on, I made some follow-up changes to use the Flag and Option types in more places, move the inverseNames into Flag, and use CommandLineArguments for the docc merge arguments to avoid that direct [String] manipulation.

Dependencies

None.

Testing

Build combined documentation for a Swift package where at least one of the targets has more than once source dependency. For example;

Modify IntegrationTests/Tests/Fixtures/TargetsWithDependencies to depend on the local version of the plugin:

- if FileManager.default.fileExists(atPath: "../swift-docc-plugin") {
      package.dependencies += [
-         .package(path: "../swift-docc-plugin"),
+         .package(path: "../../../.."),
      ]
- }

Then, run swift package generate-documentation --enable-experimental-combined-documentation --verbose and inspect the build log.

The docc convert call for the "Outer" target (which builds last because it depends on the other targets) should have two different --dependency flags passed to it;

  • The absolute path to .build/plugins/Swift-DocC/outputs/intermediates/InnerFirst.doccarchive
  • The absolute path to .build/plugins/Swift-DocC/outputs/intermediates/InnerSecond.doccarchive

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • [ ] Updated documentation if necessary Not applicable

d-ronnqvist and others added 9 commits September 6, 2024 12:09
This means that flag/option specific API can leverage types instead of including "flag" or "option" in the API's name.
This also means that a named option requires a value to create an argument.

Co-authored-by: Sofía Rodríguez <sofia_rodriguez@apple.com>
Also, define `--dependency` as an array-of-values option.

Co-authored-by: Sofía Rodríguez <sofia_rodriguez@apple.com>
@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist
Copy link
Contributor Author

Because we don't have a Swift 5.7 CI yet, I manually tested this with the swift:5.7-focal Docker image:

Swift version 5.7.3 (swift-5.7.3-RELEASE)
Target: aarch64-unknown-linux-gnu

Comment on lines 41 to 43
///
/// - Parameter names: The names of a command line option.
/// - Returns: The extracted values for this command line option, in the order that they appear in the arguments list.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment to match function signature:

/// Extracts the values for the command line argument.
///
/// Upon return, the arguments list no longer contains any elements that match any spelling of this command line option or its values.
///
/// - Parameter option: The command line option.
/// - Returns: The extracted values for this command line argument, in the order that they appear in the arguments list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 703f680

d-ronnqvist and others added 2 commits September 10, 2024 13:23
Co-authored-by: Sofía Rodríguez <sofia_rodriguez@apple.com>
@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist
Copy link
Contributor Author

Thanks for suggesting all those corrections and improvements to the documentation. I applied them in 703f680 together with a few more along the same lines.

@d-ronnqvist d-ronnqvist merged commit 85e4bb4 into swiftlang:main Sep 10, 2024
2 checks passed
@d-ronnqvist d-ronnqvist deleted the multiple-target-dependencies branch September 10, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants