Skip to content

Commit 4f161b0

Browse files
authored
Specify code listings are Swift (#333)
Because the Info.plist file specifies Swift as the default language via the CDDefaultCodeListingLanguage key, code listings with an unspecified language should still render correctly. However, it's still good to be explicit and makes the markdown files more usable by other toolchains. Used the following script to find code listings that were missing an explicit language, and to verify that none remain after this change: ``` echo "Not specified as Swift" cmark --to xml TSPL.docc/*/*.md | xpath -q -n -e '//code_block[not(@info="swift")]' echo "Languages used" cmark --to xml TSPL.docc/*/*.md | xpath -q -n -e '//code_block/@info' | sort -u ```
2 parents 9adac21 + 2e4f677 commit 4f161b0

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

TSPL.docc/LanguageGuide/Concurrency.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ For a task group that returns a result,
630630
you add code that accumulates its result
631631
inside the closure you pass to `withTaskGroup(of:returning:body:)`.
632632

633-
```
633+
```swift
634634
let photos = await withTaskGroup(of: Data.self) { group in
635635
let photoNames = await listPhotos(inGallery: "Summer Vacation")
636636
for name in photoNames {
@@ -708,7 +708,7 @@ like closing network connections and deleting temporary files.
708708
[`Task.checkCancellation()`]: https://developer.apple.com/documentation/swift/task/3814826-checkcancellation
709709
[`Task.isCancelled` type]: https://developer.apple.com/documentation/swift/task/iscancelled-swift.type.property
710710

711-
```
711+
```swift
712712
let photos = await withTaskGroup(of: Optional<Data>.self) { group in
713713
let photoNames = await listPhotos(inGallery: "Summer Vacation")
714714
for name in photoNames {

TSPL.docc/LanguageGuide/Macros.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ to add conformance to the `OptionSet` protocol.
240240
For a freestanding macro,
241241
you write the `@freestanding` attribute to specify its role:
242242

243-
```
243+
```swift
244244
@freestanding(expression)
245245
public macro line<T: ExpressibleByIntegerLiteral>() -> T =
246246
/* ... location of the macro implementation... */
@@ -317,7 +317,7 @@ Specifically, Swift expands macros in the following way:
317317

318318
To go through the specific steps, consider the following:
319319

320-
```
320+
```swift
321321
let magicNumber = #fourCharacterCode("ABCD")
322322
```
323323

@@ -413,7 +413,7 @@ That produces a final AST that can be compiled as usual:
413413

414414
This AST corresponds to Swift code like this:
415415

416-
```
416+
```swift
417417
let magicNumber = 1145258561 as UInt32
418418
```
419419

TSPL.docc/ReferenceManual/Expressions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ However, when a default value is a larger expression
15281528
that contains a macro in addition to other code,
15291529
those macros are evaluated where they appear in the function definition.
15301530

1531-
```
1531+
```swift
15321532
func f(a: Int = #line, b: Int = (#line), c: Int = 100 + #line) {
15331533
print(a, b, c)
15341534
}

0 commit comments

Comments
 (0)