-
Notifications
You must be signed in to change notification settings - Fork 158
Support more @DirectiveArgumentWrapped
configurations
#459
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
d-ronnqvist
merged 16 commits into
swiftlang:main
from
d-ronnqvist:test-directive-argument-wrapper
Feb 1, 2024
Merged
Support more @DirectiveArgumentWrapped
configurations
#459
d-ronnqvist
merged 16 commits into
swiftlang:main
from
d-ronnqvist:test-directive-argument-wrapper
Feb 1, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Also, generate more consistent `typeDisplayName` values
7f13c4e
to
c0d2e25
Compare
# Conflicts: # Sources/SwiftDocC/Semantics/DirectiveInfrastructure/DirectiveArgumentWrapper.swift
d-ronnqvist
commented
Aug 8, 2023
}, | ||
{ | ||
"text" : "or the card image used to represent this page when using the ``Links`` directive and the ``Links\/detailedGrid``" | ||
"text" : "or the card image used to represent this page when using the ``Links`` directive and the ``Links\/VisualStyle\/detailedGrid``" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These documentation changes was done before this PR but we hadn't updated the DocC SGF to reflect the latest documentation changes.
daniel-grumberg
approved these changes
Feb 1, 2024
@swift-ci please test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug/issue #, if applicable:
Summary
This PR updates the
@DirectiveArgumentWrapped
property wrapper with more initializer to support more combinations of arguments. It also marks some initializers as explicitly unavailable so that DocC developers gets specific error messages if they create an unsupported configurations.This PR also extracts the code that creates the "type display name" for directive arguments so that the same naming code applies to basic arguments, optional arguments, and completely custom arguments. This is accompanied by a handful of tests.
These changes are easies to talk about using the added tests as examples.
Support for optional values without an explicit
nil
default value.Without these changes, directives with an optional value can't omit
= nil
, regardless if they're a built in type or a custom type. In other words, these 3 properties fail to compile without these changesDisplay of default values for optional types
Without these changes, directives with default values displayed differently depending on if the type was an optional or not. For example, these two directive arguments
would display
Bool = false
as the type information forbooleanWithDefault
butBool?
as the type information foroptionalBooleanWithDefault
.With these changes both those directives display their type information as
Bool = false
.From the author facing perspective, the directive syntax doesn't have a syntax to explicitly spell out
nil
so an optional value with a non-optional default is effectively a non-optional value (either the author specifies an explicit non-nil value or the the argument uses the default non-nil value).Requiredness of optional value with allowed values
Without these changes, an optional value with an explicit collection of "allowed values" was incorrectly marked as "required". For example
With these changes the implicit
nil
value is taken into consideration, meaning that the directive argument is marked a not required.Dependencies
n/a
Testing
Manual tests can look at the added unit tests for inspiration of some directive arguments configurations to try specifying.
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded