Skip to content

Commit d7bf438

Browse files
committed
Wrap references to public types in comments in double backticks
This makes the types show up as links in the generated docc documentation
1 parent 967e487 commit d7bf438

File tree

66 files changed

+2856
-2850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2856
-2850
lines changed

CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ public let COMMON_NODES: [Node] = [
154154
Child(
155155
name: "Attributes",
156156
kind: .collection(kind: "AttributeList", collectionElementName: "Attribute"),
157-
description: "If there were standalone attributes without a declaration to attach them to, the `MissingDeclSyntax` will contain these.",
157+
description: "If there were standalone attributes without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these.",
158158
isOptional: true
159159
),
160160
Child(
161161
name: "Modifiers",
162162
kind: .collection(kind: "ModifierList", collectionElementName: "Modifier"),
163-
description: "If there were standalone modifiers without a declaration to attach them to, the `MissingDeclSyntax` will contain these.",
163+
description: "If there were standalone modifiers without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these.",
164164
isOptional: true
165165
),
166166
Child(

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ public let EXPR_NODES: [Node] = [
710710
Node(
711711
name: "ExprList",
712712
nameForDiagnostics: nil,
713-
description: "A list of expressions connected by operators. This list is contained by a `SequenceExprSyntax`.",
713+
description: "A list of expressions connected by operators. This list is contained by a ``SequenceExprSyntax``.",
714714
kind: "SyntaxCollection",
715715
element: "Expr",
716716
elementName: "Expression"

CodeGeneration/Sources/Utils/CodeGenerationFormat.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public class CodeGenerationFormat: BasicFormat {
9292
// MARK: - Private
9393

9494
private func shouldBeSeparatedByTwoNewlines(node: CodeBlockItemSyntax) -> Bool {
95-
// First item in the `CodeBlockItemListSyntax` don't need a newline or identation if the parent is a `SourceFileSyntax`.
95+
// First item in the ``CodeBlockItemListSyntax`` don't need a newline or identation if the parent is a ``SourceFileSyntax``.
9696
// We want to group imports so newline between them should be omitted
9797
return node.parent?.as(CodeBlockItemListSyntax.self)?.first == node || node.item.is(ImportDeclSyntax.self)
9898
}

CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import SwiftSyntax
1414
import SwiftSyntaxBuilder
1515
import SyntaxSupport
1616

17-
/// Extension to the `Child` type to provide functionality specific to
17+
/// Extension to the ``Child`` type to provide functionality specific to
1818
/// SwiftSyntaxBuilder.
1919
public extension Child {
20-
/// The type of this child, represented by a `SyntaxBuildableType`, which can
20+
/// The type of this child, represented by a ``SyntaxBuildableType``, which can
2121
/// be used to create the corresponding `Buildable` and `ExpressibleAs` types.
2222
var type: SyntaxBuildableType {
2323
SyntaxBuildableType(
@@ -81,7 +81,7 @@ public extension Child {
8181

8282
/// If this node is a token that can't contain arbitrary text, generate a Swift
8383
/// `precondition` statement that verifies the variable with name var_name and of type
84-
/// `TokenSyntax` contains one of the supported text options. Otherwise return `nil`.
84+
/// ``TokenSyntax`` contains one of the supported text options. Otherwise return `nil`.
8585
func generateAssertStmtTextChoices(varName: String) -> FunctionCallExprSyntax? {
8686
guard case .token(choices: let choices, requiresLeadingSpace: _, requiresTrailingSpace: _) = kind else {
8787
return nil

CodeGeneration/Sources/Utils/SyntaxBuildableNode.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212

1313
import SyntaxSupport
1414

15-
/// Extension to the `Node` type to provide functionality specific to
15+
/// Extension to the ``Node`` type to provide functionality specific to
1616
/// SwiftSyntaxBuilder.
1717
public extension Node {
18-
/// The node's syntax kind as `SyntaxBuildableType`.
18+
/// The node's syntax kind as ``SyntaxBuildableType``.
1919
var type: SyntaxBuildableType {
2020
SyntaxBuildableType(syntaxKind: syntaxKind)
2121
}
2222

23-
/// The node's syntax kind as `SyntaxBuildableType`.
23+
/// The node's syntax kind as ``SyntaxBuildableType``.
2424
var baseType: SyntaxBuildableType {
2525
if baseKind == "SyntaxCollection" {
2626
return SyntaxBuildableType(syntaxKind: "Syntax")

CodeGeneration/Sources/Utils/SyntaxBuildableType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public struct SyntaxBuildableType: Hashable {
8585
/// These names look as follows:
8686
/// - For nodes: The node name, e.g. `IdentifierExpr` (these are implemented as structs)
8787
/// - For base kinds: `<BaseKind>Buildable`, e.g. `ExprBuildable` (these are implemented as protocols)
88-
/// - For token: `TokenSyntax` (tokens don't have a dedicated type in SwiftSyntaxBuilder)
88+
/// - For token: ``TokenSyntax`` (tokens don't have a dedicated type in SwiftSyntaxBuilder)
8989
/// If the type is optional, the type is wrapped in an `OptionalType`.
9090
public var buildable: TypeSyntax {
9191
optionalWrapped(type: SimpleTypeIdentifierSyntax(name: .identifier(syntaxBaseName)))

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/KeywordFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ let keywordFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
5454
/// This is really unfortunate. Really, we should have a `switch` in
5555
/// `Keyword.defaultText` to return the keyword's kind but the constant lookup
5656
/// table is significantly faster. Ideally, we could also get the compiler to
57-
/// constant-evaluate `Keyword.spi.defaultText` to a `SyntaxText` but I don't
57+
/// constant-evaluate `Keyword.spi.defaultText` to a ``SyntaxText`` but I don't
5858
/// see how that's possible right now.
5959
private static let keywordTextLookupTable: [SyntaxText] = \(lookupTable)
6060
"""

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxAnyVisitorFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Utils
1818
let syntaxAnyVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
1919
try! ClassDeclSyntax(
2020
"""
21-
/// A `SyntaxVisitor` that can visit the nodes as generic `Syntax` values.
21+
/// A `SyntaxVisitor` that can visit the nodes as generic ``Syntax`` values.
2222
///
2323
/// This subclass of `SyntaxVisitor` is slower than the type-specific visitation
2424
/// of `SyntaxVisitor`. Use `SyntaxAnyVisitor` if the `visitAny(_)` function

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
2121
"""
2222
// MARK: - \(raw: node.name)
2323
24-
/// Protocol to which all `\(raw: node.name)` nodes conform. Extension point to add
25-
/// common methods to all `\(raw: node.name)` nodes.
24+
/// Protocol to which all ``\(raw: node.name)`` nodes conform. Extension point to add
25+
/// common methods to all ``\(raw: node.name)`` nodes.
2626
/// DO NOT CONFORM TO THIS PROTOCOL YOURSELF!
2727
public protocol \(raw: node.name)Protocol: \(raw: node.baseType.baseName)Protocol {}
2828
"""
@@ -62,7 +62,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
6262

6363
DeclSyntax(
6464
"""
65-
/// Create a `\(raw: node.name)` node from a specialized syntax node.
65+
/// Create a ``\(raw: node.name)`` node from a specialized syntax node.
6666
public init(_ syntax: some \(raw: node.name)Protocol) {
6767
// We know this cast is going to succeed. Go through init(_: SyntaxData)
6868
// to do a sanity check and verify the kind matches in debug builds and get
@@ -74,7 +74,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
7474

7575
DeclSyntax(
7676
"""
77-
/// Create a `\(raw: node.name)` node from a specialized optional syntax node.
77+
/// Create a ``\(raw: node.name)`` node from a specialized optional syntax node.
7878
public init?(_ syntax: (some \(raw: node.name)Protocol)?) {
7979
guard let syntax = syntax else { return nil }
8080
self.init(syntax)
@@ -95,7 +95,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
9595

9696
DeclSyntax(
9797
"""
98-
/// Create a `\(raw: node.name)` node from a specialized optional syntax node.
98+
/// Create a ``\(raw: node.name)`` node from a specialized optional syntax node.
9999
public init?(fromProtocol syntax: \(raw: node.name)Protocol?) {
100100
guard let syntax = syntax else { return nil }
101101
self.init(fromProtocol: syntax)
@@ -131,8 +131,8 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
131131

132132
try InitializerDeclSyntax(
133133
"""
134-
/// Creates a `\(raw: node.name)` node from the given `SyntaxData`. This assumes
135-
/// that the `SyntaxData` is of the correct kind. If it is not, the behaviour
134+
/// Creates a ``\(raw: node.name)`` node from the given ``SyntaxData``. This assumes
135+
/// that the ``SyntaxData`` is of the correct kind. If it is not, the behaviour
136136
/// is undefined.
137137
internal init(_ data: SyntaxData)
138138
"""

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
4141
let documentation =
4242
node.description.map { "/// " + $0 }
4343
?? """
44-
/// `\(node.name)` represents a collection of one or more
45-
/// `\(node.collectionElement)` nodes. \(node.name) behaves
44+
/// ``\(node.name)`` represents a collection of one or more
45+
/// `\(node.collectionElement)` nodes. ``\(node.name)`` behaves
4646
/// as a regular Swift collection, and has accessors that return new
4747
/// versions of the collection with different children.
4848
"""
@@ -186,12 +186,12 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
186186

187187
DeclSyntax(
188188
"""
189-
/// Creates a new `\(raw: node.name)` by replacing the underlying layout with
189+
/// Creates a new ``\(raw: node.name)`` by replacing the underlying layout with
190190
/// a different set of raw syntax nodes.
191191
///
192192
/// - Parameter layout: The new list of raw syntax nodes underlying this
193193
/// collection.
194-
/// - Returns: A new `\(raw: node.name)` with the new layout underlying it.
194+
/// - Returns: A new ``\(raw: node.name)`` with the new layout underlying it.
195195
internal func replacingLayout(_ layout: [RawSyntax?]) -> \(raw: node.name) {
196196
let arena = SyntaxArena()
197197
let newRaw = layoutView.replacingLayout(with: layout, arena: arena)
@@ -203,11 +203,11 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
203203

204204
DeclSyntax(
205205
"""
206-
/// Creates a new `\(raw: node.name)` by appending the provided syntax element
206+
/// Creates a new ``\(raw: node.name)`` by appending the provided syntax element
207207
/// to the children.
208208
///
209209
/// - Parameter syntax: The element to append.
210-
/// - Returns: A new `\(raw: node.name)` with that element appended to the end.
210+
/// - Returns: A new ``\(raw: node.name)`` with that element appended to the end.
211211
public func appending(_ syntax: Element) -> \(raw: node.name) {
212212
var newLayout = layoutView.formLayoutArray()
213213
newLayout.append(syntax.raw)
@@ -218,11 +218,11 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
218218

219219
DeclSyntax(
220220
"""
221-
/// Creates a new `\(raw: node.name)` by prepending the provided syntax element
221+
/// Creates a new ``\(raw: node.name)`` by prepending the provided syntax element
222222
/// to the children.
223223
///
224224
/// - Parameter syntax: The element to prepend.
225-
/// - Returns: A new `\(raw: node.name)` with that element prepended to the
225+
/// - Returns: A new ``\(raw: node.name)`` with that element prepended to the
226226
/// beginning.
227227
public func prepending(_ syntax: Element) -> \(raw: node.name) {
228228
return inserting(syntax, at: 0)
@@ -232,14 +232,14 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
232232

233233
DeclSyntax(
234234
"""
235-
/// Creates a new `\(raw: node.name)` by inserting the provided syntax element
235+
/// Creates a new ``\(raw: node.name)`` by inserting the provided syntax element
236236
/// at the provided index in the children.
237237
///
238238
/// - Parameters:
239239
/// - syntax: The element to insert.
240240
/// - index: The index at which to insert the element in the collection.
241241
///
242-
/// - Returns: A new `\(raw: node.name)` with that element appended to the end.
242+
/// - Returns: A new ``\(raw: node.name)`` with that element appended to the end.
243243
public func inserting(_ syntax: Element, at index: Int) -> \(raw: node.name) {
244244
var newLayout = layoutView.formLayoutArray()
245245
/// Make sure the index is a valid insertion index (0 to 1 past the end)
@@ -253,14 +253,14 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
253253

254254
DeclSyntax(
255255
"""
256-
/// Creates a new `\(raw: node.name)` by replacing the syntax element
256+
/// Creates a new ``\(raw: node.name)`` by replacing the syntax element
257257
/// at the provided index.
258258
///
259259
/// - Parameters:
260260
/// - index: The index at which to replace the element in the collection.
261261
/// - syntax: The element to replace with.
262262
///
263-
/// - Returns: A new `\(raw: node.name)` with the new element at the provided index.
263+
/// - Returns: A new ``\(raw: node.name)`` with the new element at the provided index.
264264
public func replacing(childAt index: Int, with syntax: Element) -> \(raw: node.name) {
265265
var newLayout = layoutView.formLayoutArray()
266266
/// Make sure the index is a valid index for replacing
@@ -274,11 +274,11 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
274274

275275
DeclSyntax(
276276
"""
277-
/// Creates a new `\(raw: node.name)` by removing the syntax element at the
277+
/// Creates a new ``\(raw: node.name)`` by removing the syntax element at the
278278
/// provided index.
279279
///
280280
/// - Parameter index: The index of the element to remove from the collection.
281-
/// - Returns: A new `\(raw: node.name)` with the element at the provided index
281+
/// - Returns: A new ``\(raw: node.name)`` with the element at the provided index
282282
/// removed.
283283
public func removing(childAt index: Int) -> \(raw: node.name) {
284284
var newLayout = layoutView.formLayoutArray()
@@ -290,9 +290,9 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
290290

291291
DeclSyntax(
292292
"""
293-
/// Creates a new `\(raw: node.name)` by removing the first element.
293+
/// Creates a new ``\(raw: node.name)`` by removing the first element.
294294
///
295-
/// - Returns: A new `\(raw: node.name)` with the first element removed.
295+
/// - Returns: A new ``\(raw: node.name)`` with the first element removed.
296296
public func removingFirst() -> \(raw: node.name) {
297297
var newLayout = layoutView.formLayoutArray()
298298
newLayout.removeFirst()
@@ -303,9 +303,9 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
303303

304304
DeclSyntax(
305305
"""
306-
/// Creates a new `\(raw: node.name)` by removing the last element.
306+
/// Creates a new ``\(raw: node.name)`` by removing the last element.
307307
///
308-
/// - Returns: A new `\(raw: node.name)` with the last element removed.
308+
/// - Returns: A new ``\(raw: node.name)`` with the last element removed.
309309
public func removingLast() -> \(raw: node.name) {
310310
var newLayout = layoutView.formLayoutArray()
311311
newLayout.removeLast()
@@ -317,7 +317,7 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
317317

318318
try! ExtensionDeclSyntax(
319319
"""
320-
/// Conformance for `\(raw: node.name)` to the `BidirectionalCollection` protocol.
320+
/// Conformance for ``\(raw: node.name)`` to the `BidirectionalCollection` protocol.
321321
extension \(raw: node.name): BidirectionalCollection
322322
"""
323323
) {

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func syntaxNode(emitKind: String) -> SourceFileSyntax {
6767

6868
DeclSyntax(
6969
"""
70-
/// Creates a `\(raw: node.name)` node from the given `SyntaxData`. This assumes
70+
/// Creates a ``\(raw: node.name)`` node from the given ``SyntaxData``. This assumes
7171
/// that the `SyntaxData` is of the correct kind. If it is not, the behaviour
7272
/// is undefined.
7373
internal init(_ data: SyntaxData) {
@@ -194,7 +194,7 @@ func syntaxNode(emitKind: String) -> SourceFileSyntax {
194194

195195
DeclSyntax(
196196
"""
197-
/// Adds the provided `\(raw: childElt)` to the node's `\(raw: child.swiftName)`
197+
/// Adds the provided `element` to the node's `\(raw: child.swiftName)`
198198
/// collection.
199199
/// - param element: The new `\(raw: childElt)` to add to the node's
200200
/// `\(raw: child.swiftName)` collection.

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxRewriterFile.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
3636
if node.baseType.baseName == "Syntax" && node.name != "MissingSyntax" {
3737
DeclSyntax(
3838
"""
39-
/// Visit a `\(raw: node.name)`.
39+
/// Visit a ``\(raw: node.name)``.
4040
/// - Parameter node: the node that is being visited
4141
/// - Returns: the rewritten node
4242
open func visit(_ node: \(raw: node.name)) -> \(raw: node.name) {
@@ -47,7 +47,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
4747
} else {
4848
DeclSyntax(
4949
"""
50-
/// Visit a `\(raw: node.name)`.
50+
/// Visit a ``\(raw: node.name)``.
5151
/// - Parameter node: the node that is being visited
5252
/// - Returns: the rewritten node
5353
open func visit(_ node: \(raw: node.name)) -> \(raw: node.baseType.syntaxBaseName) {
@@ -60,7 +60,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
6060

6161
DeclSyntax(
6262
"""
63-
/// Visit a `TokenSyntax`.
63+
/// Visit a ``TokenSyntax``.
6464
/// - Parameter node: the node that is being visited
6565
/// - Returns: the rewritten node
6666
open func visit(_ token: TokenSyntax) -> TokenSyntax {

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxTransformFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let syntaxTransformFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
2626
for node in SYNTAX_NODES where node.isVisitable {
2727
DeclSyntax(
2828
"""
29-
/// Visiting `\(raw: node.name)` specifically.
29+
/// Visiting ``\(raw: node.name)`` specifically.
3030
/// - Parameter node: the node we are visiting.
3131
/// - Returns: the sum of whatever the child visitors return.
3232
func visit(_ node: \(raw: node.name)) -> ResultType
@@ -47,7 +47,7 @@ let syntaxTransformFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
4747
for node in SYNTAX_NODES where node.isVisitable {
4848
DeclSyntax(
4949
"""
50-
/// Visiting `\(raw: node.name)` specifically.
50+
/// Visiting ``\(raw: node.name)`` specifically.
5151
/// - Parameter node: the node we are visiting.
5252
/// - Returns: nil by default.
5353
public func visit(_ node: \(raw: node.name)) -> ResultType {

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxVisitorFile.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ let syntaxVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
5353
for node in SYNTAX_NODES where node.isVisitable {
5454
DeclSyntax(
5555
"""
56-
/// Visiting `\(raw: node.name)` specifically.
56+
/// Visiting ``\(raw: node.name)`` specifically.
5757
/// - Parameter node: the node we are visiting.
5858
/// - Returns: how should we continue visiting.
5959
open func visit(_ node: \(raw: node.name)) -> SyntaxVisitorContinueKind {
@@ -64,7 +64,7 @@ let syntaxVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
6464

6565
DeclSyntax(
6666
"""
67-
/// The function called after visiting `\(raw: node.name)` and its descendents.
67+
/// The function called after visiting ``\(raw: node.name)`` and its descendents.
6868
/// - node: the node we just finished visiting.
6969
open func visitPost(_ node: \(raw: node.name)) {}
7070
"""
@@ -73,7 +73,7 @@ let syntaxVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
7373

7474
DeclSyntax(
7575
"""
76-
/// Visiting `TokenSyntax` specifically.
76+
/// Visiting ``TokenSyntax`` specifically.
7777
/// - Parameter node: the node we are visiting.
7878
/// - Returns: how should we continue visiting.
7979
open func visit(_ token: TokenSyntax) -> SyntaxVisitorContinueKind {

0 commit comments

Comments
 (0)