Skip to content

Commit 113ffa3

Browse files
don't generate pages for snippet/snippetGroup symbols
1 parent a6c744f commit 113ffa3

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

Sources/SwiftDocC/Infrastructure/DocumentationContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
13841384
}
13851385
}
13861386
for (usr, node) in symbolIndex {
1387-
guard let kind = node.symbol?.kind.identifier, kind != .module,
1387+
guard let kind = node.symbol?.kind.identifier, kind.symbolGeneratesPage(),
13881388
!hierarchyBasedReferences.keys.contains(where: { $0.precise == usr })
13891389
else { continue }
13901390
linkResolutionMismatches.missingPathsInHierarchyBasedLinkResolver.append(node.reference.path)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2022 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
import SymbolKit
12+
13+
extension SymbolGraph.Symbol.KindIdentifier {
14+
/// The kinds of symbols that should not generate pages in the documentation hierarchy.
15+
static let noPageKinds: [SymbolGraph.Symbol.KindIdentifier] = [
16+
.module,
17+
.snippet,
18+
.snippetGroup
19+
]
20+
21+
/// Indicates whether this kind of symbol should generate a page.
22+
func symbolGeneratesPage() -> Bool {
23+
!Self.noPageKinds.contains(self)
24+
}
25+
}

Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ extension AutomaticCuration {
204204
case .`method`: return "Instance Methods"
205205
case .`property`: return "Instance Properties"
206206
case .`protocol`: return "Protocols"
207-
case .snippet: return "Snippets"
208-
case .snippetGroup: return "Snippets"
209207
case .`struct`: return "Structures"
210208
case .`subscript`: return "Subscripts"
211209
case .`typeMethod`: return "Type Methods"
@@ -225,9 +223,10 @@ extension AutomaticCuration {
225223
}
226224

227225
/// The order of symbol kinds when grouped automatically.
226+
///
227+
/// Add a symbol kind to `KindIdentifier.noPageKinds` if it should not generate a page in the
228+
/// documentation hierarchy.
228229
static let groupKindOrder: [SymbolGraph.Symbol.KindIdentifier] = [
229-
.module,
230-
231230
.`class`,
232231
.`protocol`,
233232
.`struct`,
@@ -259,8 +258,5 @@ extension AutomaticCuration {
259258
.unknownExtendedType,
260259

261260
.extension,
262-
263-
.snippet,
264-
.snippetGroup
265261
]
266262
}

Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AutomaticCurationTests: XCTestCase {
2121
var availableSymbolKinds = Set(AutomaticCuration.groupKindOrder)
2222
availableSymbolKinds.formUnion(SymbolGraph.Symbol.KindIdentifier.allCases)
2323

24-
for kind in availableSymbolKinds where kind != .module {
24+
for kind in availableSymbolKinds where kind.symbolGeneratesPage() {
2525
// TODO: Synthesize appropriate `swift.extension` symbols that get transformed into
2626
// the respective internal symbol kinds as defined by `ExtendedTypeFormatTransformation`
2727
// and remove decoder injection logic from `DocumentationContext` and `SymbolGraphLoader`
@@ -43,7 +43,7 @@ class AutomaticCurationTests: XCTestCase {
4343

4444
XCTAssertNotNil(renderNode.topicSections.first(where: { group -> Bool in
4545
return group.title == AutomaticCuration.groupTitle(for: kind)
46-
}), "\(kind.identifier) was not automatically curated in a \(AutomaticCuration.groupTitle(for: kind).singleQuoted) topic group." )
46+
}), "\(kind.identifier) was not automatically curated in a \(AutomaticCuration.groupTitle(for: kind).singleQuoted) topic group. Please add it to either AutomaticCuration.groupKindOrder or KindIdentifier.noPageKinds." )
4747
}
4848
}
4949

0 commit comments

Comments
 (0)