Skip to content

Commit bb50fb9

Browse files
author
Jesse Haigh
committed
update docs
1 parent 08bd353 commit bb50fb9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Sources/docc/DocCDocumentation.docc/formatting-your-documentation-content.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,24 @@ add a new line and terminate the code listing by adding another three backticks:
143143
instead of tabs so that DocC preserves the indentation when compiling your
144144
documentation.
145145

146+
#### Formatting Code Listings
147+
148+
You can add a copy-to-clipboard button to a code listing by including the copy
149+
option after the name of the programming language for the code listing:
150+
151+
```swift, copy
152+
struct Sightseeing: Activity {
153+
func perform(with sloth: inout Sloth) -> Speed {
154+
sloth.energyLevel -= 10
155+
return .slow
156+
}
157+
}
158+
```
159+
160+
This renders a copy button in the top-right cotner of the code listing in
161+
generated documentation. When clicked, it copies the contents of the code
162+
block to the clipboard.
163+
146164
DocC uses the programming language you specify to apply the correct syntax
147165
color formatting. For the example above, DocC generates the following:
148166

0 commit comments

Comments
 (0)