Skip to content

Commit 2d9308f

Browse files
[5.7] use new ivar/macro symbol kinds (#156)
* use new ivar/macro symbol kinds rdar://92124246 * add ivar and macro to the automatic curation order * add test for curating ivars and macros * switch CLMDB and swift-markdown to release/5.7 branches
1 parent ea819f5 commit 2d9308f

File tree

6 files changed

+268
-8
lines changed

6 files changed

+268
-8
lines changed

Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
121121
package.dependencies += [
122122
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMinor(from: "2.31.2")),
123123
.package(url: "https://github.com/apple/swift-nio-ssl.git", .upToNextMinor(from: "2.15.0")),
124-
.package(name: "swift-markdown", url: "https://github.com/apple/swift-markdown.git", .branch("main")),
125-
.package(name: "CLMDB", url: "https://github.com/apple/swift-lmdb.git", .branch("main")),
124+
.package(name: "swift-markdown", url: "https://github.com/apple/swift-markdown.git", .branch("release/5.7")),
125+
.package(name: "CLMDB", url: "https://github.com/apple/swift-lmdb.git", .branch("release/5.7")),
126126
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.0.1")),
127-
.package(name: "SymbolKit", url: "https://github.com/apple/swift-docc-symbolkit", .branch("main")),
127+
.package(name: "SymbolKit", url: "https://github.com/apple/swift-docc-symbolkit", .branch("release/5.7")),
128128
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "1.1.2")),
129129
]
130130

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ extension AutomaticCuration {
190190
case .`func`: return "Functions"
191191
case .`operator`: return "Operators"
192192
case .`init`: return "Initializers"
193+
case .ivar: return "Instance Variables"
194+
case .macro: return "Macros"
193195
case .`method`: return "Instance Methods"
194196
case .`property`: return "Instance Properties"
195197
case .`protocol`: return "Protocols"
@@ -217,11 +219,13 @@ extension AutomaticCuration {
217219
.`var`,
218220
.`func`,
219221
.`operator`,
222+
.`macro`,
220223

221224
.`associatedtype`,
222225
.`case`,
223226
.`init`,
224227
.`deinit`,
228+
.`ivar`,
225229
.`property`,
226230
.`method`,
227231
.`subscript`,

Sources/SwiftDocC/Model/DocumentationNode.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ public struct DocumentationNode {
443443
case .`func`: return .function
444444
case .`operator`: return .operator
445445
case .`init`: return .initializer
446+
case .ivar: return .instanceVariable
447+
case .macro: return .macro
446448
case .`method`: return .instanceMethod
447449
case .`property`: return .instanceProperty
448450
case .`protocol`: return .protocol

Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -420,4 +420,65 @@ class AutomaticCurationTests: XCTestCase {
420420
]
421421
)
422422
}
423+
424+
func testIvarsAndMacrosAreCuratedProperly() throws {
425+
let whatsitSymbols = Bundle.module.url(
426+
forResource: "Whatsit-Objective-C.symbols", withExtension: "json", subdirectory: "Test Resources")!
427+
428+
let (bundleURL, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in
429+
try? FileManager.default.copyItem(at: whatsitSymbols, to: url.appendingPathComponent("Whatsit-Objective-C.symbols.json"))
430+
}
431+
defer {
432+
try? FileManager.default.removeItem(at: bundleURL)
433+
}
434+
435+
let frameworkDocumentationNode = try context.entity(
436+
with: ResolvedTopicReference(
437+
bundleIdentifier: bundle.identifier,
438+
path: "/documentation/Whatsit",
439+
sourceLanguages: [.objectiveC]
440+
)
441+
)
442+
let objectiveCTopics = try AutomaticCuration.topics(
443+
for: frameworkDocumentationNode,
444+
withTrait: DocumentationDataVariantsTrait(interfaceLanguage: "occ"),
445+
context: context
446+
)
447+
448+
XCTAssertEqual(
449+
objectiveCTopics.flatMap { taskGroup in
450+
[taskGroup.title] + taskGroup.references.map(\.path)
451+
},
452+
[
453+
"Classes",
454+
"/documentation/Whatsit/Whatsit",
455+
456+
"Macros",
457+
"/documentation/Whatsit/IS_COOL",
458+
]
459+
)
460+
461+
let classDocumentationNode = try context.entity(
462+
with: ResolvedTopicReference(
463+
bundleIdentifier: bundle.identifier,
464+
path: "/documentation/Whatsit/Whatsit",
465+
sourceLanguages: [.objectiveC]
466+
)
467+
)
468+
let classTopics = try AutomaticCuration.topics(
469+
for: classDocumentationNode,
470+
withTrait: DocumentationDataVariantsTrait(interfaceLanguage: "occ"),
471+
context: context
472+
)
473+
474+
XCTAssertEqual(
475+
classTopics.flatMap { taskGroup in
476+
[taskGroup.title] + taskGroup.references.map(\.path)
477+
},
478+
[
479+
"Instance Variables",
480+
"/documentation/Whatsit/Whatsit/Ivar",
481+
]
482+
)
483+
}
423484
}
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
{
2+
"metadata" : {
3+
"formatVersion" : {
4+
"major" : 0,
5+
"minor" : 5,
6+
"patch" : 0
7+
},
8+
"generator" : "clang"
9+
},
10+
"module" : {
11+
"name" : "Whatsit",
12+
"platform" : {
13+
"architecture" : "x86_64",
14+
"operatingSystem" : {
15+
"minimumVersion" : {
16+
"major" : 11,
17+
"minor" : 0,
18+
"patch" : 0
19+
},
20+
"name" : "macos"
21+
},
22+
"vendor" : "apple"
23+
}
24+
},
25+
"relationships" : [
26+
{
27+
"kind" : "memberOf",
28+
"source" : "c:objc(cs)Whatsit@Ivar",
29+
"target" : "c:objc(cs)Whatsit",
30+
"targetFallback" : null
31+
}
32+
],
33+
"symbols" : [
34+
{
35+
"accessLevel" : "public",
36+
"declarationFragments" : [
37+
{
38+
"kind" : "keyword",
39+
"spelling" : "#define"
40+
},
41+
{
42+
"kind" : "text",
43+
"spelling" : " "
44+
},
45+
{
46+
"kind" : "identifier",
47+
"spelling" : "IS_COOL"
48+
},
49+
{
50+
"kind" : "text",
51+
"spelling" : "("
52+
},
53+
{
54+
"kind" : "internalParam",
55+
"spelling" : "X"
56+
},
57+
{
58+
"kind" : "text",
59+
"spelling" : ")"
60+
}
61+
],
62+
"identifier" : {
63+
"interfaceLanguage" : "occ",
64+
"precise" : "c:PlayingCard.h@154@macro@IS_COOL"
65+
},
66+
"kind" : {
67+
"displayName" : "Macro",
68+
"identifier" : "macro"
69+
},
70+
"location" : {
71+
"position" : {
72+
"character" : 8,
73+
"line" : 11
74+
},
75+
"uri" : "PlayingCard.h"
76+
},
77+
"names" : {
78+
"navigator" : [
79+
{
80+
"kind" : "identifier",
81+
"spelling" : "IS_COOL"
82+
}
83+
],
84+
"title" : "IS_COOL"
85+
},
86+
"pathComponents" : [
87+
"IS_COOL"
88+
]
89+
},
90+
{
91+
"accessLevel" : "public",
92+
"declarationFragments" : [
93+
{
94+
"kind" : "keyword",
95+
"spelling" : "@interface"
96+
},
97+
{
98+
"kind" : "text",
99+
"spelling" : " "
100+
},
101+
{
102+
"kind" : "identifier",
103+
"spelling" : "Whatsit"
104+
}
105+
],
106+
"identifier" : {
107+
"interfaceLanguage" : "occ",
108+
"precise" : "c:objc(cs)Whatsit"
109+
},
110+
"kind" : {
111+
"displayName" : "Class",
112+
"identifier" : "class"
113+
},
114+
"location" : {
115+
"position" : {
116+
"character" : 11,
117+
"line" : 64
118+
},
119+
"uri" : "PlayingCard.h"
120+
},
121+
"names" : {
122+
"navigator" : [
123+
{
124+
"kind" : "identifier",
125+
"spelling" : "Whatsit"
126+
}
127+
],
128+
"subHeading" : [
129+
{
130+
"kind" : "identifier",
131+
"spelling" : "Whatsit"
132+
}
133+
],
134+
"title" : "Whatsit"
135+
},
136+
"pathComponents" : [
137+
"Whatsit"
138+
]
139+
},
140+
{
141+
"accessLevel" : "public",
142+
"declarationFragments" : [
143+
{
144+
"kind" : "typeIdentifier",
145+
"preciseIdentifier" : "c:C",
146+
"spelling" : "char"
147+
},
148+
{
149+
"kind" : "text",
150+
"spelling" : " "
151+
},
152+
{
153+
"kind" : "identifier",
154+
"spelling" : "Ivar"
155+
}
156+
],
157+
"identifier" : {
158+
"interfaceLanguage" : "occ",
159+
"precise" : "c:objc(cs)Whatsit@Ivar"
160+
},
161+
"kind" : {
162+
"displayName" : "Instance Variable",
163+
"identifier" : "ivar"
164+
},
165+
"location" : {
166+
"position" : {
167+
"character" : 9,
168+
"line" : 65
169+
},
170+
"uri" : "PlayingCard.h"
171+
},
172+
"names" : {
173+
"navigator" : [
174+
{
175+
"kind" : "identifier",
176+
"spelling" : "Ivar"
177+
}
178+
],
179+
"subHeading" : [
180+
{
181+
"kind" : "identifier",
182+
"spelling" : "Ivar"
183+
}
184+
],
185+
"title" : "Ivar"
186+
},
187+
"pathComponents" : [
188+
"Whatsit",
189+
"Ivar"
190+
]
191+
}
192+
]
193+
}

0 commit comments

Comments
 (0)