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
[SR-15407] DocC (wrongly) renders actors as classes #212
Comments
It looks like the Swift compiler is treating actors as classes in symbol graph file generation. This is the data I'm seeing for an actor I defined: {
"kind": {
"identifier": "swift.class",
"displayName": "Class"
},
"identifier": {
"precise": "s:12Test5HelloC",
"interfaceLanguage": "swift"
},
"pathComponents": […],
"names": {…},
"declarationFragments": [
{
"kind": "keyword",
"spelling": "actor"
},
{…},
{…}
],
"accessLevel": "public",
"availability": […],
"location": {…}
}, |
Yeah, that's correct – they are `ClassDecl` but you need to check the keyword it is declared with and treat it separately as an actor if it was declared as actor. A distributed actor will also have a |
If it helps, this is how we detect them in SwiftSyntax, if you want to do this on the consuming end of symbols you'd do the same here I suppose: extension ClassDeclSyntax {
var isActor: Bool {
classOrActorKeyword.text == "actor"
}
var isDistributedActor: Bool {
guard isActor else {
return false
}
guard let mods = self.modifiers else {
return false
}
for mod in mods where mod.name.text == "distributed" {
return true
}
return false
}
} If you want to do it in the compiler, then the Decls have accurate |
It looks like there are two parts to this issue:
The first is relatively easy; the second requires some greater design effort in Swift-DocC to allow symbol graphs to customize the automatic topic organization behavior. I would suggest proposing that on the forums and splitting it into its own issue. For the first, the change needs to happen in the compiler, in |
+1 just ran into this myself and found it pretty confusing |
+1 UPD: +1 also for distributed actors |
Attachment: Download
Environment
Nightly `main` toolchain from October 27th
Additional Detail from JIRA
md5: 314cf0c884190d9ab14edc3fb2ab9753
Issue Description:
Summary:
Actors are listed as classes under the Classes: section. This is very confusing, they should be listed as their own category as they are stand alone nominal types.
Steps To Reproduce:
public actor NEIN {
}Results:
Actor shows up under classes as
class NEIN
which is misleading.Expected:
Should get their own section.
Extra:
And distributed actors should get their own section as well, perhaps under actors?
The text was updated successfully, but these errors were encountered: