Skip to content

Commit eeabad0

Browse files
authored
Add a bit more public API documentation about the V2 communication protocol for external link resolver processes/executables (#1313)
* Add a bit more public API documentation about the V2 communication protocol for external link resolver processes/executables rdar://161721734 * Add additional public API documentation about the expected `referenceURL` for successful link requests. * Use 3 hyphens instead of em-dashes in in-source doc comments
1 parent f982c41 commit eeabad0

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver+Communication.swift

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extension OutOfProcessReferenceResolver {
3737

3838
// MARK: Request & Response
3939

40-
/// Request messages that DocC sends to the external link resolver.
40+
/// Request messages that DocC sends to the configured external link resolver.
4141
///
4242
/// ## Topics
4343
/// ### Base requests
@@ -49,9 +49,17 @@ extension OutOfProcessReferenceResolver {
4949
public enum RequestV2: Codable {
5050
/// A request to resolve a link
5151
///
52-
/// Your external resolver
52+
/// Your external resolver should respond with either:
53+
/// - a ``ResponseV2/resolved(_:)`` message, with information about the requested link.
54+
/// - a ``ResponseV2/failure(_:)`` message, with human-readable information about the problem that the external link resolver encountered while resolving the link.
5355
case link(String)
5456
/// A request to resolve a symbol based on its precise identifier.
57+
///
58+
/// Your external resolver should respond with either:
59+
/// - a ``ResponseV2/resolved(_:)`` message, with information about the requested symbol.
60+
/// - an empty ``ResponseV2/failure(_:)`` message.
61+
/// DocC doesn't display any diagnostics about failed symbol requests because they wouldn't be actionable;
62+
/// because they're entirely automatic---based on unique identifiers in the symbol graph files---rather than authored references in the content.
5563
case symbol(String)
5664

5765
// This empty-marker case is here because non-frozen enums are only available when Library Evolution is enabled,
@@ -88,20 +96,31 @@ extension OutOfProcessReferenceResolver {
8896
}
8997
}
9098

91-
/// A response message from the external link resolver.
99+
/// Response messages that the external link resolver sends back to DocC for each received request..
92100
///
93101
/// If your external resolver sends a response that's associated with a capability that DocC hasn't declared support for, then DocC will fail to handle the response.
94102
public enum ResponseV2: Codable {
95-
/// The initial identifier and capabilities message.
103+
/// The initial identifier-and-capabilities message.
96104
///
97105
/// Your external link resolver should send this message, exactly once, after it has launched to signal that its ready to receive requests.
98106
///
99107
/// The capabilities that your external link resolver declares in this message determines which optional request messages that DocC will send.
100108
/// If your resolver doesn't declare _any_ capabilities it only needs to handle the 3 default requests. See <doc:RequestV2#Base-requests>.
101109
case identifierAndCapabilities(DocumentationBundle.Identifier, Capabilities)
102-
/// The error message of the problem that the external link resolver encountered while resolving the requested topic or symbol.
110+
/// A response with human-readable information about the problem that the external link resolver encountered while resolving the requested link or symbol.
111+
///
112+
/// - Note: DocC doesn't display any diagnostics about failed ``RequestV2/symbol(_:)`` requests because they wouldn't be actionable;
113+
/// because they're entirely automatic---based on unique identifiers in the symbol graph files---rather than authored references in the content.
114+
///
115+
/// Your external link resolver still needs to send a response to each request but it doesn't need to include details about the failure when responding to a ``RequestV2/symbol(_:)`` request.
103116
case failure(DiagnosticInformation)
104-
/// A response with the resolved information about the requested topic or symbol.
117+
/// A response with the resolved information about the requested link or symbol.
118+
///
119+
/// The ``LinkDestinationSummary/referenceURL`` can have a "path" and "fragment" components that are different from what DocC sent in the ``RequestV2/link(_:)`` request.
120+
/// For example; if your resolver supports different spellings of the link---corresponding to a page's different names in different language representations---you can return the common reference URL identifier for that page for all link spellings.
121+
///
122+
/// - Note: DocC expects the resolved ``LinkDestinationSummary/referenceURL`` to have a "host" component that matches the ``DocumentationBundle/Identifier`` that your resolver provided in its initial ``identifierAndCapabilities(_:_:)`` handshake message.
123+
/// Responding with a ``LinkDestinationSummary/referenceURL`` that doesn't match the resolver's provided ``DocumentationBundle/Identifier`` is undefined behavior.
105124
case resolved(LinkDestinationSummary)
106125

107126
// This empty-marker case is here because non-frozen enums are only available when Library Evolution is enabled,
@@ -159,6 +178,11 @@ extension OutOfProcessReferenceResolver {
159178

160179
extension OutOfProcessReferenceResolver.ResponseV2 {
161180
/// Information about why the external resolver failed to resolve the `link(_:)`, or `symbol(_:)` request.
181+
///
182+
/// - Note: DocC doesn't display any diagnostics about failed ``RequestV2/symbol(_:)`` requests because they wouldn't be actionable;
183+
/// because they're entirely automatic---based on unique identifiers in the symbol graph files---rather than authored references in the content.
184+
///
185+
/// Your external link resolver still needs to send a response to each request but it doesn't need to include details about the failure when responding to a ``RequestV2/symbol(_:)`` request.
162186
public struct DiagnosticInformation: Codable {
163187
/// A brief user-facing summary of the issue that caused the external resolver to fail.
164188
public var summary: String

Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,25 @@ private import Markdown
6060
///
6161
/// ## Topics
6262
///
63+
/// ### Messages
64+
///
65+
/// Requests that DocC sends to your link resolver executable and the responses that it should send back.
66+
///
6367
/// - ``RequestV2``
6468
/// - ``ResponseV2``
6569
///
70+
/// ### Finding common capabilities
71+
///
72+
/// Ways that your link resolver executable can signal any optional capabilities that it supports.
73+
///
74+
/// - ``ResponseV2/identifierAndCapabilities(_:_:)``
75+
/// - ``Capabilities``
76+
///
77+
/// ### Deprecated messages
78+
///
79+
/// - ``Request``
80+
/// - ``Response``
81+
///
6682
/// ## See Also
6783
/// - ``DocumentationContext/externalDocumentationSources``
6884
/// - ``DocumentationContext/globalExternalSymbolResolver``

0 commit comments

Comments
 (0)