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:
143
143
instead of tabs so that DocC preserves the indentation when compiling your
144
144
documentation.
145
145
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
+
146
164
DocC uses the programming language you specify to apply the correct syntax
147
165
color formatting. For the example above, DocC generates the following:
148
166
You can’t perform that action at this time.
0 commit comments