Skip to content

Commit 22a36b8

Browse files
authored
Fix broken and old links (#176)
2 parents 5f16124 + 69e4698 commit 22a36b8

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

TSPL.docc/LanguageGuide/Macros.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func myFunction() {
5353
```
5454

5555
In the first line,
56-
`#function` calls the [`function`][] macro from the Swift standard library.
56+
`#function` calls the [`function()`][] macro from the Swift standard library.
5757
When you compile this code,
5858
Swift calls that macro's implementation,
5959
which replaces `#function` with the name of the current function.
@@ -63,7 +63,7 @@ In the second line,
6363
`#warning` calls the [`warning(_:)`][] macro from the Swift standard library
6464
to produce a custom compile-time warning.
6565

66-
[`function`]: https://developer.apple.com/documentation/swift/function
66+
[`function()`]: https://developer.apple.com/documentation/swift/function()
6767
[`warning(_:)`]: https://developer.apple.com/documentation/swift/warning(_:)
6868

6969
Freestanding macros can produce a value, like `#function` does,
@@ -117,8 +117,15 @@ The macro reads the list of cases in the private enumeration,
117117
generates the list of constants for each option,
118118
and adds a conformance to the [`OptionSet`][] protocol.
119119

120+
[`OptionSet`]: https://developer.apple.com/documentation/swift/optionset
121+
122+
<!--
123+
When the @OptionSet macro comes back, change both links back:
124+
120125
[`@OptionSet`]: https://developer.apple.com/documentation/swift/optionset-swift.macro
121126
[`OptionSet`]: https://developer.apple.com/documentation/swift/optionset-swift.protocol
127+
-->
128+
122129

123130
For comparison,
124131
here's what the expanded version of the `@OptionSet` macro looks like.

TSPL.docc/ReferenceManual/Expressions.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,13 @@ or a playground literal.
583583
> `#function`,
584584
> and `#line`.
585585
> These are now implemented as macros in the Swift standard library:
586-
> [`column`](https://developer.apple.com/documentation/swift/column()),
587-
> [`dsohandle`](https://developer.apple.com/documentation/swift/dsohandle()),
588-
> [`fileID`](https://developer.apple.com/documentation/swift/fileID()),
589-
> [`filePath`](https://developer.apple.com/documentation/swift/filePath()),
590-
> [`file`](https://developer.apple.com/documentation/swift/file()),
591-
> [`function`](https://developer.apple.com/documentation/swift/function()),
592-
> and [`line`](https://developer.apple.com/documentation/swift/line()).
586+
> [`column()`](https://developer.apple.com/documentation/swift/column()),
587+
> [`dsohandle()`](https://developer.apple.com/documentation/swift/dsohandle()),
588+
> [`fileID()`](https://developer.apple.com/documentation/swift/fileID()),
589+
> [`filePath()`](https://developer.apple.com/documentation/swift/filePath()),
590+
> [`file()`](https://developer.apple.com/documentation/swift/file()),
591+
> [`function()`](https://developer.apple.com/documentation/swift/function()),
592+
> and [`line()`](https://developer.apple.com/documentation/swift/line()).
593593
594594
<!--
595595
- test: `pound-file-flavors`
@@ -1518,13 +1518,13 @@ A macro-expansion expression omits the parentheses
15181518
if the macro doesn't take any arguments.
15191519

15201520
A macro expression can't appear as the default value for a parameter,
1521-
except for the [`file`][] and [`line`][] macros from the Swift standard library.
1521+
except for the [`file()`][] and [`line()`][] macros from the Swift standard library.
15221522
When used as the default value of a function or method parameter,
15231523
These macros' value is determined
15241524
when the default value expression is evaluated at the call site.
15251525

1526-
[`file`]: http://developer.apple.com/documentation/swift/documentation/swift/file
1527-
[`line`]: http://developer.apple.com/documentation/swift/documentation/swift/line
1526+
[`file()`]: https://developer.apple.com/documentation/swift/file()
1527+
[`line()`]: https://developer.apple.com/documentation/swift/line()
15281528

15291529
> Grammar of a macro-expansion expression:
15301530
>

bin/preflight

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,19 @@ then
3939
exit_status=1
4040
fi
4141

42+
echo "Checking links..."
43+
cmark --to xml TSPL.docc/*/*.md |
44+
xpath -q -n -e '//link/@destination' |
45+
sort -u | cut -f2 -d= | grep -v '^"doc:' | sed 's/^"//; s/"$//' |
46+
while read url
47+
do
48+
if curl --silent --output /dev/null --fail --head $url
49+
then
50+
echo " $url"
51+
else
52+
echo "BAD: $url"
53+
exit_status=1
54+
fi
55+
done
56+
4257
exit $exit_status

0 commit comments

Comments
 (0)