You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support linking to authored task groups / topic sections (#842)
* Support linking to topic sections
rdar://78908451
* Fix typo in test data
* Document how to link to headings and task groups
* Add comment about preserving order of anchor sections
Copy file name to clipboardExpand all lines: Sources/docc/DocCDocumentation.docc/linking-to-symbols-and-other-content.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,6 +173,13 @@ a colon (`:`), the name of the article, and a greater-than symbol
173
173
<doc:GettingStarted>
174
174
```
175
175
176
+
If the article's file name contains whitespace characters, replace each consecutive sequence of whitespace characters with a dash.
177
+
For example, the link to an article with a file name "Getting Started.md" is
178
+
179
+
```
180
+
<doc:Getting-Started>
181
+
```
182
+
176
183
When DocC resolves the link, it uses the article's page title as the link's
177
184
text, and the article's filename as the link's URL. Links to tutorials follow
178
185
the same format, except you must add the `/tutorials/` prefix to the path:
@@ -186,6 +193,41 @@ symbol's path between the colon (`:`) and the terminating greater-than
186
193
symbol (`>`).
187
194
`<doc:Sloth/init(name:color:power:)>`
188
195
196
+
### Navigate to a Heading or Task Group
197
+
198
+
To add a link to heading or task group on another page, use a `<doc:>` link to the page and end the link with a hash (`#`) followed by the name of the heading.
199
+
If the heading text contains whitespace or punctuation characters, replace each consecutive sequence of whitespace characters with a dash and optionally remove the punctuation characters.
200
+
201
+
For example, consider this level 3 heading with a handful of punctuation characters:
202
+
203
+
```
204
+
### (1) "Example": Sloth's diet.
205
+
```
206
+
207
+
A link to this heading can either include all the punctuation characters from the heading text or remove some or all of the punctuation characters.
208
+
209
+
```
210
+
<doc:OtherPage#(1)-"Example":-Sloth's-diet.>
211
+
<doc:OtherPage#1-Example-Sloths-diet>
212
+
```
213
+
214
+
> Note:
215
+
> Links to headings or task groups on symbol pages use `<doc:>` syntax.
216
+
217
+
To add a link to heading or task group on the current page, use a `<doc:>` link that starts with the name of the heading. If you prefer you can include the hash (`#`) prefix before the heading name. For example, both these links resolve to a heading named "Some heading title" on the current page:
218
+
219
+
```
220
+
<doc:#Some-heading-title>
221
+
<doc:Some-heading-title>
222
+
```
223
+
224
+
If a task group is empty or none of its links resolve successfully, it's not possible to link to that task group because it will be omitted from the rendered page. Linking to generated per-symbol-kind task groups is not supported.
225
+
226
+
> Earlier Versions:
227
+
> Before Swift-DocC 6.0, links to task groups isn't supported. The syntax above only works for links to general headings.
228
+
>
229
+
> Before Swift-DocC 5.9, links to same-page headings don't support a leading hash (`#`) character.
230
+
189
231
### Include web links
190
232
191
233
To include a regular web link, add a set of brackets (`[]`) and
0 commit comments