Skip to content

Commit 4a5dd44

Browse files
Adds the seeAlso aside (#96)
“See Also” is a common kind of aside that folks parsing markdown may wish to consider. For Swift-DocC specifically, there is a lot of pre-DocC Swift documentation content that uses this style of callout: ``` - SeeAlso: ``` In order to gracefully transition this content over to Swift-DocC style asides, we should add support for them.
1 parent 87ae1a8 commit 4a5dd44

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

Sources/Markdown/Interpretive Nodes/Aside.swift

Lines changed: 30 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-2022 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2023 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
@@ -92,6 +92,9 @@ public struct Aside {
9292
/// A "throws" aside.
9393
public static let `throws` = Kind(rawValue: "Throws")!
9494

95+
/// A "seeAlso" aside.
96+
public static let seeAlso = Kind(rawValue: "SeeAlso")!
97+
9598
/// A collection of preconfigured aside kinds.
9699
public static var allCases: [Aside.Kind] {
97100
[
@@ -118,9 +121,35 @@ public struct Aside {
118121
todo,
119122
version,
120123
`throws`,
124+
seeAlso,
121125
]
122126
}
123127

128+
/// The heading text to use when rendering this kind of aside.
129+
///
130+
/// For multi-word asides this value may differ from the aside's ``rawValue``.
131+
/// For example, the ``seeAlso`` aside's `rawValue` is `"SeeAlso"` but its
132+
/// `displayName` is `"See Also"`.
133+
/// Likewise, ``nonMutatingVariant``'s `rawValue` is
134+
/// `"NonMutatingVariant"` and its `displayName` is `"Non-Mutating Variant"`.
135+
///
136+
/// For simpler, single-word asides like ``bug``, the `displayName` and `rawValue` will
137+
/// be the same.
138+
public var displayName: String {
139+
switch self {
140+
case .seeAlso:
141+
return "See Also"
142+
case .nonMutatingVariant:
143+
return "Non-Mutating Variant"
144+
case .mutatingVariant:
145+
return "Mutating Variant"
146+
case .todo:
147+
return "To Do"
148+
default:
149+
return rawValue
150+
}
151+
}
152+
124153
/// The underlying raw string value.
125154
public var rawValue: String
126155

0 commit comments

Comments
 (0)