Skip to content
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

Improve the ergonomics of working with the Symbol.Availability.Domain constants #90

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
20 changes: 11 additions & 9 deletions Sources/SymbolKit/SymbolGraph/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,29 @@ extension SymbolGraph {
guard let os = operatingSystem?.name else {
return nil
}
switch os {

let domain: Symbol.Availability.Domain
switch operatingSystem?.name {
case "macosx", "macos":
return SymbolGraph.Symbol.Availability.Domain.macOS
domain = .macOS
case "ios":
if environment == "macabi" {
return SymbolGraph.Symbol.Availability.Domain.macCatalyst

domain = .macCatalyst
} else {
return SymbolGraph.Symbol.Availability.Domain.iOS
domain = .iOS
}
case "watchos":
return SymbolGraph.Symbol.Availability.Domain.watchOS
domain = .watchOS
case "tvos":
return SymbolGraph.Symbol.Availability.Domain.tvOS
domain = .tvOS
case "visionos":
return SymbolGraph.Symbol.Availability.Domain.visionOS
domain = .visionOS
case "linux":
return SymbolGraph.Symbol.Availability.Domain.linux
domain = .linux
default:
return "Unsupported OS: \(os)"
}
return domain.rawValue
}

public init(architecture: String? = nil, vendor: String? = nil, operatingSystem: OperatingSystem? = nil, environment: String? = nil) {
Expand Down
30 changes: 15 additions & 15 deletions Sources/SymbolKit/SymbolGraph/Symbol/Availability/Domain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,76 +41,76 @@ extension SymbolGraph.Symbol.Availability {
in Swift, or availability applies to particular versions
of Swift.
*/
public static let swift = "Swift"
public static let swift = Domain(rawValue: "Swift")

/**
The Swift Package Manager Package Description Format.
*/
public static let swiftPM = "SwiftPM"
public static let swiftPM = Domain(rawValue: "SwiftPM")

/**
Apple's macOS operating system.
*/
public static let macOS = "macOS"
public static let macOS = Domain(rawValue: "macOS")

/**
An application extension for the macOS operating system.
*/
public static let macOSAppExtension = "macOSAppExtension"
public static let macOSAppExtension = Domain(rawValue: "macOSAppExtension")

/**
The iOS operating system.
*/
public static let iOS = "iOS"
public static let iOS = Domain(rawValue: "iOS")

/**
An application extension for the iOS operating system.
*/
public static let iOSAppExtension = "iOSAppExtension"
public static let iOSAppExtension = Domain(rawValue: "iOSAppExtension")

/**
The watchOS operating system.
*/
public static let watchOS = "watchOS"
public static let watchOS = Domain(rawValue: "watchOS")

/**
An application extension for the watchOS operating system.
*/
public static let watchOSAppExtension = "watchOSAppExtension"
public static let watchOSAppExtension = Domain(rawValue: "watchOSAppExtension")

/**
The tvOS operating system.
*/
public static let tvOS = "tvOS"
public static let tvOS = Domain(rawValue: "tvOS")

/**
An application extension for the tvOS operating system.
*/
public static let tvOSAppExtension = "tvOSAppExtension"
public static let tvOSAppExtension = Domain(rawValue: "tvOSAppExtension")

/**
The Mac Catalyst platform.
*/
public static let macCatalyst = "macCatalyst"
public static let macCatalyst = Domain(rawValue: "macCatalyst")

/**
An application extension for the Mac Catalyst platform.
*/
public static let macCatalystAppExtension = "macCatalystAppExtension"
public static let macCatalystAppExtension = Domain(rawValue: "macCatalystAppExtension")

/**
The visionOS operating system.
*/
public static let visionOS = "visionOS"
public static let visionOS = Domain(rawValue: "visionOS")

/**
An application extension for the visionOS operating system.
*/
public static let visionOSAppExtension = "visionOSAppExtension"
public static let visionOSAppExtension = Domain(rawValue: "visionOSAppExtension")

/**
A Linux-based operating system, but not a specific distribution.
*/
public static let linux = "Linux"
public static let linux = Domain(rawValue: "Linux")
}
}