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

Add symbolGraphMinimumAccessLevel option support #82

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Kyle-Ye
Copy link

@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
Author

Kyle-Ye commented Jun 2, 2024

@swift-ci please test

@heckj
Copy link

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
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
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
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.

@@ -0,0 +1,46 @@
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2022 Apple Inc. and the Swift project authors
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This is a new file

Suggested change
// Copyright (c) 2022 Apple Inc. and the Swift project authors
// Copyright (c) 2024 Apple Inc. and the Swift project authors

Copy link
Author

Choose a reason for hiding this comment

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

Nice catch.


/// 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
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.

@rauhul
Copy link

rauhul commented Jul 1, 2024

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

@Kyle-Ye
Copy link
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

rauhul commented Aug 9, 2024

Can we rebase and merge this?

@Kyle-Ye
Copy link
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
Author

Kyle-Ye commented Aug 11, 2024

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants