Skip to content

Commit 3e604f5

Browse files
Expand documentation for new layout directives
Includes a fix for generate-symbol-graph doc comment fetching for directives implemented by a class with a different name. rdar://108207445
1 parent ea45032 commit 3e604f5

File tree

8 files changed

+256
-9
lines changed

8 files changed

+256
-9
lines changed

Sources/SwiftDocC/Semantics/DirectiveInfrastructure/DirectiveIndex.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,12 @@ struct DirectiveIndex {
104104
// is not in the pre-populated index.
105105
return indexedDirectives[directiveConvertible.directiveName]!
106106
}
107+
108+
func reflection(of implementationName: String) -> DirectiveMirror.ReflectedDirective? {
109+
return indexedDirectives.first(
110+
where: { (directiveName: String, reflectedDirective: DirectiveMirror.ReflectedDirective) in
111+
directiveName == implementationName || String(describing: reflectedDirective.type) == implementationName
112+
}
113+
)?.value
114+
}
107115
}

Sources/SwiftDocC/Semantics/Metadata/PageImage.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,28 @@
1111
import Foundation
1212
import Markdown
1313

14+
/// Associates an image with a page.
15+
///
16+
/// You can use this directive to set the image used when rendering a user-interface element representing the page.
17+
/// For example, use the page image directive to customize the icon used to represent this page in the navigation sidebar,
18+
/// or the card image used to represent this page when using the ``Links`` directive and the ``Links/detailedGrid``
19+
/// visual style.
1420
public final class PageImage: Semantic, AutomaticDirectiveConvertible {
1521
public let originalMarkup: BlockDirective
1622

23+
/// The image's purpose.
1724
@DirectiveArgumentWrapped
1825
public private(set) var purpose: Purpose
1926

27+
/// The base file name of an image in your documentation catalog.
2028
@DirectiveArgumentWrapped(
2129
parseArgument: { bundle, argumentValue in
2230
ResourceReference(bundleIdentifier: bundle.identifier, path: argumentValue)
2331
}
2432
)
2533
public private(set) var source: ResourceReference
2634

35+
/// Alternative text that describes the image to screen readers.
2736
@DirectiveArgumentWrapped
2837
public private(set) var alt: String? = nil
2938

@@ -33,10 +42,12 @@ public final class PageImage: Semantic, AutomaticDirectiveConvertible {
3342
"alt" : \PageImage._alt,
3443
]
3544

36-
/// The style of the display name for this symbol.
45+
/// The name of the display style for this image.
3746
public enum Purpose: String, CaseIterable, DirectiveArgumentValueConvertible {
47+
/// The image will be used when representing the page as an icon, such as in the navigation sidebar.
3848
case icon
3949

50+
/// The image will be used when representing the page as a card, such as in grid styled Topics sections.
4051
case card
4152
}
4253

Sources/SwiftDocC/Semantics/Options/AutomaticTitleHeading.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class AutomaticTitleHeading: Semantic, AutomaticDirectiveConvertible {
2525
@DirectiveArgumentWrapped(name: .unnamed)
2626
public private(set) var enabledness: Enabledness
2727

28-
/// A value that represent whether automatic title heading generation is enabled or disabled.
28+
/// A value that represents whether automatic title heading generation is enabled or disabled.
2929
public enum Enabledness: String, CaseIterable, DirectiveArgumentValueConvertible {
3030
/// A title heading should be automatically created for the page (the default).
3131
case enabled

Sources/SwiftDocC/Semantics/Options/Options.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import Foundation
1212
import Markdown
1313

14-
/// Use Option directives to adjust DocC's default behaviors when rendering a page.
14+
/// A directive to adjust Swift-DocC's default behaviors when rendering a page.
1515
///
1616
/// ## Topics
1717
///

Sources/SwiftDocC/Semantics/Reference/Row.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import Markdown
5050
public final class Row: Semantic, AutomaticDirectiveConvertible, MarkupContaining {
5151
public let originalMarkup: BlockDirective
5252

53+
/// The number of columns available in this row.
5354
@DirectiveArgumentWrapped(name: .custom("numberOfColumns"))
5455
public private(set) var _numberOfColumns: Int? = nil
5556

@@ -89,6 +90,8 @@ public final class Row: Semantic, AutomaticDirectiveConvertible, MarkupContainin
8990
extension Row {
9091
/// A container directive that holds general markup content describing a column
9192
/// with a row in a grid-based layout.
93+
///
94+
/// Create a column inside a ``Row`` by nesting a `@Column` directive within the content for an `@Row` directive.
9295
public final class Column: Semantic, AutomaticDirectiveConvertible, MarkupContaining {
9396
public let originalMarkup: BlockDirective
9497

Sources/SwiftDocC/Semantics/Reference/TabNavigator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public final class TabNavigator: Semantic, AutomaticDirectiveConvertible, Markup
6161
extension TabNavigator {
6262
/// A container directive that holds general markup content describing an individual
6363
/// tab within a tab-based layout.
64+
///
65+
/// To add a new tab to a ``TabNavigator``, add a `@Tab` directive within the content of the `@TabNavigator` directive.
6466
public final class Tab: Semantic, AutomaticDirectiveConvertible, MarkupContaining {
6567
public let originalMarkup: BlockDirective
6668

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

Lines changed: 225 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,118 @@
600600
"spelling" : ")"
601601
}
602602
],
603+
"docComment" : {
604+
"lines" : [
605+
{
606+
"text" : "A directive that sets the platform availability information for a documentation page."
607+
},
608+
{
609+
"text" : ""
610+
},
611+
{
612+
"text" : "`@Available` is analagous to the `@available` attribute in Swift: It allows you to specify a"
613+
},
614+
{
615+
"text" : "platform version that the page relates to. To specify a platform and version, list the platform"
616+
},
617+
{
618+
"text" : "name and use the `introduced` argument:"
619+
},
620+
{
621+
"text" : ""
622+
},
623+
{
624+
"text" : "```markdown"
625+
},
626+
{
627+
"text" : "@Available(macOS, introduced: \"12.0\")"
628+
},
629+
{
630+
"text" : "```"
631+
},
632+
{
633+
"text" : ""
634+
},
635+
{
636+
"text" : "Any text can be given to the first argument, and will be displayed in the page's"
637+
},
638+
{
639+
"text" : "availability data. The platforms `iOS`, `macOS`, `watchOS`, and `tvOS` will be matched"
640+
},
641+
{
642+
"text" : "case-insensitively, but anything else will be printed verbatim."
643+
},
644+
{
645+
"text" : ""
646+
},
647+
{
648+
"text" : "To provide a platform name with spaces in it, provide it as a quoted string:"
649+
},
650+
{
651+
"text" : ""
652+
},
653+
{
654+
"text" : "```markdown"
655+
},
656+
{
657+
"text" : "@Available(\"My Package\", introduced: \"1.0\")"
658+
},
659+
{
660+
"text" : "```"
661+
},
662+
{
663+
"text" : ""
664+
},
665+
{
666+
"text" : "This directive is available on both articles and documentation extension files. In extension"
667+
},
668+
{
669+
"text" : "files, the information overrides any information from the symbol itself."
670+
},
671+
{
672+
"text" : ""
673+
},
674+
{
675+
"text" : "This directive is only valid within a ``Metadata`` directive:"
676+
},
677+
{
678+
"text" : ""
679+
},
680+
{
681+
"text" : "```markdown"
682+
},
683+
{
684+
"text" : "@Metadata {"
685+
},
686+
{
687+
"text" : " @Available(macOS, introduced: \"12.0\")"
688+
},
689+
{
690+
"text" : " @Available(iOS, introduced: \"15.0\")"
691+
},
692+
{
693+
"text" : "}"
694+
},
695+
{
696+
"text" : "```"
697+
},
698+
{
699+
"text" : "- Parameters:"
700+
},
701+
{
702+
"text" : " - platform: The platform that this argument's information applies to."
703+
},
704+
{
705+
"text" : " **(required)**"
706+
},
707+
{
708+
"text" : " - introduced: The platform version that this page applies to."
709+
},
710+
{
711+
"text" : " **(required)**"
712+
}
713+
]
714+
},
603715
"identifier" : {
604716
"interfaceLanguage" : "swift",
605717
"precise" : "__docc_universal_symbol_reference_$Available"
@@ -1492,6 +1604,12 @@
14921604
{
14931605
"text" : "with a row in a grid-based layout."
14941606
},
1607+
{
1608+
"text" : ""
1609+
},
1610+
{
1611+
"text" : "Create a column inside a ``Row`` by nesting a `@Column` directive within the content for an `@Row` directive."
1612+
},
14951613
{
14961614
"text" : "- Parameters:"
14971615
},
@@ -2262,6 +2380,28 @@
22622380
"spelling" : " {\n ...\n}"
22632381
}
22642382
],
2383+
"docComment" : {
2384+
"lines" : [
2385+
{
2386+
"text" : "A block filled with an image."
2387+
},
2388+
{
2389+
"text" : "- Parameters:"
2390+
},
2391+
{
2392+
"text" : " - source: A reference to the source file for the media item."
2393+
},
2394+
{
2395+
"text" : " **(required)**"
2396+
},
2397+
{
2398+
"text" : " - alt: Optional alternate text for an image."
2399+
},
2400+
{
2401+
"text" : " **(optional)**"
2402+
}
2403+
]
2404+
},
22652405
"identifier" : {
22662406
"interfaceLanguage" : "swift",
22672407
"precise" : "__docc_universal_symbol_reference_$Image"
@@ -2957,7 +3097,7 @@
29573097
"docComment" : {
29583098
"lines" : [
29593099
{
2960-
"text" : "Use Option directives to adjust DocC's default behaviors when rendering a page."
3100+
"text" : "A directive to adjust Swift-DocC's default behaviors when rendering a page."
29613101
},
29623102
{
29633103
"text" : ""
@@ -3320,6 +3460,55 @@
33203460
"spelling" : ")"
33213461
}
33223462
],
3463+
"docComment" : {
3464+
"lines" : [
3465+
{
3466+
"text" : "Associates an image with a page."
3467+
},
3468+
{
3469+
"text" : ""
3470+
},
3471+
{
3472+
"text" : "You can use this directive to set the image used when rendering a user-interface element representing the page."
3473+
},
3474+
{
3475+
"text" : "For example, use the page image directive to customize the icon used to represent this page in the navigation sidebar,"
3476+
},
3477+
{
3478+
"text" : "or the card image used to represent this page when using the ``Links`` directive and the ``Links\/detailedGrid``"
3479+
},
3480+
{
3481+
"text" : "visual style."
3482+
},
3483+
{
3484+
"text" : "- Parameters:"
3485+
},
3486+
{
3487+
"text" : " - purpose: The image's purpose."
3488+
},
3489+
{
3490+
"text" : " **(required)**"
3491+
},
3492+
{
3493+
"text" : " - term `icon`: The image will be used when representing the page as an icon, such as in the navigation sidebar."
3494+
},
3495+
{
3496+
"text" : " - term `card`: The image will be used when representing the page as a card, such as in grid styled Topics sections."
3497+
},
3498+
{
3499+
"text" : " - source: The base file name of an image in your documentation catalog."
3500+
},
3501+
{
3502+
"text" : " **(required)**"
3503+
},
3504+
{
3505+
"text" : " - alt: Alternative text that describes the image to screen readers."
3506+
},
3507+
{
3508+
"text" : " **(optional)**"
3509+
}
3510+
]
3511+
},
33233512
"identifier" : {
33243513
"interfaceLanguage" : "swift",
33253514
"precise" : "__docc_universal_symbol_reference_$PageImage"
@@ -3814,7 +4003,7 @@
38144003
"text" : "- Parameters:"
38154004
},
38164005
{
3817-
"text" : " - numberOfColumns: The number of columns in this row."
4006+
"text" : " - numberOfColumns: The number of columns available in this row."
38184007
},
38194008
{
38204009
"text" : " **(optional)**"
@@ -4536,6 +4725,12 @@
45364725
{
45374726
"text" : "tab within a tab-based layout."
45384727
},
4728+
{
4729+
"text" : ""
4730+
},
4731+
{
4732+
"text" : " To add a new tab to a ``TabNavigator``, add a `@Tab` directive within the content of the `@TabNavigator` directive."
4733+
},
45394734
{
45404735
"text" : "- Parameters:"
45414736
},
@@ -5469,6 +5664,34 @@
54695664
"spelling" : " {\n ...\n}"
54705665
}
54715666
],
5667+
"docComment" : {
5668+
"lines" : [
5669+
{
5670+
"text" : "A block filled with a video."
5671+
},
5672+
{
5673+
"text" : "- Parameters:"
5674+
},
5675+
{
5676+
"text" : " - source: A reference to the source file for the media item."
5677+
},
5678+
{
5679+
"text" : " **(required)**"
5680+
},
5681+
{
5682+
"text" : " - alt: Alternate text describing the video."
5683+
},
5684+
{
5685+
"text" : " **(optional)**"
5686+
},
5687+
{
5688+
"text" : " - poster: An image to be shown when the video isn't playing."
5689+
},
5690+
{
5691+
"text" : " **(optional)**"
5692+
}
5693+
]
5694+
},
54725695
"identifier" : {
54735696
"interfaceLanguage" : "swift",
54745697
"precise" : "__docc_universal_symbol_reference_$Video"

0 commit comments

Comments
 (0)