Skip to content

Commit

Permalink
Merge branch 'main' into readable-symbol-link-disambiguation
Browse files Browse the repository at this point in the history
# Conflicts:
#	Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+DisambiguatedPaths.swift
#	Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Dump.swift
#	Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Error.swift
#	Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Find.swift
#	Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift
#	Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift
  • Loading branch information
d-ronnqvist committed Aug 28, 2023
2 parents f39847f + d756924 commit 0939305
Show file tree
Hide file tree
Showing 56 changed files with 1,176 additions and 222 deletions.
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"location" : "https://github.com/apple/swift-markdown.git",
"state" : {
"branch" : "main",
"revision" : "36b71b380ca9cb7497fc24416f8b77721eaf7330"
"revision" : "3d4b36cff09f785adf5efb190d458a3d44e6df87"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ public struct ConvertRequest: Codable {

/// The symbol identifiers that have an expanded documentation page available if they meet the associated access level requirement.
///
/// DocC sets the ``RenderMetadata/hasExpandedDocumentationForSymbols`` property to `true`
/// for these symbols if they meet the provided requirements, so that renderers can display a "View More" link
/// that navigates the user to the full version of the documentation page.
/// For each of these symbols DocC sets the ``RenderMetadata/hasNoExpandedDocumentation`` property to `true`
/// if the symbol fails to meet its provided requirements. This information in the page's ``RenderMetadata`` can be used to display
/// a "View More" link that navigates the user to the full version of the documentation page.
public var symbolIdentifiersWithExpandedDocumentation: [String: ExpandedDocumentationRequirements]?

/// The default code listing language for the documentation bundle to convert.
Expand Down
57 changes: 57 additions & 0 deletions Sources/SwiftDocC/Infrastructure/Diagnostics/ANSIAnnotation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
This source file is part of the Swift.org open source project
Copyright (c) 2023 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

struct ANSIAnnotation {
enum Color: UInt8 {
case normal = 0
case red = 31
case green = 32
case yellow = 33
case `default` = 39
}

enum Trait: UInt8 {
case normal = 0
case bold = 1
case italic = 3
}

private var color: Color
private var trait: Trait

/// The textual representation of the annotation.
private var code: String {
"\u{001B}[\(trait.rawValue);\(color.rawValue)m"
}

init(color: Color, trait: Trait = .normal) {
self.color = color
self.trait = trait
}

func applied(to message: String) -> String {
"\(code)\(message)\(ANSIAnnotation.normal.code)"
}

static var normal: ANSIAnnotation {
self.init(color: .normal, trait: .normal)
}

/// Annotation used for highlighting source text.
static var sourceHighlight: ANSIAnnotation {
ANSIAnnotation(color: .green, trait: .bold)
}
/// Annotation used for highlighting source suggestion.
static var sourceSuggestionHighlight: ANSIAnnotation {
ANSIAnnotation(color: .default, trait: .bold)
}
}

0 comments on commit 0939305

Please sign in to comment.