Skip to content

Commit ced4877

Browse files
committed
co-locates snippet API ref content to source class rather than using an extension page
1 parent 6d54a00 commit ced4877

File tree

3 files changed

+73
-20
lines changed

3 files changed

+73
-20
lines changed

Sources/SwiftDocC/Semantics/Snippets/Snippet.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ import Foundation
1212
public import Markdown
1313
import SymbolKit
1414

15+
// NOTE: If you update the DocC content, remember to run
16+
// `swift run generate-symbol-graph` to regenerate the DocC
17+
// symbol content for the DocC Documentation.
18+
19+
/// Embeds a code example from the project's code snippets.
20+
///
21+
/// ```markdown
22+
/// @Snippet(path: "my-package/Snippets/example-snippet", slice: "setup")
23+
/// ```
24+
///
25+
/// Place the `Snippet` directive to embed a code example from the project's snippet directory.
26+
/// The path that references the snippet is identified with three parts:
27+
///
28+
/// 1. The package name as defined in `Package.swift`
29+
///
30+
/// 2. The directory path to the snippet file, starting with "Snippets".
31+
///
32+
/// 3. The name of your snippet file without the `.swift` extension
33+
///
34+
/// If the snippet had slices annotated within it, an individual slice of the snippet can be referenced with the `slice` option.
35+
/// Without the option defined, the directive embeds the entire snippet.
1536
public final class Snippet: Semantic, AutomaticDirectiveConvertible {
1637
public static let introducedVersion = "5.7"
1738
public let originalMarkup: BlockDirective

Sources/docc/DocCDocumentation.docc/DocC.symbols.json

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5253,7 +5253,7 @@
52535253
"domain" : "Swift-DocC",
52545254
"introduced" : {
52555255
"major" : 5,
5256-
"minor" : 6,
5256+
"minor" : 7,
52575257
"patch" : 0
52585258
}
52595259
}
@@ -5310,6 +5310,57 @@
53105310
],
53115311
"docComment" : {
53125312
"lines" : [
5313+
{
5314+
"text" : "Embeds a code example from the project's code snippets."
5315+
},
5316+
{
5317+
"text" : ""
5318+
},
5319+
{
5320+
"text" : "```markdown"
5321+
},
5322+
{
5323+
"text" : "@Snippet(path: \"my-package\/Snippets\/example-snippet\", slice: \"setup\")"
5324+
},
5325+
{
5326+
"text" : "```"
5327+
},
5328+
{
5329+
"text" : ""
5330+
},
5331+
{
5332+
"text" : "Place the `Snippet` directive to embed a code example from the project's snippet directory."
5333+
},
5334+
{
5335+
"text" : "The path that references the snippet is identified with three parts:"
5336+
},
5337+
{
5338+
"text" : ""
5339+
},
5340+
{
5341+
"text" : "1. The package name as defined in `Package.swift`"
5342+
},
5343+
{
5344+
"text" : ""
5345+
},
5346+
{
5347+
"text" : "2. The directory path to the snippet file, starting with \"Snippets\"."
5348+
},
5349+
{
5350+
"text" : ""
5351+
},
5352+
{
5353+
"text" : "3. The name of your snippet file without the `.swift` extension"
5354+
},
5355+
{
5356+
"text" : ""
5357+
},
5358+
{
5359+
"text" : "If the snippet had slices annotated within it, an individual slice of the snippet can be referenced with the `slice` option."
5360+
},
5361+
{
5362+
"text" : "Without the option defined, the directive embeds the entire snippet."
5363+
},
53135364
{
53145365
"text" : "- Parameters:"
53155366
},

Sources/docc/DocCDocumentation.docc/Reference Syntax/API Reference Syntax/Snippet.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)