@@ -19,14 +19,18 @@ extension SymbolGraph.Symbol {
19
19
let identifier = SymbolGraph . Symbol. Identifier ( precise: " $snippet__ \( moduleName) . \( basename) " , interfaceLanguage: " swift " )
20
20
let names = SymbolGraph . Symbol. Names. init ( title: basename, navigator: nil , subHeading: nil , prose: nil )
21
21
22
- var pathComponents = snippet. sourceFile. absoluteURL. deletingPathExtension ( ) . pathComponents [ ... ]
22
+ var pathComponents = Array ( snippet. sourceFile. absoluteURL. deletingPathExtension ( ) . pathComponents [ ... ] )
23
23
24
24
guard let snippetsPathComponentIndex = pathComponents. firstIndex ( where: {
25
25
$0 == " Snippets "
26
26
} ) else {
27
27
throw SnippetExtractCommand . ArgumentError. snippetNotContainedInSnippetsDirectory ( snippet. sourceFile)
28
28
}
29
- pathComponents = pathComponents [ snippetsPathComponentIndex... ]
29
+
30
+ // In theory, there may be differently named snippet root directories in the future.
31
+ // Replace that path component with the standardized `Snippets`.
32
+ pathComponents. replaceSubrange ( pathComponents. startIndex... snippetsPathComponentIndex,
33
+ with: CollectionOfOne ( " Snippets " ) )
30
34
31
35
let docComment = SymbolGraph . LineList ( snippet. explanation
32
36
. split ( separator: " \n " , maxSplits: Int . max, omittingEmptySubsequences: false )
@@ -39,7 +43,7 @@ extension SymbolGraph.Symbol {
39
43
40
44
self . init ( identifier: identifier,
41
45
names: names,
42
- pathComponents: [ " Snippets " ] + Array ( pathComponents) ,
46
+ pathComponents: pathComponents,
43
47
docComment: docComment,
44
48
accessLevel: accessLevel,
45
49
kind: kind,
0 commit comments