File tree Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,8 @@ extension Text {
119
119
120
120
## ` @_documentation(...) `
121
121
122
- Adds a "documentation category" to the given symbol.
122
+ Adds a "documentation category" to the given symbol. The identifier in the
123
+ attribute is added to the symbol graph in the ` "category" ` field of the symbol.
123
124
124
125
There are two special-case categories: ` underscored ` will treat the given symbol
125
126
as having an underscored name regardless of its actual name, effectively marking
Original file line number Diff line number Diff line change 19
19
#include " swift/Basic/PrimitiveParsing.h"
20
20
#include " swift/Basic/SourceManager.h"
21
21
#include " swift/Basic/Unicode.h"
22
+ #include " swift/SymbolGraphGen/DocumentationCategory.h"
22
23
#include " clang/AST/ASTContext.h"
23
24
#include " clang/AST/Decl.h"
24
25
#include " clang/Basic/SourceManager.h"
@@ -452,6 +453,12 @@ void Symbol::serializeAccessLevelMixin(llvm::json::OStream &OS) const {
452
453
OS.attribute (" accessLevel" , getAccessLevelSpelling (VD->getFormalAccess ()));
453
454
}
454
455
456
+ void Symbol::serializeCategoryMixin (llvm::json::OStream &OS) const {
457
+ StringRef Category = documentationCategoryForDecl (VD);
458
+ if (!Category.empty ())
459
+ OS.attribute (" category" , Category);
460
+ }
461
+
455
462
void Symbol::serializeLocationMixin (llvm::json::OStream &OS) const {
456
463
if (ClangNode ClangN = VD->getClangNode ()) {
457
464
if (!Graph->Walker .Options .IncludeClangDocs )
@@ -592,6 +599,7 @@ void Symbol::serialize(llvm::json::OStream &OS) const {
592
599
serializeDeclarationFragmentMixin (OS);
593
600
serializeAccessLevelMixin (OS);
594
601
serializeAvailabilityMixin (OS);
602
+ serializeCategoryMixin (OS);
595
603
serializeLocationMixin (OS);
596
604
serializeSPIMixin (OS);
597
605
});
Original file line number Diff line number Diff line change @@ -72,6 +72,8 @@ class Symbol {
72
72
73
73
void serializeAccessLevelMixin (llvm::json::OStream &OS) const ;
74
74
75
+ void serializeCategoryMixin (llvm::json::OStream &OS) const ;
76
+
75
77
void serializeLocationMixin (llvm::json::OStream &OS) const ;
76
78
77
79
void serializeAvailabilityMixin (llvm::json::OStream &OS) const ;
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-build-swift %s -module-name DocumentationCategories -emit-module -emit-module-path %t/
3
+ // RUN: %target-swift-symbolgraph-extract -module-name DocumentationCategories -I %t -pretty-print -output-dir %t
4
+ // RUN: %FileCheck %s --input-file %t/DocumentationCategories.symbols.json
5
+
6
+ // CHECK: "category": "cool_stuff"
7
+ @_documentation ( cool_stuff) public class SomeClass { }
8
+
You can’t perform that action at this time.
0 commit comments