Skip to content

swift-api-extract to generate JSON API information #35690

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

Conversation

cachemeifyoucan
Copy link
Contributor

Add a new swift-frontend driver option that extract APIs in the swift
module and print in JSON format. This is to allow tooling to understand
and process swift APIs without the need to be a swift compiler or
understand swift module/AST.

Create a swift driver option that based on TBDGen but provide more information about swift APIs in both swift/objc/etc. in JSON format. The output can be easily consumed by other tools and scripts to reason about APIs in the swift module.

rdar://69600000

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci Please smoke test

@cachemeifyoucan
Copy link
Contributor Author

ping

Copy link
Contributor

@cyndyishida cyndyishida left a comment

Choose a reason for hiding this comment

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

LGTM,
I know theres some functionality/API's being used that already exist in tapi, do you see in the future us refactoring this out once tapi is fully merged into llvm?
Regardless of the case, I'm wondering if theres value in documenting what details aren't currently applicable in a swift context, e.g. Project level APIAccess.

Copy link
Contributor

@ributzka ributzka left a comment

Choose a reason for hiding this comment

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

LGTM

@cachemeifyoucan
Copy link
Contributor Author

Rebase the change and run tests.

@nkcsgexi @DougGregor is this good enough to merge?

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

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

LGTM!

Add a new swift-frontend driver option that extract APIs in the swift
module and print in JSON format. This is to allow tooling to understand
and process swift APIs without the need to be a swift compiler or
understand swift module/AST.
@cachemeifyoucan
Copy link
Contributor Author

@swift-ci Please smoke test

@cachemeifyoucan cachemeifyoucan merged commit 726a8d5 into swiftlang:main Feb 16, 2021
@akyrtzi
Copy link
Contributor

akyrtzi commented Feb 16, 2021

Hi, sorry for the late question but have you considered using the JSON output of swift-symbolgraph-extract?

I'd like to see if it's possible to converge on a single tool for producing JSON output of Swift module APIs, instead of maintaining multiple incompatible tools.

@cachemeifyoucan
Copy link
Contributor Author

Hi, sorry for the late question but have you considered using the JSON output of swift-symbolgraph-extract?

I'd like to see if it's possible to converge on a single tool for producing JSON output of Swift module APIs, instead of maintaining multiple incompatible tools.

Yes, we have considered that. Our original methods includes writing a tool that converts symbolgraph JSON to API JSON and we eventually decide to do it this way. Symbolgraph does missing some information to compute all the information we need but we also want to push a bit further with api-extract tool to detach that from swift AST so it can be language agnostics to add stuffs that is more than swift. In the future, we might converge those two because we are going to add more fields to API JSON to include all the information needed by documentation from symbolgraph.

@migueldeicaza
Copy link

I found a crash when using the tool, filed it here:

https://bugs.swift.org/browse/SR-14311?jql=text%20~%20%22swift-api-extract%22

@cachemeifyoucan
Copy link
Contributor Author

I found a crash when using the tool, filed it here:

https://bugs.swift.org/browse/SR-14311?jql=text%20~%20%22swift-api-extract%22

Thanks for the report. I comment on the issue.

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.

6 participants