Skip to content

Pass dump-symbol-graph flags to symbolgraph-extract #3682

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 1 commit into from
Aug 26, 2021

Conversation

Dev1an
Copy link
Contributor

@Dev1an Dev1an commented Aug 20, 2021

Passes flags from swift package dump-symbol-graph to swift-symbolgraph-extract

Motivation:

The package manager allows us to extract a symbol graph from a Swift Package without the need to manually specify the module-name, target, sdk and other compiler flags. But it is limited to extract public symbols only, because it takes away the ability to specify any of the swift-symbolgraph-extract configuration options (like access control etc.).
This pull request adds some of the most useful configuration options of swift-symbolgraph-extract to the SPM tool and passes them through.

Modifications:

The following flags are added to the DumpSymbolGraph: SwiftCommand:

  • prettyPrint: Bool
  • skipSynthesisedMembers: Bool
  • minimumAccessLevel: AccessLevel
  • skipInheritedDocs: Bool
  • includeSpiSymbols: Bool

AccessLevel is a new struct that I declared in the SymbolGraphExtract.swift file.

Result:

You can now dump symbol graphs with SPM

  • using pretty-printed formatting
  • skipping synthesised members
  • using user-defined minimum access levels: private, fileprivate, internal, open
  • skipping inherited docs
  • including SPI symbols

Usage instructions can be shown by executing swift package dump-symbol-graph --help

OVERVIEW: Dump Symbol Graph

USAGE: swift package dump-symbol-graph <options>

OPTIONS:
  --pretty-print          Pretty-print the output JSON. 
  --skip-synthesized-members
                          Skip members inherited through classes or default implementations. 
  --minimum-access-level <minimum-access-level>
                          Include symbols with this access level or more. Possible values: private | fileprivate | internal | public | open (default:
                          public)
  --skip-inherited-docs   Skip emitting doc comments for members inherited through classes or default implementations. 
  --include-spi-symbols   Add symbols with SPI information to the symbol graph. 
  --version               Show the version.
  -help, -h, --help       Show help information.

@Dev1an Dev1an changed the title Pass symbolgraph flags to symbolgraph-extract Pass dump-symbol-graph flags to symbolgraph-extract Aug 20, 2021
@tomerd
Copy link
Contributor

tomerd commented Aug 23, 2021

@abertelrud this is something that we should refactor out to a plugin when the underlying framework is in place. could you please review in that light.

@tomerd
Copy link
Contributor

tomerd commented Aug 23, 2021

@swift-ci please smoke test

@abertelrud
Copy link
Contributor

I believe that the unit test failure is unrelated. I think I saw a different PR that resolves it, so probably just running the tests again after your amended fix will result in green builds.

Passes flags from `swift package dump-symbol-graph` to `swift-symbolgraph-extract`
The following flags are added: prettyPrint, skipSynthesisedMembers, minimumAccessLevel, skipInheritedDocs and skipInheritedDocs
@Dev1an Dev1an force-pushed the feature/pass-symbolgraph-flags branch from d5f1ea2 to 58baf11 Compare August 25, 2021 17:12
@Dev1an
Copy link
Contributor Author

Dev1an commented Aug 25, 2021

OK I amended a formatting change. I now

  • used SPI instead of Spi
  • switched my indentation style from tabs to spaces to match the rest of the code.

Can someone retrigger the smoke test @tomerd @abertelrud?

@neonichu
Copy link
Contributor

@swift-ci please smoke test

Copy link
Contributor

@abertelrud abertelrud 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 to me. Thanks!

@abertelrud
Copy link
Contributor

@neonichu @tomerd Ok to merge?

@abertelrud abertelrud merged commit 301c3fb into swiftlang:main Aug 26, 2021
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.

4 participants