Skip to content

Commit 94ff157

Browse files
authored
Merge pull request swiftlang#32070 from xymus/spi-swiftdoc
[Serialization] Skip SPI documentation in swiftdoc files
2 parents 9bde41a + 56c77df commit 94ff157

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

lib/Serialization/SerializeDoc.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ static bool shouldIncludeDecl(Decl *D, bool ExcludeDoubleUnderscore) {
344344
if (VD->getEffectiveAccess() < swift::AccessLevel::Public)
345345
return false;
346346
}
347+
348+
// Skip SPI decls.
349+
if (D->isSPI())
350+
return false;
351+
347352
if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
348353
return shouldIncludeDecl(ED->getExtendedNominal(), ExcludeDoubleUnderscore);
349354
}
@@ -745,7 +750,7 @@ Result.X.Column = Locs->X.Column;
745750
};
746751
// .swiftdoc doesn't include comments for double underscored symbols, but
747752
// for .swiftsourceinfo, having the source location for these symbols isn't
748-
// a concern becuase these symbols are in .swiftinterface anyway.
753+
// a concern because these symbols are in .swiftinterface anyway.
749754
if (!shouldIncludeDecl(D, /*ExcludeDoubleUnderscore*/false))
750755
return false;
751756
if (!shouldSerializeSourceLoc(D))

test/Serialization/comments-hidden.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public class PublicClass {
4343
public init(label __name: String) {}
4444
/// Public Filter Subscript Documentation NotForNormal NotForTesting
4545
public subscript(label __name: String) -> Int { return 0 }
46+
/// SPI Function Documentation NotForNormal NotForTesting
47+
@_spi(SPI) public func f_spi() { }
4648
}
4749

4850
public extension PublicClass {
@@ -64,6 +66,16 @@ private class PrivateClass {
6466
private func f_private() { }
6567
}
6668

69+
/// SPI Documentation NotForNormal NotForTesting
70+
@_spi(SPI) public class SPIClass {
71+
/// SPI Function Documentation NotForNormal NotForTesting
72+
public func f_spi() { }
73+
}
74+
75+
/// SPI Extension Documentation NotForNormal NotForTesting
76+
@_spi(SPI) public extension PublicClass {
77+
}
78+
6779
// NORMAL-NEGATIVE-NOT: NotForNormal
6880
// NORMAL-NEGATIVE-NOT: NotForTesting
6981
// NORMAL: PublicClass Documentation
@@ -74,7 +86,7 @@ private class PrivateClass {
7486
// TESTING-NEGATIVE-NOT: NotForTesting
7587
// TESTING: PublicClass Documentation
7688
// TESTING: Public Function Documentation
77-
// TESTINH: Public Init Documentation
89+
// TESTING: Public Init Documentation
7890
// TESTING: Public Subscript Documentation
7991
// TESTING: Internal Function Documentation
8092
// TESTING: InternalClass Documentation
@@ -85,4 +97,4 @@ private class PrivateClass {
8597
// SOURCE-LOC: comments-hidden.swift:41:10: Subscript/PublicClass.subscript RawComment=none BriefComment=none DocCommentAsXML=none
8698
// SOURCE-LOC: comments-hidden.swift:43:10: Constructor/PublicClass.init RawComment=none BriefComment=none DocCommentAsXML=none
8799
// SOURCE-LOC: comments-hidden.swift:45:10: Subscript/PublicClass.subscript RawComment=none BriefComment=none DocCommentAsXML=none
88-
// SOURCE-LOC: comments-hidden.swift:50:15: Func/-= RawComment=none BriefComment=none DocCommentAsXML=none
100+
// SOURCE-LOC: comments-hidden.swift:52:15: Func/-= RawComment=none BriefComment=none DocCommentAsXML=none

0 commit comments

Comments
 (0)