Skip to content

Add symbolGraphMinimumAccessLevel option support #82

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 3 commits into from
Aug 12, 2024

Conversation

Kyle-Ye
Copy link
Contributor

@Kyle-Ye Kyle-Ye commented Jun 2, 2024

Bug/issue #, if applicable:

Close #11

Summary

Add symbolGraphMinimumAccessLevel option support.

The current behavior for it is for library target we assume it to be public and for executable target we assume it to be internal implemented in defaultSymbolGraphOptions.

I propose to add symbol-graph-minimum-access-level option in command line so that we can opt-out the default internal behavior for executable target.

The usage is we want to documentation the executable target via docc bundle but we do not want to expose the internal symbol graph into the documentation.

See apple/swift-mmio#104 (comment)

Dependencies

None

Testing

See ArgumentsSymbolGraphMinimumAccessLevelTests.swift

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

Other Link

@Kyle-Ye Kyle-Ye force-pushed the feature/kyle/access_level branch from 1c49dd8 to a32a9d8 Compare June 2, 2024 08:33
@Kyle-Ye Kyle-Ye changed the title Add experimental-symbol-graph-minimum-access-level support Add symbolGraphMinimumAccessLevel option support Jun 2, 2024
@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Jun 2, 2024

@swift-ci please test

@heckj
Copy link
Member

heckj commented Jun 2, 2024

As the individual who opened #11, I'm hugely in favor of this. I don't know what the intended pattern is in calling a command line option "experimental", but since this has a stable part of the API of DocC for some time, and is actively used and adjusted with "OTHER DOCC FLAGS" in a number of places, I'd very much prefer to drop the "experimental" from the CLI option.

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Jun 2, 2024

I don't know what the intended pattern is in calling a command line option "experimental"

Oh, I think we'll eventually not need experimental too. It's the suggestion I got from @ethan-kusters on swift-docc Slack channel.

Reply from Slack channel:
There's not - but #11 is tracking the issue. A PR would be great! Maybe we should start with an --experimental prefixed flag? Ideally I think we'd have configuration in the Package.swift itself.

@sofiaromorales sofiaromorales self-requested a review June 3, 2024 10:47
@sofiaromorales
Copy link
Contributor

Thanks for opening this PR @Kyle-Ye! I'll be reviewing this in the upcoming days :)


extension Arguments {
/// The symbol graph minimum access level, if any, described by this set of command-line arguments.
public var symbolGraphMinimumAccessLevel: String? {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense for this property to return SymbolGraphOptions.AccessLevel? instead? That way the two call sites wouldn't need to use .flatMap { .init(rawValue: $0) }

Copy link
Contributor Author

@Kyle-Ye Kyle-Ye Jun 18, 2024

Choose a reason for hiding this comment

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

I'd like to. But SymbolGraphOptions.AccessLevel is defined in a module we can't access here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Should we move this into SharedPackagePluginExtensions then so that it can access the necessary types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. This is an alignment with Arguments+outputPath.swift.
  2. If we move this into SharedPackagePluginExtensions , we could not access CommandLineOption anymore unless we move CommandLineOption too or remove CommandLineOption.symbolGraphMinimumAccessLevel dependency.
  3. But in general, I agree your idea here.


/// Specifies the symbol graph minimum access level.
static let symbolGraphMinimumAccessLevel = CommandLineOption(
defaultName: "--experimental-symbol-graph-minimum-access-level"
Copy link
Contributor

Choose a reason for hiding this comment

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

One comment and a question:

  • I don't think this needs to say "experimental".
  • Should we also define this in a PluginFlag so that it is listed in the swift package generate-documentation --help output as a "plugin option"?

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 don't think this needs to say "experimental".

+1 for this.

A PR would be great! Maybe we should start with an --experimental prefixed flag?

What do you think about it? cc @ethan-kusters

Should we also define this in a PluginFlag so that it is listed in the swift package generate-documentation --help output as a "plugin option"?

I will give some check on this part.

Copy link
Contributor Author

@Kyle-Ye Kyle-Ye Aug 12, 2024

Choose a reason for hiding this comment

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

I don't think this needs to say "experimental".

Fixed.

Should we also define this in a PluginFlag so that it is listed in the swift package generate-documentation --help output as a "plugin option"?

I remember I tried it at the first time. But I forgot what is stopping me to use it.

@rauhul
Copy link
Member

rauhul commented Jul 1, 2024

Any updates on this? I'd love to adopt it in swift-mmio

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Jul 2, 2024

Any updates on this? I'd love to adopt it in swift-mmio

I'll take some time later this week to resolve the feedback I receive from the reviewers.

@d-ronnqvist
Copy link
Contributor

Any updates on this? I'd love to adopt it in swift-mmio

I'll take some time later this week to resolve the feedback I receive from the reviewers.

There isn't any blocking feedback. I'd be happy to merge this as is and look at surfacing the new flag in the help text in a later PR.

Copy link
Contributor

@d-ronnqvist d-ronnqvist left a comment

Choose a reason for hiding this comment

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

LGTM

@rauhul
Copy link
Member

rauhul commented Aug 9, 2024

Can we rebase and merge this?

@Kyle-Ye Kyle-Ye force-pushed the feature/kyle/access_level branch from a32a9d8 to 87e893c Compare August 11, 2024 17:22
@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Aug 11, 2024

There isn't any blocking feedback. I'd be happy to merge this as is and look at surfacing the new flag in the help text in a later PR.

Not have time to address all the PR comments. Maybe we can address them later since they are implementation details and there are downstream usage waiting this PR.

Can we rebase and merge this?

Done. I'd like to request @d-ronnqvist for a final approval since I removed experimental prefix.

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Aug 11, 2024

@swift-ci please test

@Kyle-Ye Kyle-Ye requested a review from d-ronnqvist August 11, 2024 17:25
@d-ronnqvist
Copy link
Contributor

I'll take a look later today

@Kyle-Ye Kyle-Ye force-pushed the feature/kyle/access_level branch from 87e893c to 22c8086 Compare August 12, 2024 07:56
@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Aug 12, 2024

@swift-ci please test

Copy link
Contributor

@d-ronnqvist d-ronnqvist left a comment

Choose a reason for hiding this comment

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

LGTM

@Kyle-Ye Kyle-Ye merged commit d80a059 into swiftlang:main Aug 12, 2024
2 checks passed
@Kyle-Ye Kyle-Ye deleted the feature/kyle/access_level branch August 12, 2024 13:15
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.

[SR-15765] CLI option for choosing level of access to expose when assembling documentation for internal consumption
5 participants