Skip to content
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
2 changes: 1 addition & 1 deletion Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -217,11 +219,13 @@ extension AutomaticCuration {
.`var`,
.`func`,
.`operator`,
.`macro`,

.`associatedtype`,
.`case`,
.`init`,
.`deinit`,
.`ivar`,
.`property`,
.`method`,
.`subscript`,
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftDocC/Model/DocumentationNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 62 additions & 1 deletion Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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",
]
)
}
}
193 changes: 193 additions & 0 deletions Tests/SwiftDocCTests/Test Resources/Whatsit-Objective-C.symbols.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
}