Skip to content

[Serialization] Skip SPI documentation in swiftdoc files #32070

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
merged 1 commit into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/Serialization/SerializeDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ static bool shouldIncludeDecl(Decl *D, bool ExcludeDoubleUnderscore) {
if (VD->getEffectiveAccess() < swift::AccessLevel::Public)
return false;
}

// Skip SPI decls.
if (D->isSPI())
return false;

if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
return shouldIncludeDecl(ED->getExtendedNominal(), ExcludeDoubleUnderscore);
}
Expand Down Expand Up @@ -745,7 +750,7 @@ Result.X.Column = Locs->X.Column;
};
// .swiftdoc doesn't include comments for double underscored symbols, but
// for .swiftsourceinfo, having the source location for these symbols isn't
// a concern becuase these symbols are in .swiftinterface anyway.
// a concern because these symbols are in .swiftinterface anyway.
if (!shouldIncludeDecl(D, /*ExcludeDoubleUnderscore*/false))
return false;
if (!shouldSerializeSourceLoc(D))
Expand Down
16 changes: 14 additions & 2 deletions test/Serialization/comments-hidden.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class PublicClass {
public init(label __name: String) {}
/// Public Filter Subscript Documentation NotForNormal NotForTesting
public subscript(label __name: String) -> Int { return 0 }
/// SPI Function Documentation NotForNormal NotForTesting
@_spi(SPI) public func f_spi() { }
}

public extension PublicClass {
Expand All @@ -64,6 +66,16 @@ private class PrivateClass {
private func f_private() { }
}

/// SPI Documentation NotForNormal NotForTesting
@_spi(SPI) public class SPIClass {
/// SPI Function Documentation NotForNormal NotForTesting
public func f_spi() { }
}

/// SPI Extension Documentation NotForNormal NotForTesting
@_spi(SPI) public extension PublicClass {
}

// NORMAL-NEGATIVE-NOT: NotForNormal
// NORMAL-NEGATIVE-NOT: NotForTesting
// NORMAL: PublicClass Documentation
Expand All @@ -74,7 +86,7 @@ private class PrivateClass {
// TESTING-NEGATIVE-NOT: NotForTesting
// TESTING: PublicClass Documentation
// TESTING: Public Function Documentation
// TESTINH: Public Init Documentation
// TESTING: Public Init Documentation
// TESTING: Public Subscript Documentation
// TESTING: Internal Function Documentation
// TESTING: InternalClass Documentation
Expand All @@ -85,4 +97,4 @@ private class PrivateClass {
// SOURCE-LOC: comments-hidden.swift:41:10: Subscript/PublicClass.subscript RawComment=none BriefComment=none DocCommentAsXML=none
// SOURCE-LOC: comments-hidden.swift:43:10: Constructor/PublicClass.init RawComment=none BriefComment=none DocCommentAsXML=none
// SOURCE-LOC: comments-hidden.swift:45:10: Subscript/PublicClass.subscript RawComment=none BriefComment=none DocCommentAsXML=none
// SOURCE-LOC: comments-hidden.swift:50:15: Func/-= RawComment=none BriefComment=none DocCommentAsXML=none
// SOURCE-LOC: comments-hidden.swift:52:15: Func/-= RawComment=none BriefComment=none DocCommentAsXML=none