-
Notifications
You must be signed in to change notification settings - Fork 10.5k
introduce a @_documentation(...)
attribute to influence SymbolGraphGen
#60242
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
Conversation
@swift-ci Please test |
@_nodoc
attribute to hide symbols from the symbol graph@_documentation(...)
attribute to add "documentation categories"
Based on discussion in this Swift Forums thread, i've pushed up a couple commits that change how the attribute works. Instead of a single |
@swift-ci Please test |
569bd2f
to
7d9551c
Compare
Based on further discussion on the forums, the
|
@swift-ci Please test |
@_documentation(...)
attribute to add "documentation categories"@_documentation(...)
attribute to influence SymbolGraphGen
@@ -117,6 +117,27 @@ extension Text { | |||
} | |||
``` | |||
|
|||
## `@_documentation(metadata: ...)` |
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.
I assume the value of the metadata
parameter is just a string that be specified with or without quotes?
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.
Right now it can only be an identifier, but i could see about making it a quoted string as well.
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.
If it's a string in quotes, developers could stick in useful metadata like JSON, CSV, or hex encoded images which would be fun 👌🏼
include/swift/AST/Attr.h
Outdated
@@ -2226,6 +2226,28 @@ class BackDeployAttr: public DeclAttribute { | |||
} | |||
}; | |||
|
|||
/// The `@_documentation(...)` attribute, used to note a "category" for a |
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.
Is the term "category" still correct given the latest changes?
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.
It's not, good catch 😅
Adds "documentation metadata" to the symbol. The identifier in the attribute is | ||
added to the symbol graph in the `"metadata"` field of the symbol. This can be | ||
used to add an arbitrary grouping or other indicator to symbols for use in | ||
documentation. |
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.
Are you able to specify multiple @_documentation(metadata: …)
attributes for the same declaration?
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.
I'm not sure; i'll have to check. Offhand, i think the answer is "no" because of checks for duplicate attributes, but i'm not confident about it.
1461391
to
be76de2
Compare
I've rebased onto the latest @swift-ci Please test |
@swift-ci Please test |
be76de2
to
955beff
Compare
Rebased to resolve merge conflicts. @swift-ci Please test |
955beff
to
cc55f0e
Compare
@swift-ci Please test |
Resolves rdar://79049241
This PR introduces a new attribute,
@_documentation(...)
, that influences how SymbolGraphGen handles the symbol it's attached to. There are two forms of this attribute:@_documentation(visibility: ...)
treats the symbol as the given access level in the symbol graph, allowing you to hide a technically-public
implementation detail from public documentation, or reveal a symbol with an underscored name that would otherwise be hidden.@_documentation(metadata: ...)
adds an arbitrary identifier to the symbol's"metadata"
field, which can then be handled by other tooling.This PR also fixes a pre-existing issue where symbols that were declared
internal
in a re-exported module would be included in the symbol graph if it was being requested with aninternal
access level, and similarly for anything belowpublic
.