Skip to content

Use a more detailed page type for C++ namespaces in navigator index #817

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
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
4 changes: 4 additions & 0 deletions Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ public class NavigatorIndex {

// A property list key.
case propertyListKeyReference = 47

// C++ symbols
case namespace = 48

// Special items
case languageGroup = 127
Expand Down Expand Up @@ -336,6 +339,7 @@ public class NavigatorIndex {
case "enumcm", "structcm", "clm", "intfcm", "type.method": self = .typeMethod
case "httpget", "httpput", "httppost", "httppatch", "httpdelete": self = .httpRequest
case "dict": self = .dictionarySymbol
case "namespace": self = .namespace
default: self = .symbol
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftDocC/Indexing/RenderIndexJSON/RenderIndex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ extension NavigatorIndex.PageType {
return "httpRequest"
case .dictionarySymbol:
return "dictionarySymbol"
case .namespace:
return SymbolGraph.Symbol.KindIdentifier.namespace.renderingIdentifier
case .propertyListKeyReference:
return "propertyListKeyReference"
case .languageGroup:
Expand Down
1 change: 1 addition & 0 deletions Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,7 @@ Root
XCTAssertEqual(PageType(symbolKind: "union"), .union)
XCTAssertEqual(PageType(symbolKind: "property"), .instanceProperty)
XCTAssertEqual(PageType(symbolKind: "dict"), .dictionarySymbol)
XCTAssertEqual(PageType(symbolKind: "namespace"), .namespace)

func verifySymbolKind(_ inputs: [String], _ result: PageType) {
for input in inputs {
Expand Down
23 changes: 23 additions & 0 deletions Tests/SwiftDocCTests/Indexing/RenderIndexTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,29 @@ final class RenderIndexTests: XCTestCase {
XCTAssertTrue(try XCTUnwrap(renderIndex.interfaceLanguages["swift"])[0].isBeta)
}
}

func testRenderIndexGenerationWithNamespaceNode() throws {
try testRenderIndexGenerationFromJSON("""
{
"interfaceLanguages": {
"occ": [
{
"path": "/documentation/framework/foo",
"title": "Foo",
"type": "namespace"
}
]
},
"schemaVersion": {
"major": 0,
"minor": 1,
"patch": 0
}
}
""") { renderIndex in
XCTAssertTrue(try XCTUnwrap(renderIndex.interfaceLanguages["occ"])[0].type == "namespace")
}
}

func makeRenderIndexJSONSingleNode(withOptionalProperty property: String) -> String {
return """
Expand Down