From 8533107527ccf1dffb16ddfe8812335de1b940f1 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Tue, 19 Apr 2022 11:53:04 -0600 Subject: [PATCH 1/4] use new ivar/macro symbol kinds rdar://92124246 --- Package.resolved | 4 ++-- Package.swift | 2 +- .../Infrastructure/Topic Graph/AutomaticCuration.swift | 2 ++ Sources/SwiftDocC/Model/DocumentationNode.swift | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Package.resolved b/Package.resolved index 292456e804..3aff9a6516 100644 --- a/Package.resolved +++ b/Package.resolved @@ -41,8 +41,8 @@ "package": "SymbolKit", "repositoryURL": "https://github.com/apple/swift-docc-symbolkit", "state": { - "branch": "main", - "revision": "ed8ce5502e563090ab1400b4dd7d703b01eceabb", + "branch": "release/5.7", + "revision": "3866a31493efce07a57e8344b8b1318c6ae1b3c8", "version": null } }, diff --git a/Package.swift b/Package.swift index 0900ffdeb1..878544ec61 100644 --- a/Package.swift +++ b/Package.swift @@ -124,7 +124,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { .package(name: "swift-markdown", url: "https://github.com/apple/swift-markdown.git", .branch("main")), .package(name: "CLMDB", url: "https://github.com/apple/swift-lmdb.git", .branch("main")), .package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.0.1")), - .package(name: "SymbolKit", url: "https://github.com/apple/swift-docc-symbolkit", .branch("main")), + .package(name: "SymbolKit", url: "https://github.com/apple/swift-docc-symbolkit", .branch("release/5.7")), .package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "1.1.2")), ] diff --git a/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift b/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift index e33a21125a..f948899dd4 100644 --- a/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift +++ b/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift @@ -190,6 +190,8 @@ extension AutomaticCuration { case .`func`: return "Functions" case .`operator`: return "Operators" case .`init`: return "Initializers" + case .ivar: return "Instance Variables" + case .macro: return "Macros" case .`method`: return "Instance Methods" case .`property`: return "Instance Properties" case .`protocol`: return "Protocols" diff --git a/Sources/SwiftDocC/Model/DocumentationNode.swift b/Sources/SwiftDocC/Model/DocumentationNode.swift index ba585876c0..27f3cf332a 100644 --- a/Sources/SwiftDocC/Model/DocumentationNode.swift +++ b/Sources/SwiftDocC/Model/DocumentationNode.swift @@ -443,6 +443,8 @@ public struct DocumentationNode { case .`func`: return .function case .`operator`: return .operator case .`init`: return .initializer + case .ivar: return .instanceVariable + case .macro: return .macro case .`method`: return .instanceMethod case .`property`: return .instanceProperty case .`protocol`: return .protocol From 5bcacef61fba4d2a7caaeaea08ea85afcf8df7e3 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Thu, 21 Apr 2022 15:25:25 -0600 Subject: [PATCH 2/4] add ivar and macro to the automatic curation order --- .../Infrastructure/Topic Graph/AutomaticCuration.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift b/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift index f948899dd4..c0a58b70e0 100644 --- a/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift +++ b/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift @@ -219,11 +219,13 @@ extension AutomaticCuration { .`var`, .`func`, .`operator`, + .`macro`, .`associatedtype`, .`case`, .`init`, .`deinit`, + .`ivar`, .`property`, .`method`, .`subscript`, From 21fb887b42efec2e46fed606604b92841d1564bf Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 22 Apr 2022 10:22:47 -0600 Subject: [PATCH 3/4] add test for curating ivars and macros --- .../AutomaticCurationTests.swift | 63 +++++- .../Whatsit-Objective-C.symbols.json | 193 ++++++++++++++++++ 2 files changed, 255 insertions(+), 1 deletion(-) create mode 100644 Tests/SwiftDocCTests/Test Resources/Whatsit-Objective-C.symbols.json diff --git a/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift b/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift index 89a22eb880..54219ec5e3 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2022 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -420,4 +420,65 @@ class AutomaticCurationTests: XCTestCase { ] ) } + + func testIvarsAndMacrosAreCuratedProperly() throws { + let whatsitSymbols = Bundle.module.url( + forResource: "Whatsit-Objective-C.symbols", withExtension: "json", subdirectory: "Test Resources")! + + let (bundleURL, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + try? FileManager.default.copyItem(at: whatsitSymbols, to: url.appendingPathComponent("Whatsit-Objective-C.symbols.json")) + } + defer { + try? FileManager.default.removeItem(at: bundleURL) + } + + let frameworkDocumentationNode = try context.entity( + with: ResolvedTopicReference( + bundleIdentifier: bundle.identifier, + path: "/documentation/Whatsit", + sourceLanguages: [.objectiveC] + ) + ) + let objectiveCTopics = try AutomaticCuration.topics( + for: frameworkDocumentationNode, + withTrait: DocumentationDataVariantsTrait(interfaceLanguage: "occ"), + context: context + ) + + XCTAssertEqual( + objectiveCTopics.flatMap { taskGroup in + [taskGroup.title] + taskGroup.references.map(\.path) + }, + [ + "Classes", + "/documentation/Whatsit/Whatsit", + + "Macros", + "/documentation/Whatsit/IS_COOL", + ] + ) + + let classDocumentationNode = try context.entity( + with: ResolvedTopicReference( + bundleIdentifier: bundle.identifier, + path: "/documentation/Whatsit/Whatsit", + sourceLanguages: [.objectiveC] + ) + ) + let classTopics = try AutomaticCuration.topics( + for: classDocumentationNode, + withTrait: DocumentationDataVariantsTrait(interfaceLanguage: "occ"), + context: context + ) + + XCTAssertEqual( + classTopics.flatMap { taskGroup in + [taskGroup.title] + taskGroup.references.map(\.path) + }, + [ + "Instance Variables", + "/documentation/Whatsit/Whatsit/Ivar", + ] + ) + } } diff --git a/Tests/SwiftDocCTests/Test Resources/Whatsit-Objective-C.symbols.json b/Tests/SwiftDocCTests/Test Resources/Whatsit-Objective-C.symbols.json new file mode 100644 index 0000000000..b3292077b4 --- /dev/null +++ b/Tests/SwiftDocCTests/Test Resources/Whatsit-Objective-C.symbols.json @@ -0,0 +1,193 @@ +{ + "metadata" : { + "formatVersion" : { + "major" : 0, + "minor" : 5, + "patch" : 0 + }, + "generator" : "clang" + }, + "module" : { + "name" : "Whatsit", + "platform" : { + "architecture" : "x86_64", + "operatingSystem" : { + "minimumVersion" : { + "major" : 11, + "minor" : 0, + "patch" : 0 + }, + "name" : "macos" + }, + "vendor" : "apple" + } + }, + "relationships" : [ + { + "kind" : "memberOf", + "source" : "c:objc(cs)Whatsit@Ivar", + "target" : "c:objc(cs)Whatsit", + "targetFallback" : null + } + ], + "symbols" : [ + { + "accessLevel" : "public", + "declarationFragments" : [ + { + "kind" : "keyword", + "spelling" : "#define" + }, + { + "kind" : "text", + "spelling" : " " + }, + { + "kind" : "identifier", + "spelling" : "IS_COOL" + }, + { + "kind" : "text", + "spelling" : "(" + }, + { + "kind" : "internalParam", + "spelling" : "X" + }, + { + "kind" : "text", + "spelling" : ")" + } + ], + "identifier" : { + "interfaceLanguage" : "occ", + "precise" : "c:PlayingCard.h@154@macro@IS_COOL" + }, + "kind" : { + "displayName" : "Macro", + "identifier" : "macro" + }, + "location" : { + "position" : { + "character" : 8, + "line" : 11 + }, + "uri" : "PlayingCard.h" + }, + "names" : { + "navigator" : [ + { + "kind" : "identifier", + "spelling" : "IS_COOL" + } + ], + "title" : "IS_COOL" + }, + "pathComponents" : [ + "IS_COOL" + ] + }, + { + "accessLevel" : "public", + "declarationFragments" : [ + { + "kind" : "keyword", + "spelling" : "@interface" + }, + { + "kind" : "text", + "spelling" : " " + }, + { + "kind" : "identifier", + "spelling" : "Whatsit" + } + ], + "identifier" : { + "interfaceLanguage" : "occ", + "precise" : "c:objc(cs)Whatsit" + }, + "kind" : { + "displayName" : "Class", + "identifier" : "class" + }, + "location" : { + "position" : { + "character" : 11, + "line" : 64 + }, + "uri" : "PlayingCard.h" + }, + "names" : { + "navigator" : [ + { + "kind" : "identifier", + "spelling" : "Whatsit" + } + ], + "subHeading" : [ + { + "kind" : "identifier", + "spelling" : "Whatsit" + } + ], + "title" : "Whatsit" + }, + "pathComponents" : [ + "Whatsit" + ] + }, + { + "accessLevel" : "public", + "declarationFragments" : [ + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:C", + "spelling" : "char" + }, + { + "kind" : "text", + "spelling" : " " + }, + { + "kind" : "identifier", + "spelling" : "Ivar" + } + ], + "identifier" : { + "interfaceLanguage" : "occ", + "precise" : "c:objc(cs)Whatsit@Ivar" + }, + "kind" : { + "displayName" : "Instance Variable", + "identifier" : "ivar" + }, + "location" : { + "position" : { + "character" : 9, + "line" : 65 + }, + "uri" : "PlayingCard.h" + }, + "names" : { + "navigator" : [ + { + "kind" : "identifier", + "spelling" : "Ivar" + } + ], + "subHeading" : [ + { + "kind" : "identifier", + "spelling" : "Ivar" + } + ], + "title" : "Ivar" + }, + "pathComponents" : [ + "Whatsit", + "Ivar" + ] + } + ] +} From 58adcf5ffea934f98b437756f4135086a3fd3236 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 22 Apr 2022 18:06:17 -0600 Subject: [PATCH 4/4] switch CLMDB and swift-markdown to release/5.7 branches --- Package.resolved | 4 ++-- Package.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Package.resolved b/Package.resolved index 3aff9a6516..ac62b3fd6a 100644 --- a/Package.resolved +++ b/Package.resolved @@ -50,7 +50,7 @@ "package": "CLMDB", "repositoryURL": "https://github.com/apple/swift-lmdb.git", "state": { - "branch": "main", + "branch": "release/5.7", "revision": "6ea45a7ebf6d8f72bd299dfcc3299e284bbb92ee", "version": null } @@ -59,7 +59,7 @@ "package": "swift-markdown", "repositoryURL": "https://github.com/apple/swift-markdown.git", "state": { - "branch": "main", + "branch": "release/5.7", "revision": "caafc56d3794a08c2203fe417b3aff81e2ab2fc1", "version": null } diff --git a/Package.swift b/Package.swift index 878544ec61..8e2fbf3dd2 100644 --- a/Package.swift +++ b/Package.swift @@ -121,8 +121,8 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { package.dependencies += [ .package(url: "https://github.com/apple/swift-nio.git", .upToNextMinor(from: "2.31.2")), .package(url: "https://github.com/apple/swift-nio-ssl.git", .upToNextMinor(from: "2.15.0")), - .package(name: "swift-markdown", url: "https://github.com/apple/swift-markdown.git", .branch("main")), - .package(name: "CLMDB", url: "https://github.com/apple/swift-lmdb.git", .branch("main")), + .package(name: "swift-markdown", url: "https://github.com/apple/swift-markdown.git", .branch("release/5.7")), + .package(name: "CLMDB", url: "https://github.com/apple/swift-lmdb.git", .branch("release/5.7")), .package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.0.1")), .package(name: "SymbolKit", url: "https://github.com/apple/swift-docc-symbolkit", .branch("release/5.7")), .package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "1.1.2")),