File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Sources/docc/DocCDocumentation.docc Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff 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
144144documentation.
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+
146164DocC uses the programming language you specify to apply the correct syntax
147165color formatting. For the example above, DocC generates the following:
148166
You can’t perform that action at this time.
0 commit comments