Commit f0a3e95
authored
Populate abbreviated declaration fragments in external render nodes (#1255)
* Clarify doc comment for `OutOfProcessReferenceResolver.declarationFragments`
These declaration fragments are directly used to populate `TopicRenderReference.fragmentsVariants` [1], which is described as "The abbreviated declaration of the symbol to display in links" [2].
This change clarifies that the declaration fragments are expected to be the abbreviated declaration fragments.
[1]: https://github.com/swiftlang/swift-docc/blob/65aaf926ec079ddbd40f29540d4180a70af99e5e/Sources/SwiftDocC/Infrastructure/External%20Data/OutOfProcessReferenceResolver.swift#L169
[2]: https://github.com/swiftlang/swift-docc/blob/65aaf926ec079ddbd40f29540d4180a70af99e5e/Sources/SwiftDocC/Model/Rendering/References/TopicRenderReference.swift#L50-L53
* Add full (symbol) name to LinkDestinationSummary
The only use-case for storing the full declaration fragments in `LinkDestinationSummary` rather than the shortened declaration fragments intended for display, is to derive the full name of the symbol in diagnostics [1] [2]. We have a number of tests [3] which verify that the diagnostic emitted when a symbol is referenced locally is the same as when the symbol is referenced externally.
However, we want to stop storing the full declaration fragments in favour of the shortened ones because:
- the full fragments are never displayed when referenced externally, as they are too long
- the full fragments take up additionally storage space, and encoding/decoding time, to only be used to derive the full name of the symbol
This commit updates the logic such that, we pre-derive the full name of the symbol from its declaration fragments, and then store that as part of `LinkDestinationSummary`, so that in a subsequent commit we can stop storing the full declaration fragments and store only the shortened ones instead.
The diagnostic logic has also been updated to use the new field rather than the full declaration fragments.
[1]: https://github.com/swiftlang/swift-docc/blob/1b4a1850dd2785a8ebabded139ae0af3551bb029/Sources/SwiftDocC/Infrastructure/Link%20Resolution/ExternalPathHierarchyResolver.swift#L61-L63
[2]: https://github.com/swiftlang/swift-docc/blob/1b4a1850dd2785a8ebabded139ae0af3551bb029/Sources/SwiftDocC/Infrastructure/Link%20Resolution/PathHierarchy%2BError.swift#L115-L117
[3]: https://github.com/swiftlang/swift-docc/blob/9413c599817abc9dd4f8feeed57a998b19a05a6f/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift#L907-L918
* Use the abbreviated declaration fragments in LinkDestinationSummary
LinkDestinationSummary contains a summary of an element that you can link to from outside the documentation bundle. [1]
This information is meant to be used by a server to provide information to an out-of-process resolver to resolve links to external entities, so that the partner implementation of `LinkDestinationSummary` is `OutOfProcessReferenceResolver.ResolvedInformation` [2].
However, currently `OutOfProcessReferenceResolver.ResolvedInformation. declarationFragments` is expecting the abbreviated declaration fragments, but we are storing the full fragments instead. [3]
Instead, we should be storing the abbreviated declaration fragments, which are stored as the `subHeading` of the symbol. [4] This subheading is further processed during the render node transformation phase [5], and stored as `renderNode.metadata.fragmentsVariants`.
This commit modifies `LinkDestinationSummary` such that its declaration fragments are the abbreviated declaration fragments from `renderNode.metadata.fragmentsVariants` rather than the full declaration fragments.
The final result will be that declaration fragments for external links will behave the same as local links when referencing them in the Topics section. They will both now use the abbreviated declaration fragments.
[1]: https://github.com/swiftlang/swift-docc/blob/65aaf926ec079ddbd40f29540d4180a70af99e5e/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift#L66
[2]: https://github.com/swiftlang/swift-docc/blob/65aaf926ec079ddbd40f29540d4180a70af99e5e/Sources/SwiftDocC/Infrastructure/External%20Data/OutOfProcessReferenceResolver.swift#L558-L562
[3]: https://github.com/swiftlang/swift-docc/blob/65aaf926ec079ddbd40f29540d4180a70af99e5e/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift#L445
[4]: https://github.com/swiftlang/swift-docc-symbolkit/blob/ebe89c7da4cf03ded04cd708f3399087c6f2dad7/Sources/SymbolKit/SymbolGraph/Symbol/Names.swift#L28-L31
* Populate declaration fragments in navigator metadata for external links
Now that the declaration fragments will be the abbreviated declaration fragments from `LinkDestinationSummary`, we can propagate those to the navigator metadata for them to be used to inform the title of the navigator item [1].
Fixes rdar://152652751.
[1]: https://github.com/swiftlang/swift-docc/blob/65aaf926ec079ddbd40f29540d4180a70af99e5e/Sources/SwiftDocC/Indexing/Navigator/RenderNode%2BNavigatorIndex.swift#L140
* Add navigator title to LinkDestinationSummary
The navigator title, which contains abbreviated fragments of a symbol's declaration for display in navigation [1], was missing from LinkDestinationSummary.
The navigator title is used here [2], but the information wasn't being populated anywhere [3].
This commit captures the navigator title information from the render metadata, and stores it as part of `LinkDestinationSummary`. While the original information comes from the symbol graph [4], the `DocumentationContentRenderer` has some special logic to sanitise the declaration fragments, particularly for Swift [5]. In order to ensure that we have parity between internal and external navigator titles, used the render metadata rather than the original information from the symbol graph.
This mirrors what we're already doing with the shortened declaration fragments, which also are processed with the same logic.
Finally, `LinkDestinationSummary.makeTopicRenderReference()` has been updated to populate the navigator title variants, such that after this commit navigator titles will be correctly populated for external links in the navigator.
Fixes rdar://156488184.
[1]: https://github.com/swiftlang/swift-docc/blob/257c62d1ef11efc023667fda89c0cd4419a8afa3/Sources/SwiftDocC/Model/Rendering/References/TopicRenderReference.swift#L60-L63
[2]: https://github.com/swiftlang/swift-docc/blob/257c62d1ef11efc023667fda89c0cd4419a8afa3/Sources/SwiftDocC/Indexing/Navigator/RenderNode%2BNavigatorIndex.swift#L153
[3]: https://github.com/swiftlang/swift-docc/blob/257c62d1ef11efc023667fda89c0cd4419a8afa3/Sources/SwiftDocC/Infrastructure/Link%20Resolution/ExternalPathHierarchyResolver.swift#L225
[4]: https://github.com/swiftlang/swift-docc-symbolkit/blob/3fc0c6880f712ce38137d0752f24b568fce1522e/Sources/SymbolKit/SymbolGraph/Symbol/Names.swift#L23-L26
[5]: https://github.com/swiftlang/swift-docc/blob/257c62d1ef11efc023667fda89c0cd4419a8afa3/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift#L87-L105
* Add navigator title tests for external links in the navigator
Now that the navigator title is supported in external references, we can add some tests which verify this logic is working as expected.
Added some tests which verify that the navigator title is used as expected for both Swift and Objective C symbols.
* Rename `fullName` to `plainTextDeclaration` in LinkDestinationSummary
`plainTextDeclaration` is clearer and makes it harder to confuse it with `title`. It is also closer to how the value is derived.
Also updates the JSON schema in `LinkableEntities.json` to add the new `plainTextDeclaration` property to the `LinkDestinationSummary` and `LinkDestinationSummaryVariant` schemas.
* Rename to `subheadingDeclarationFragments` for clarity
`declarationFragments` was not descriptive enough about the contents of the property, so renamed to `subheadingDeclarationFragments` and deprecated `declarationFragments` for backwards compatibility.
The JSON encoding key is kept the same (`fragments`) for backwards compatibility.
* Rename `navigatorTitle` to `navigatorDeclarationFragments`
Renamed the property in `LinkDestinationSummary` which stores the declaration fragments for the navigator to `navigatorDeclarationFragments`, to follow the same naming convention as `subheadingDeclarationFragments` which fulfils a very similar purpose.
The documentation comments mirror each other, with one explaining that it's intended for use in topic groups, and the other that it's intended for use in navigators.
* Rename helper function for readability
Clarifies the function name so that it clearly states that only top level nodes are returned, as well as improving the grammar at the call site.
* Fix minor issue in comment1 parent 163fd03 commit f0a3e95
File tree
14 files changed
+448
-150
lines changed- Sources/SwiftDocC
- Infrastructure
- External Data
- Link Resolution
- LinkTargets
- SwiftDocC.docc/Resources
- Tests
- SwiftDocCTests
- Indexing
- Infrastructure
- LinkTargets
- Model
- Test Bundles/MixedLanguageFramework.docc/symbol-graphs/clang
- SwiftDocCUtilitiesTests
14 files changed
+448
-150
lines changedLines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
| |||
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
208 | | - | |
| 210 | + | |
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| |||
259 | 261 | | |
260 | 262 | | |
261 | 263 | | |
| 264 | + | |
| 265 | + | |
262 | 266 | | |
263 | 267 | | |
264 | 268 | | |
| |||
271 | 275 | | |
272 | 276 | | |
273 | 277 | | |
274 | | - | |
| 278 | + | |
275 | 279 | | |
276 | 280 | | |
277 | 281 | | |
| |||
Lines changed: 11 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
| 61 | + | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | 156 | | |
163 | 157 | | |
164 | 158 | | |
| |||
177 | 171 | | |
178 | 172 | | |
179 | 173 | | |
180 | | - | |
| 174 | + | |
| 175 | + | |
181 | 176 | | |
182 | 177 | | |
183 | 178 | | |
| |||
187 | 182 | | |
188 | 183 | | |
189 | 184 | | |
190 | | - | |
| 185 | + | |
191 | 186 | | |
192 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
193 | 191 | | |
194 | 192 | | |
195 | 193 | | |
| |||
201 | 199 | | |
202 | 200 | | |
203 | 201 | | |
204 | | - | |
| 202 | + | |
205 | 203 | | |
206 | 204 | | |
207 | 205 | | |
| |||
Lines changed: 10 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
72 | 79 | | |
73 | 80 | | |
74 | 81 | | |
| |||
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
132 | | - | |
| 139 | + | |
| 140 | + | |
133 | 141 | | |
134 | 142 | | |
135 | 143 | | |
| |||
143 | 151 | | |
144 | 152 | | |
145 | 153 | | |
| 154 | + | |
146 | 155 | | |
147 | 156 | | |
148 | 157 | | |
149 | 158 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | 159 | | |
154 | 160 | | |
155 | 161 | | |
156 | 162 | | |
157 | 163 | | |
158 | | - | |
159 | 164 | | |
160 | 165 | | |
161 | 166 | | |
0 commit comments