Skip to content

Commit 31456c4

Browse files
authored
Use a more detailed page type for C++ namespaces in navigator index (#817)
* Add `namespace` case for `NavigatorIndex.PageType`. * Add `RenderIndex` test with namespace node. * Test `PageType.init(symbolKind:)` with namespace. * Move case location. rdar://122340677
1 parent e353808 commit 31456c4

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ public class NavigatorIndex {
304304

305305
// A property list key.
306306
case propertyListKeyReference = 47
307+
308+
// C++ symbols
309+
case namespace = 48
307310

308311
// Special items
309312
case languageGroup = 127
@@ -336,6 +339,7 @@ public class NavigatorIndex {
336339
case "enumcm", "structcm", "clm", "intfcm", "type.method": self = .typeMethod
337340
case "httpget", "httpput", "httppost", "httppatch", "httpdelete": self = .httpRequest
338341
case "dict": self = .dictionarySymbol
342+
case "namespace": self = .namespace
339343
default: self = .symbol
340344
}
341345
}

Sources/SwiftDocC/Indexing/RenderIndexJSON/RenderIndex.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ extension NavigatorIndex.PageType {
364364
return "httpRequest"
365365
case .dictionarySymbol:
366366
return "dictionarySymbol"
367+
case .namespace:
368+
return SymbolGraph.Symbol.KindIdentifier.namespace.renderingIdentifier
367369
case .propertyListKeyReference:
368370
return "propertyListKeyReference"
369371
case .languageGroup:

Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,7 @@ Root
12501250
XCTAssertEqual(PageType(symbolKind: "union"), .union)
12511251
XCTAssertEqual(PageType(symbolKind: "property"), .instanceProperty)
12521252
XCTAssertEqual(PageType(symbolKind: "dict"), .dictionarySymbol)
1253+
XCTAssertEqual(PageType(symbolKind: "namespace"), .namespace)
12531254

12541255
func verifySymbolKind(_ inputs: [String], _ result: PageType) {
12551256
for input in inputs {

Tests/SwiftDocCTests/Indexing/RenderIndexTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,29 @@ final class RenderIndexTests: XCTestCase {
561561
XCTAssertTrue(try XCTUnwrap(renderIndex.interfaceLanguages["swift"])[0].isBeta)
562562
}
563563
}
564+
565+
func testRenderIndexGenerationWithNamespaceNode() throws {
566+
try testRenderIndexGenerationFromJSON("""
567+
{
568+
"interfaceLanguages": {
569+
"occ": [
570+
{
571+
"path": "/documentation/framework/foo",
572+
"title": "Foo",
573+
"type": "namespace"
574+
}
575+
]
576+
},
577+
"schemaVersion": {
578+
"major": 0,
579+
"minor": 1,
580+
"patch": 0
581+
}
582+
}
583+
""") { renderIndex in
584+
XCTAssertTrue(try XCTUnwrap(renderIndex.interfaceLanguages["occ"])[0].type == "namespace")
585+
}
586+
}
564587

565588
func makeRenderIndexJSONSingleNode(withOptionalProperty property: String) -> String {
566589
return """

0 commit comments

Comments
 (0)