Skip to content

Commit 5625a8c

Browse files
committed
Always backtick token choices in docc comments
1 parent 5344894 commit 5625a8c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,18 @@ struct GrammarGenerator {
2020
/// - parameters:
2121
/// - tokenChoice: ``TokenChoice`` to describe
2222
/// - backticks: Whether to wrap the token choice in backticks
23-
private func grammar(for tokenChoice: TokenChoice, backticked: Bool = true) -> String {
24-
var description: String
23+
private func grammar(for tokenChoice: TokenChoice) -> String {
2524
switch tokenChoice {
2625
case .keyword(let keyword):
27-
description = "'\(keyword.spec.name)'"
26+
return "`'\(keyword.spec.name)'`"
2827
case .token(let token):
2928
let tokenSpec = token.spec
3029
if let tokenText = tokenSpec.text {
31-
description = "'\(tokenText)'"
30+
return "`'\(tokenText)'`"
3231
} else {
33-
description = "<\(tokenSpec.varOrCaseName)>"
32+
return "`<\(tokenSpec.varOrCaseName)>`"
3433
}
3534
}
36-
37-
return backticked ? "`\(description)`" : description
3835
}
3936

4037
private func grammar(for child: Child) -> String {
@@ -77,9 +74,9 @@ struct GrammarGenerator {
7774

7875
if case .token(let choices, _, _) = child.kind {
7976
if choices.count == 1 {
80-
return " \(generator.grammar(for: choices.first!, backticked: false))"
77+
return " \(generator.grammar(for: choices.first!))"
8178
} else {
82-
return choices.map { " - \(generator.grammar(for: $0, backticked: false))" }.joined(separator: "\n")
79+
return choices.map { " - \(generator.grammar(for: $0))" }.joined(separator: "\n")
8380
}
8481
} else {
8582
return ""

0 commit comments

Comments
 (0)