Skip to content

Commit 338a626

Browse files
authored
Merge pull request #1777 from ahoppen/ahoppen/docc-warnings
Fix warnings when generating documentation using docc
2 parents 8a75944 + cdb4ef3 commit 338a626

File tree

17 files changed

+42
-59
lines changed

17 files changed

+42
-59
lines changed

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ public let DECL_NODES: [Node] = [
634634
Child(
635635
name: "Attributes",
636636
kind: .collection(kind: .attributeList, collectionElementName: "Attribute"),
637-
documentation: "If there were attributes before the editor placeholder, the ``EditorPlaceholderDecl`` will contain these.",
637+
documentation: "If there were attributes before the editor placeholder, the ``EditorPlaceholderDeclSyntax`` will contain these.",
638638
isOptional: true
639639
),
640640
Child(

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ let nodesSections: String = {
4646
types: [
4747
"SyntaxChildren",
4848
"SyntaxChildrenIndex",
49-
"SyntaxChildrenIndexData",
5049
]
5150
+ SYNTAX_NODES.flatMap({ (node: Node) -> [String] in
5251
guard let node = node.collectionNode else {
@@ -62,7 +61,7 @@ let nodesSections: String = {
6261

6362
addSection(heading: "Miscellaneous Syntax", types: SYNTAX_NODES.map(\.kind.syntaxType.description).filter({ !handledSyntaxTypes.contains($0) }))
6463

65-
addSection(heading: "Traits", types: TRAITS.map(\.traitName))
64+
addSection(heading: "Traits", types: TRAITS.map { "\($0.traitName)Syntax" })
6665

6766
return result
6867
}()

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SwiftSyntaxDoccIndexTemplate.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,3 @@ These articles are intended for developers wishing to contribute to SwiftSyntax
8282
- <doc:SwiftSyntax/SyntaxEnum>
8383
- <doc:SwiftSyntax/SyntaxHashable>
8484
- <doc:SwiftSyntax/SyntaxIdentifier>
85-
- <doc:SwiftSyntax/RawTokenKind>

Sources/SwiftParser/Parser.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
/// from a bad parse should be left `nonmutating` to indicate that they do not
3030
/// consume tokens.
3131
///
32-
/// Token consumption is generally either unconditional via ``TokenConsumer/consumeAnyToken()``
33-
/// or conditional via a combination of ``TokenConsumer/at(_:where:)``
32+
/// Token consumption is generally either unconditional via `TokenConsumer.consumeAnyToken()`
33+
/// or conditional via a combination of `TokenConsumer/at(_:where:)`
3434
/// and `TokenConsumer.eat(_:)`. When parsing conditionally, `at` returns a
3535
/// handle that is passed to `eat`. This ensures that any structure that is
3636
/// checked for is actually parsed by the parser at that position. If the parser
@@ -46,7 +46,7 @@
4646
/// /* */
4747
/// let rbrace = self.expect(.rightBrace)
4848
///
49-
/// Unlike ``TokenConsumer/eat(_:)``, ``Parser/expect(_:remapping:)`` returns
49+
/// Unlike `TokenConsumer.eat(_:)`, `Parser.expect(_:remapping:)` returns
5050
/// a `missing` token of the given kind. This allows the tree to remain
5151
/// well-formed even when the input text is not, all without affecting
5252
/// source fidelity.
@@ -72,8 +72,8 @@
7272
///
7373
/// This parser provides at most one token worth of lookahead via
7474
/// `peek()`. If more tokens are required to disambiguate a parse, a
75-
/// ``Parser/Lookahead`` instance should be constructed instead with
76-
/// ``Parser/lookahead()``.
75+
/// `Parser.Lookahead` instance should be constructed instead with
76+
/// `Parser.lookahead()`.
7777
///
7878
/// Source Fidelity
7979
/// ===============

Sources/SwiftParser/SwiftParser.docc/FixingBugs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ To add a new, more contextual diagnostic, perform the following steps.
6565
```
6666
2. Mark the location at which you expect the diagnostic to be produced with `1️⃣`. If you expect multiple diagnostics to be produced, you can use multiple of these markers with different names and use these markers by passing a `locationMarker` to `DiagnosticSpec`. The list of valid marker emojis can be found in `Character.isMarkerEmoji`.
6767
3. Determine which node encompasses all information that is necessary to produce the improved diagnostic – for example `FunctionSignatureSyntax` contains all information to diagnose if the `throws` keyword was written after the `->` instead of in front of it.
68-
4. If the diagnostic message you want to emit does not exist yet, add a case to <doc:SwiftParser/DiagnosticKind> for the new diagnostic.
69-
5. If the function does not already exist, write a new visit method on <doc:SwiftParser/ParseDiagnosticsGenerator>.
68+
4. If the diagnostic message you want to emit does not exist yet, add a case to `StaticParserError` for the new diagnostic. If the diagnostic needs to take parameters, add a new struct to in `ParserDiagnsoticMessages.swift`.
69+
5. If the function does not already exist, write a new visit method on `ParseDiagnosticsGenerator`.
7070
6. In that visitation method, detect the pattern for which the improved diagnostic should be emitted and emit it using `diagnostics.append`.
7171
7. Mark the missing or garbage nodes that are covered by the new diagnostic as handled by adding their `SyntaxIdentifier`s to `handledNodes`.
7272
8. If the diagnostic produces Fix-Its assert that they are generated by adding the Fix-It's message to the `DiagnosticSpec` with the `fixIt` parameter and asserting that applying the Fix-Its produces the correct source code by adding the `fixedSource` parameter to `assertParse`.

Sources/SwiftParser/SwiftParser.docc/ParserDesign.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ stateless. It is not a hard and fast rule that the parse be stateless, but
109109
engineering it with that mindset has enabled a relatively clean, testable
110110
parser design to emerge. Swift is not a context-free language, so there will
111111
inevitably need to be some state involved during the parse. The parser is
112-
designed to sequester those stateful decisions
113-
(e.g. <doc:SwiftParser/Parser/Lookahead>) away from the main parse productions.
112+
designed to sequester those stateful decisions (e.g. `Parser.Lookahead`)
113+
away from the main parse productions.
114114

115115
What ambient state is present occurs as arguments to certain productions that
116116
are required to enable or disable their child productions in response to some

Sources/SwiftParser/SwiftParser.docc/ParserRecovery.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ with these diagnostics.
3333

3434
When the parser expects a token but can’t find it, it looks ahead to see if it
3535
can find the expected token by using a token precedence model. Tokens are
36-
divided in precedence groups (see ``TokenPrecedence``),
36+
divided in precedence groups (see `TokenPrecedence`),
3737
dependening on how strongly they mark the structure of the source code. For
3838
example, keywords that start a declaration, like `func`, have a higher
3939
precedence than expression keywords, like `self`.

Sources/SwiftParser/SwiftParser.docc/ParsingBasics.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ extension Parser {
108108
```
109109

110110
This simple function introduces many of the basic concepts that form the
111-
backbone of the parser's implementation. The ``Parser/eat(_:)`` method
111+
backbone of the parser's implementation. The `Parser.eat(_:)` method
112112
provides a function to examine the input stream and advance one step if the
113113
provided token kind is present. To form the node, a call to the initializer
114114
is made, which acts to wire up all of the sub-nodes into a single
115115
`RawOptionalTypeSyntax`.
116116

117117
### Unconditional Parsing
118118

119-
The ``Parser/eat(_:)`` method unconditionally consumes a token of the given
119+
The `Parser.eat(_:)` method unconditionally consumes a token of the given
120120
type, and an assertion is raised if the input token's kind does not match.
121121
This function is most appropriate for encoding structural invariants during
122122
the parse. For example, the decision to parse a `FunctionDeclSyntax` node is
@@ -128,7 +128,7 @@ calling the function parsing method.
128128
### Conditional Parsing
129129

130130
To model conditional productions, the syntax tree uses `Optional`-typed
131-
syntax nodes, and the parser uses the ``Parser/consume(if:)`` method.
131+
syntax nodes, and the parser uses the `Parser.consume(if:)` method.
132132
For a Swift declaration item, a trailing semicolon is optional:
133133

134134
```swift
@@ -146,7 +146,7 @@ extension Parser {
146146
}
147147
```
148148

149-
Unlike ``Parser/eat(_:)``, if the parser does not encounter a token of the
149+
Unlike `Parser.eat(_:)`, if the parser does not encounter a token of the
150150
given type, a `nil` token is returned and the input is left unconsumed.
151151

152152
### Sequence Parsing

Sources/SwiftParser/SwiftParser.docc/SwiftParser.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,6 @@ There are several design principles that govern the parser:
4646
- **Minimal context**: The parser requires minimal context to parse Swift code, which consists of only those things required to handle a suitable Swift dialect, e.g., whether [regex literals](https://github.com/apple/swift-evolution/blob/main/proposals/0354-regex-literals.md) are supported. The parser can be invoked on any input source code, starting at any major production in the grammar (e.g., full source file, an individual type, an individual expression).
4747
- **Incremental**: A parse tree produced for a source file can be incrementally updated for a new version of that source file, reusing syntax nodes where possible to reduce computation overhead and memory.
4848

49-
### Lexical Analysis
50-
51-
- <doc:SwiftParser/Lexer>
52-
- <doc:SwiftParser/Lexer/Lexeme>
53-
- <doc:SwiftParser/Lexer/Cursor>
54-
- <doc:SwiftParser/Lexer/LexemeSequence>
55-
56-
### Parsing
57-
58-
- <doc:SwiftParser/TokenConsumer>
59-
- <doc:SwiftParser/Parser>
60-
- <doc:SwiftParser/Parser/Lookahead>
61-
6249
### Development
6350

6451
- <doc:SwiftParser/FilingBugReports>

Sources/SwiftSyntax/Documentation.docc/Contributing/SPI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
Learn when SwiftSyntax exposes declaration annotated as `@_spi`.
44

5-
Functions marked as `@_spi(RawSyntax)` (where ``RawSyntax`` can be any name) are considered *SPI* (System Programming Interface) and are only accessible if the module that declares them is imported as `@_spi(RawSyntax)`.
5+
Functions marked as `@_spi(RawSyntax)` (where `RawSyntax` can be any name) are considered *SPI* (System Programming Interface) and are only accessible if the module that declares them is imported as `@_spi(RawSyntax)`.
66

77
Since functions marked as SPI are not part of the public API, swift-syntax makes no guarantee to their source stability. swift-syntax makes no effort to keep its SPI stable.
88

9-
Declarations are typically marked as SPI because they have some kind of caveat that makes them unsafe to use in general. For example, when accessing ``RawSyntax`` nodes, you need to manually guarantee that the ``SyntaxArena`` they’re allocated in will not be de-allocated. Other declarations have an `@_spi` to share them between different modules within the swift-syntax package. These would use the [`package` modifier](https://github.com/apple/swift-evolution/blob/main/proposals/0386-package-access-modifier.md) if not for the fact that swift-syntax needed to compile with the last two Swift releases (see <doc:Swift-Version>).
9+
Declarations are typically marked as SPI because they have some kind of caveat that makes them unsafe to use in general. For example, when accessing `RawSyntax` nodes, you need to manually guarantee that the ``SyntaxArena`` they’re allocated in will not be de-allocated. Other declarations have an `@_spi` to share them between different modules within the swift-syntax package. These would use the [`package` modifier](https://github.com/apple/swift-evolution/blob/main/proposals/0386-package-access-modifier.md) if not for the fact that swift-syntax needed to compile with the last two Swift releases (see <doc:Swift-Version>).

Sources/SwiftSyntax/Documentation.docc/Working with SwiftSyntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ of high-level APIs for expressing these modifications. In general, data in
178178
syntax nodes can be accessed via a getter and updated with a corresponding
179179
`with*` method. For example, the name of a class can be retrieved with the
180180
``ClassDeclSyntax/identifier`` accessor, and replaced with the
181-
``ClassDeclSyntax/withIdentifier(_:)`` update function. This method returns
181+
``ClassDeclSyntax/with(_:_:)-3exln`` update function. This method returns
182182
a new ``ClassDeclSyntax`` value.
183183

184184
## Building Syntax Trees

Sources/SwiftSyntax/Documentation.docc/generated/SwiftSyntax.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ These articles are intended for developers wishing to contribute to SwiftSyntax
203203

204204
- <doc:SwiftSyntax/SyntaxChildren>
205205
- <doc:SwiftSyntax/SyntaxChildrenIndex>
206-
- <doc:SwiftSyntax/SyntaxChildrenIndexData>
207206
- <doc:SwiftSyntax/AccessorListSyntax>
208207
- <doc:SwiftSyntax/ArrayElementListSyntax>
209208
- <doc:SwiftSyntax/ArrayElementSyntax>
@@ -371,17 +370,17 @@ These articles are intended for developers wishing to contribute to SwiftSyntax
371370

372371
### Traits
373372

374-
- <doc:SwiftSyntax/Braced>
375-
- <doc:SwiftSyntax/DeclGroup>
376-
- <doc:SwiftSyntax/EffectSpecifiers>
377-
- <doc:SwiftSyntax/FreestandingMacroExpansion>
378-
- <doc:SwiftSyntax/IdentifiedDecl>
379-
- <doc:SwiftSyntax/Parenthesized>
380-
- <doc:SwiftSyntax/WithAttributes>
381-
- <doc:SwiftSyntax/WithCodeBlock>
382-
- <doc:SwiftSyntax/WithModifiers>
383-
- <doc:SwiftSyntax/WithStatements>
384-
- <doc:SwiftSyntax/WithTrailingComma>
373+
- <doc:SwiftSyntax/BracedSyntax>
374+
- <doc:SwiftSyntax/DeclGroupSyntax>
375+
- <doc:SwiftSyntax/EffectSpecifiersSyntax>
376+
- <doc:SwiftSyntax/FreestandingMacroExpansionSyntax>
377+
- <doc:SwiftSyntax/IdentifiedDeclSyntax>
378+
- <doc:SwiftSyntax/ParenthesizedSyntax>
379+
- <doc:SwiftSyntax/WithAttributesSyntax>
380+
- <doc:SwiftSyntax/WithCodeBlockSyntax>
381+
- <doc:SwiftSyntax/WithModifiersSyntax>
382+
- <doc:SwiftSyntax/WithStatementsSyntax>
383+
- <doc:SwiftSyntax/WithTrailingCommaSyntax>
385384

386385

387386

@@ -410,4 +409,3 @@ These articles are intended for developers wishing to contribute to SwiftSyntax
410409
- <doc:SwiftSyntax/SyntaxEnum>
411410
- <doc:SwiftSyntax/SyntaxHashable>
412411
- <doc:SwiftSyntax/SyntaxIdentifier>
413-
- <doc:SwiftSyntax/RawTokenKind>

Sources/SwiftSyntax/SyntaxArena.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/// A syntax arena owns the memory for all syntax nodes within it.
1414
///
1515
/// The following is only relevant if you are accessing the raw syntax tree using
16-
/// ``RawSyntax`` nodes. When working with syntax trees using SwiftSyntax’s API,
16+
/// `RawSyntax` nodes. When working with syntax trees using SwiftSyntax’s API,
1717
/// the usage of a ``SyntaxArena`` is transparent.
1818
///
1919
/// Contrary to Swift’s usual memory model, syntax node's are not individually
@@ -26,15 +26,15 @@
2626
/// As a consequence, syntax nodes cannot be freed individually but the memory
2727
/// will get freed once the owning ``SyntaxArena`` gets freed. Thus, it needs to
2828
/// be manually ensured that the ``SyntaxArena`` is not deallocated while any
29-
/// of its nodes are being accessed. The ``SyntaxData`` type ensures this as
29+
/// of its nodes are being accessed. The `SyntaxData` type ensures this as
3030
/// follows:
3131
/// - The root node has a strong reference to its ``SyntaxArena``
32-
/// - Each node retains its parent ``SyntaxData``, thus keeping it alive.
32+
/// - Each node retains its parent `SyntaxData`, thus keeping it alive.
3333
/// - If any node is allocated within a different ``SyntaxArena``, that arena
3434
/// is added to the root's `childRefs` property and thus kept a live as long
3535
/// as the parent tree is alive.
3636
///
37-
/// As an added benefit of the ``SyntaxArena``, ``RawSyntax`` nodes don’t need to
37+
/// As an added benefit of the ``SyntaxArena``, `RawSyntax` nodes don’t need to
3838
/// be reference-counted, further improving the performance of ``SwiftSyntax``
3939
/// when worked with at that level.
4040
public class SyntaxArena {

Sources/SwiftSyntax/TokenSyntax.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public struct TokenSyntax: SyntaxProtocol, SyntaxHashable {
139139
/// empty layout node.
140140
///
141141
/// Every syntax node that contains a token will have a
142-
/// ``SyntaxNodeStructure.SyntaxChoices.choices`` case for the token and those
142+
/// ``SyntaxNodeStructure/SyntaxChoice/token(_:)`` case for the token and those
143143
/// choices represent the token kinds the token might have.
144144
public static var structure: SyntaxNodeStructure {
145145
return .layout([])

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ public struct EditorPlaceholderDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
15281528
}
15291529
}
15301530

1531-
/// If there were attributes before the editor placeholder, the ``EditorPlaceholderDecl`` will contain these.
1531+
/// If there were attributes before the editor placeholder, the ``EditorPlaceholderDeclSyntax`` will contain these.
15321532
public var attributes: AttributeListSyntax? {
15331533
get {
15341534
return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init)

Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extension ArrayExprSyntax {
4343
extension AttributeSyntax {
4444
/// A convenience initializer that allows passing in arguments using a result builder
4545
/// and automatically adds parentheses as needed, similar to the convenience
46-
/// initializer for ``FunctionCallExpr``.
46+
/// initializer for ``FunctionCallExprSyntax``.
4747
public init(
4848
_ attributeName: TypeSyntax,
4949
@TupleExprElementListBuilder argumentList: () -> TupleExprElementListSyntax? = { nil }

Sources/SwiftSyntaxBuilder/Syntax+StringInterpolation.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ extension SyntaxStringInterpolation: StringInterpolationProtocol {
106106

107107
/// Interpolates a literal or similar expression syntax equivalent to `value`.
108108
///
109-
/// - SeeAlso: ``Expr/init(literal:)``
109+
/// - SeeAlso: ``SwiftSyntax/ExprSyntax/init(literal:)``
110110
public mutating func appendInterpolation(
111111
literal value: some ExpressibleByLiteralSyntax,
112112
format: BasicFormat = BasicFormat()
@@ -118,7 +118,7 @@ extension SyntaxStringInterpolation: StringInterpolationProtocol {
118118
// it silences a warning about interpolating Optionals.
119119
/// Interpolates a literal or similar expression syntax equivalent to `value`.
120120
///
121-
/// - SeeAlso: ``Expr/init(literal:)``
121+
/// - SeeAlso: ``SwiftSyntax/ExprSyntax/init(literal:)``
122122
public mutating func appendInterpolation<Literal: ExpressibleByLiteralSyntax>(
123123
literal value: Literal?,
124124
format: BasicFormat = BasicFormat()
@@ -161,10 +161,10 @@ enum SyntaxStringInterpolationError: Error, CustomStringConvertible {
161161
/// Conforming types do not *contain* Swift source code; rather, they can be
162162
/// *expressed* in Swift source code, and this protocol can be used to get
163163
/// whatever source code would do that. For example, `String` is
164-
/// `ExpressibleByLiteralSyntax` but ``StringLiteralExprSyntax`` is not.
164+
/// `ExpressibleByLiteralSyntax` but ``SwiftSyntax/StringLiteralExprSyntax`` is not.
165165
///
166166
/// This protocol is usually not used directly. Instead, conforming types can
167-
/// be turned into syntax trees using ``Expr/init(literal:)``:
167+
/// be turned into syntax trees using ``SwiftSyntax/ExprSyntax/init(literal:)``:
168168
///
169169
/// let expr2 = Expr(literal: [0+1, 1+1, 2+1])
170170
/// // `expr2` is a syntax tree for `[1, 2, 3]`.
@@ -195,7 +195,7 @@ public protocol ExpressibleByLiteralSyntax {
195195
/// Returns a syntax tree that represents the value of this instance.
196196
///
197197
/// This method is usually not called directly. Instead, conforming types can
198-
/// be turned into syntax trees using ``Expr/init(literal:)``:
198+
/// be turned into syntax trees using ``SwiftSyntax/ExprSyntax/init(literal:)``:
199199
///
200200
/// let expr2 = Expr(literal: [0+1, 1+1, 2+1])
201201
/// // `expr2` is a syntax tree for `[1, 2, 3]`.

0 commit comments

Comments
 (0)