Skip to content
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

Feat: New plugin flag for skipping synthesized symbols #28

Conversation

sofiaromorales
Copy link
Contributor

Bug/issue #, if applicable: #27

Summary

This pull request aims to support the generation of archives without synthesized symbols by passing a new plugin flag --skip-synthesized-symbols. This would reduce the size of the generated doccarchive.

The plugin flag --skip-synthesized-symbols has been added to achieve this. It doesn't transform any of the passed arguments but overrides the default value of symbolGraphOptions.includeSynthesized to false. Also, with the proposed implementation, more flags could be added to override other settings of the symbol graph options.

Dependencies

N/A

Testing

For automated testing run the integration tests suite.

For manual testing:

  1. Download the attached package
  2. In Package.swift set the right path for swift-docc-plugin dependency
  3. Run swift package generate-documentation, and swift package generate-documentation --skip-synthesized-symbols, for both compare the files generated at PackageWithConformanceSymbols.doccarchive/data/documentation/packagewithconformancesymbols/bar

PackageWithConformanceSymbols.zip

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

    * Added `--skip-synthesized-symbols` flag as plugin flag to override the symbol graph option `includeSynthesized` and set it to false
    * Array of plugin flags that overrides the defaults of the symbol graph generation
    * Conformance of `PluginFlag` to `Equatable` protocol
    * Unit tests for `--skip-synthesized-symbols`
    * Integration test to make sure that synthesized symbols are excluded from the .doccarchive when `--skip-synthesized-symbols` is passed
Copy link
Contributor

@ethan-kusters ethan-kusters left a comment

Choose a reason for hiding this comment

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

Looks good - thank you! I left some initial feedback and I'll want to do some more testing as well before we land this.

* Renamed flag to `--experimental-skip-synthesized-symbols`
* Changed flag description
* Integration test now conforms to `Hashable` protocol instead of `SwiftUI`
Conflicts:
	Plugins/SharedPackagePluginExtensions/PackageManager+getSymbolGraphsForDocC.swift
	Plugins/Swift-DocC Convert/SwiftDocCConvert.swift
	Plugins/Swift-DocC Preview/SwiftDocCPreview.swift
theMomax added a commit to theMomax/swift-docc-plugin that referenced this pull request Jan 12, 2023
theMomax added a commit to theMomax/swift-docc-plugin that referenced this pull request Jan 17, 2023
@ethan-kusters
Copy link
Contributor

Hi @sofiaromorales would you mind taking a look at the merge conflicts here when you have a chance? I believe #34 introduced a few since it also touches some of this same code.

It would be great to land this in the next release alongside extension support if we can.

Conflicts:
	IntegrationTests/Package.swift
	Plugins/SharedPackagePluginExtensions/PackageManager+getSymbolGraphsForDocC.swift
	Sources/SwiftDocCPluginUtilities/ParsedArguments.swift
	Tests/SwiftDocCPluginUtilitiesTests/HelpInformationTests.swift
	Tests/SwiftDocCPluginUtilitiesTests/ParsedArgumentsTests.swift
@@ -201,7 +201,8 @@ private extension ParsedArguments {
switch self {
case .dumpSymbolGraph:
return [
PluginFlag.extendedTypes
PluginFlag.extendedTypes,
PluginFlag.skipSynthesizedSymbols
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed along the same strategy as in #34 since--experimental-skip-synthesized-symbol is transformed to -skip-synthesized-members flag of the swift package dump-symbol-graph command

@ethan-kusters
Copy link
Contributor

@swift-ci please test

@ethan-kusters
Copy link
Contributor

CC: @theMomax I'm having trouble adding you as reviewer for some reason – but would appreciate your review on this as well.

@theMomax
Copy link
Contributor

@ethan-kusters that's probably because I don't have commit access to Swift repositories and thus cannot formally approve a PR.

As for the review, I think it looks good! One thing I didn't check, though, is whether the symbolGraphOptions.includeSynthesized property has existed since 5.6. I do think so, but otherwise we'd need some special handling for backwards compatibility as I added it in #34.

@ethan-kusters
Copy link
Contributor

@swift-ci please test

Copy link
Contributor

@ethan-kusters ethan-kusters left a 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 @sofiaromorales!

@ethan-kusters ethan-kusters merged commit 9b12589 into swiftlang:main Mar 13, 2023
@Kyle-Ye Kyle-Ye linked an issue Aug 13, 2024 that may be closed by this pull request
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.

Support for skipping synthesized symbols
3 participants