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

allow arbitrary platform strings in the @Available directive #463

Merged
merged 2 commits into from
Jan 26, 2023

Conversation

QuietMisdreavus
Copy link
Contributor

Bug/issue #, if applicable: rdar://104224866

Summary

In #440, the @Available directive was limited to four platforms: iOS, macOS, watchOS, tvOS. This PR opens up that directive to take arbitrary platform strings, which will be passed along to the rendered page.

Dependencies

None

Testing

Use the following metadata for testing:

@Metadata {
    @Available("Swift DocC", introduced: "1.0")
}

Steps:

  1. Add the above metadata to Sources/SwiftDocC/SwiftDocC.docc/SwiftDocC/Directives.md.
  2. bin/preview-docs
  3. Ensure that the "Directives" page is printed with an availability callout for "Swift DocC" (with the space - i'm specifically testing platforms with spaces here):

image

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

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

if platform.rawValue.lowercased() == rawValue.lowercased() {
self = platform
return
}
}
return nil
if rawValue == "*" {
Copy link
Contributor

@binamaniar binamaniar Jan 23, 2023

Choose a reason for hiding this comment

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

With this implementation as well, we can mimic Deprecated behavior. it would be so confusing to have @available() with Deprecated information passed to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean allowing @Available(isDeprecated: true) once that is implemented? That will need to be handled as part of that implementation.

If you mean allowing @Available(MyPackage, isDeprecated, true), that should come for free without any extra work. I could add a test for that if you would like.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant the first part, i.e @available(isDeprecated: true). sorry my response was never posted due to my internet connectivity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, deprecation status isn't available yet; see #441 for information.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@QuietMisdreavus QuietMisdreavus merged commit 2503c0d into swiftlang:main Jan 26, 2023
@QuietMisdreavus QuietMisdreavus deleted the arbitrary-avail branch January 26, 2023 23:35
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.

3 participants