Skip to content

Commit fd82527

Browse files
authored
Replace @comment blocks with HTML comments (#50)
This reduces the places where content in the comment causes DocC to silently mis-parse the comment and content after it. The markdown parser for DocC first parses plain markdown syntax, and then identifies places where the `@Comment { }` syntax delimits blocks. That means it tries to parse the content of a comment as markdown first, and then later it gets turned into a comment. The parsing of HTML style comments happens as part of the first stage, which makes it less fragile. Using the DocC syntax for comments, a lot of the issues seem to come from `}` appearing in commented-out in code listings, or from other places where part of the comment is being interpreted as markdown and preventing the later DocC parsing pass from treating that content as a comment, or in some causes causing content after it to be missing. Using the HTML comment syntax, the `-->` arrow used in comment-out formal grammar conflicts with the end-of-comment marker, which I worked around by changing them to a `->` arrow. We can probably delete most or all of the commented-out formal grammar blocks, which seem to date back to the original drafting of the book's grammar. Some of the comment-parsing issues appear to be related to a known issue in Swift-Markdown: swiftlang/swift-markdown#84
2 parents 3201fc1 + 4fef873 commit fd82527

Some content is hidden

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

42 files changed

+3041
-3047
lines changed

Sources/TSPL/TSPL.docc/GuidedTour/AboutSwift.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ Our goals for Swift are ambitious.
5151
We can’t wait to see what you create with it.
5252

5353

54-
@Comment {
54+
<!--
5555
This source file is part of the Swift.org open source project
5656
5757
Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
5858
Licensed under Apache License v2.0 with Runtime Library Exception
5959
6060
See https://swift.org/LICENSE.txt for license information
6161
See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
62-
}
62+
-->

Sources/TSPL/TSPL.docc/GuidedTour/Compatibility.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ the default version of Swift that's included in Xcode 14.
99
You can use Xcode 14 to build targets
1010
that are written in either Swift 5.7, Swift 4.2, or Swift 4.
1111

12-
@Comment {
12+
<!--
1313
- test: `swift-version`
1414
1515
```swifttest
@@ -22,7 +22,7 @@ that are written in either Swift 5.7, Swift 4.2, or Swift 4.
2222
>> #endif
2323
<< Just right
2424
```
25-
}
25+
-->
2626

2727
When you use Xcode 14 to build Swift 4 and Swift 4.2 code,
2828
most Swift 5.7 functionality is available.
@@ -52,12 +52,12 @@ you can migrate your code from Swift 4 to Swift 5.7
5252
one framework at a time.
5353

5454

55-
@Comment {
55+
<!--
5656
This source file is part of the Swift.org open source project
5757
5858
Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
5959
Licensed under Apache License v2.0 with Runtime Library Exception
6060
6161
See https://swift.org/LICENSE.txt for license information
6262
See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
63-
}
63+
-->

0 commit comments

Comments
 (0)