File: ExternalMetadata.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (86 lines) | stat: -rw-r--r-- 3,423 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 This source file is part of the Swift.org open source project

 Copyright (c) 2021 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
 See https://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import Foundation

/// A semantic version-number triplet with major, minor, and patch components.
public struct VersionTriplet: Equatable, Comparable {
    /// Returns a Boolean value that indicates whether the first version is less than the second version.
    ///
    /// - Parameters:
    ///   - lhs: A version to compare.
    ///   - rhs: Another version to compare.
    public static func < (lhs: VersionTriplet, rhs: VersionTriplet) -> Bool {
        if lhs.major != rhs.major { return lhs.major < rhs.major }
        if lhs.minor != rhs.minor { return lhs.minor < rhs.minor }
        if lhs.patch != rhs.patch { return lhs.patch < rhs.patch }
        return false // The version are equal
    }
    
    /// The major component, for example, "1" in "1.2.3".
    let major: Int
    /// The minor component, for example, "2" in "1.2.3".
    let minor: Int
    /// The patch component, for example, "3" in "1.2.3".
    let patch: Int
    
    /// Creates a new version triplet with the given major, minor, and patch components.
    /// - Parameters:
    ///   - major: The major component.
    ///   - minor: The minor component.
    ///   - patch: The patch component.
    public init(_ major: Int, _ minor: Int, _ patch: Int) {
        self.major = major
        self.minor = minor
        self.patch = patch
    }
}

/// A pair of a version number and beta information for a platform.
///
/// ## Topics
/// ### Semantic Versions
/// - ``VersionTriplet``
/// - ``Version``
public struct PlatformVersion: Equatable {
    /// The version number for the platform.
    public let version: VersionTriplet
    /// If `true`, this is a beta version.
    public let beta: Bool
    
    /// Creates a new version and beta pair for a platform.
    /// - Parameters:
    ///   - version: The version number for the platform.
    ///   - beta:  If the platform is considered in beta.
    public init(_ version: VersionTriplet, beta: Bool) {
        self.version = version
        self.beta = beta
    }
}

/// External metadata injected into the documentation compiler, for example via command line arguments.
public struct ExternalMetadata {
    /// The current version and beta information for platforms that may be encountered while processing symbol graph files.
    ///
    /// If the version that a symbol was introduced for a given platform (as indicated by the availability information in the symbol graph file) matches the
    /// current version for that platform (as indicated by this metadata) and the current version is in beta, then that symbol is also considered in beta.
    public var currentPlatforms: [String: PlatformVersion]?
    
    /// If `true`, inherited symbols retain their original docs.
    public var inheritDocs = false

    /// If `true`, there is no source bundle on disk and the inputs were passed via command line parameters.
    public var isGeneratedBundle = false
    
    /// The granularity of diagnostics to emit via the engine.
    ///
    /// > Note: This setting is set by the convert command.
    public var diagnosticLevel: DiagnosticSeverity = .warning
}