I have a few sections in my content where I have a repeated example that I use to illustrate how to use a few methods in my library together - is there a way to move this into an external snippet and include it inline within existing content?
DocC supports standard Markdown code voice (``) and fenced code blocks (```...```). Please submit feedback with a description of your use case on the Feedback Assistant website.
To avoid having to copy and paste the same snippet in multiple places, though, one workaround is to place your snippet in the doc comments of one type, and then use DocC's link support to link from multiple comments to the type containing your snippet.
/// This is my function.
///
/// Typical usage of this function looks like this:
///
/// ```
/// ...illustrative snippet
/// ```
func myFunc() { /*...*/ }
/// This is another function.
///
/// This is typically used with ``myFunc()``.
func anotherFunc() { /*...*/ }
The double backticks around the text "myFunc()" in the second doc comment will become a link back to myFunc, providing readers an easy way to navigate to the docs that contain the snippet.