From da431291d26b81f8433c33a80e194372619b1dc1 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Tue, 15 Sep 2026 14:57:04 +0200 Subject: [PATCH] feat(renderer): Show symbol kind in text documentation --- Sources/CLI/renderer/TextTypeDocumentationRenderer.swift | 5 ++++- .../AppleDocsCommandIntegrationTests.swift | 2 +- .../renderer/DefaultTypeDocumentationRendererTests.swift | 2 ++ .../renderer/TextTypeDocumentationRendererContentTests.swift | 2 +- .../renderer/TextTypeDocumentationRendererTests.swift | 3 ++- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Sources/CLI/renderer/TextTypeDocumentationRenderer.swift b/Sources/CLI/renderer/TextTypeDocumentationRenderer.swift index 22ada15..3f827c3 100644 --- a/Sources/CLI/renderer/TextTypeDocumentationRenderer.swift +++ b/Sources/CLI/renderer/TextTypeDocumentationRenderer.swift @@ -5,7 +5,10 @@ struct TextTypeDocumentationRenderer: Sendable { let content = DocumentationContentRenderer(references: page.references) let metadata = ([page.metadata.roleHeading] + page.metadata.modules.map(\.name)) .filter { !$0.isEmpty }.joined(separator: " · ") - var sections = [layout.heading(page.metadata.title, prominent: true) + "\n" + metadata] + var sections = [ + layout.heading(page.metadata.title, prominent: true) + "\n" + metadata + + "\nSymbol kind: " + page.metadata.symbolKind + ] let abstract = content.inlineText(page.abstract) if !abstract.isEmpty { diff --git a/Tests/CLIIntegrationTests/AppleDocsCommandIntegrationTests.swift b/Tests/CLIIntegrationTests/AppleDocsCommandIntegrationTests.swift index 5745ff6..8c40544 100644 --- a/Tests/CLIIntegrationTests/AppleDocsCommandIntegrationTests.swift +++ b/Tests/CLIIntegrationTests/AppleDocsCommandIntegrationTests.swift @@ -49,7 +49,7 @@ struct AppleDocsCommandIntegrationTests { let output = try runAppleDocs(arguments) // -- Assert -- - #expect(output.hasPrefix("String\n━━━━━━\nStructure · Swift\n")) + #expect(output.hasPrefix("String\n━━━━━━\nStructure · Swift\nSymbol kind: struct\n")) #expect(output.contains("Declaration\n───────────")) #expect(output.contains("│ @frozen struct String")) #expect(output.contains("Overview\n────────")) diff --git a/Tests/CLITests/renderer/DefaultTypeDocumentationRendererTests.swift b/Tests/CLITests/renderer/DefaultTypeDocumentationRendererTests.swift index 04dd682..878d983 100644 --- a/Tests/CLITests/renderer/DefaultTypeDocumentationRendererTests.swift +++ b/Tests/CLITests/renderer/DefaultTypeDocumentationRendererTests.swift @@ -34,6 +34,7 @@ struct DefaultTypeDocumentationRendererTests { MXHangDiagnostic ━━━━━━━━━━━━━━━━ Class · MetricKit + Symbol kind: class A diagnostic report. """ @@ -68,6 +69,7 @@ struct DefaultTypeDocumentationRendererTests { Package ━━━━━━━ Structure · PackageDescription + Symbol kind: struct The Swift package manifest representation. """ diff --git a/Tests/CLITests/renderer/TextTypeDocumentationRendererContentTests.swift b/Tests/CLITests/renderer/TextTypeDocumentationRendererContentTests.swift index 944d98c..6b7c488 100644 --- a/Tests/CLITests/renderer/TextTypeDocumentationRendererContentTests.swift +++ b/Tests/CLITests/renderer/TextTypeDocumentationRendererContentTests.swift @@ -129,7 +129,7 @@ struct TextTypeDocumentationRendererContentTests { let output = TextTypeDocumentationRenderer().render(page) // -- Assert -- - #expect(output == "View\n━━━━\nProtocol · SwiftUI") + #expect(output == "View\n━━━━\nProtocol · SwiftUI\nSymbol kind: protocol") } @Test( diff --git a/Tests/CLITests/renderer/TextTypeDocumentationRendererTests.swift b/Tests/CLITests/renderer/TextTypeDocumentationRendererTests.swift index 4e1e905..66f78c4 100644 --- a/Tests/CLITests/renderer/TextTypeDocumentationRendererTests.swift +++ b/Tests/CLITests/renderer/TextTypeDocumentationRendererTests.swift @@ -46,6 +46,7 @@ struct TextTypeDocumentationRendererTests { MXHangDiagnostic ━━━━━━━━━━━━━━━━ Class · MetricKit + Symbol kind: class An object representing a diagnostic report. @@ -262,6 +263,6 @@ struct TextTypeDocumentationRendererTests { let output = TextTypeDocumentationRenderer().render(page) // -- Assert -- - #expect(output == "String\n━━━━━━\nStructure · Swift") + #expect(output == "String\n━━━━━━\nStructure · Swift\nSymbol kind: struct") } }