-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support disambiguating links with type signature information #643
Support disambiguating links with type signature information #643
Conversation
# Conflicts: # Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift
Co-authored-by: Ethan Kusters <[email protected]> Co-authored-by: Daniel Grumberg <[email protected]> Co-authored-by: Max Obermeier <[email protected]> Co-authored-by: Natik Gadzhi <[email protected]>
I feel that the code in this PR is getting too long to be easily reviewed but splitting it into multiple files in the same PR makes it much much harder to know what changed and what moved. Because of this I opened #662 to only split the code into multiple files and then this PR can focus on just the new feature. |
0939305
to
4b2581b
Compare
4b2581b
to
7341760
Compare
# Conflicts: # Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Error.swift # Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Find.swift # Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift # Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift # Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift
9605330
to
3827762
Compare
# Conflicts: # Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+DisambiguatedPaths.swift # Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Error.swift # Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Find.swift # Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift # Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Serialization.swift # Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift # Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift
The main implementation is ready for review. I will update the user facing documentation to describe this new syntax. |
@swift-ci please test |
Also, format the error message better in single-line presentation
… of the overloaded symbols Also, improve paths for overload groups and other preferred symbols
aea9c21
to
f57ac6c
Compare
@swift-ci please test |
I resolved the merge conflicts so this is reviewable again. I also updated the code to make some improvements for overload groups and C++ operators which are new changes since last time I updated this PR. |
I have some more improvements in mind for the richness of the error messages about ambiguous links, but my plan is to defer that to a follow up PR, sometime after this is merged 🤞 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work!
I left a lot of questions and a few suggestions mostly around the readability of the code. You added extensive new unit tests, which is great, but I can imagine some quirks or odd corner conditions could come up someday. I'd suggest we merge this and then keep an eye on how the disambiguation is working over time as we use these new disambiguation styles more and more.
Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+DisambiguatedPaths.swift
Show resolved
Hide resolved
@@ -47,7 +53,7 @@ extension PathHierarchy { | |||
|
|||
func gatherLinksFrom(_ containers: some Sequence<DisambiguationContainer>) { | |||
for container in containers { | |||
let disambiguatedChildren = container.disambiguatedValuesWithCollapsedUniqueSymbols(includeLanguage: false) | |||
let disambiguatedChildren = container.disambiguatedValuesWithCollapsedUniqueSymbols(includeLanguage: false, allowAdvancedDisambiguation: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following on the previous comment: Here you set the values for these to false and true. It might be hard for someone in the future to track down where you set these values. Maybe using FeatureFlags
or maybe some struct-wide attribute of PathHierarchy
instead of function parameters would make the code less verbose and easier to understand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too concerned about this since these are mostly file private arguments that are passed by the caller.
Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+DisambiguatedPaths.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+DisambiguatedPaths.swift
Show resolved
Hide resolved
Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+DisambiguatedPaths.swift
Show resolved
Hide resolved
Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift
Show resolved
Hide resolved
Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift
Show resolved
Hide resolved
Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift
Show resolved
Hide resolved
return lhs.fullName < rhs.fullName | ||
} | ||
.map { (fullName: String, suggestedDisambiguation: String) -> Solution in | ||
// In contexts that display the solution message on a single line by removing newlines, this extra whitespace makes it look correct ─────────────╮ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand what this is referring to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default diagnostic formatter outputs diagnostic solutions (phrased as "suggestions") on a single line. For example:
4 | /// Here's a link that uses the wrong symbol kind disambiguation in a link:
5 + /// - ``myFunction(with:and:)-struct``
| ╰─suggestion: Remove '-struct' for'func myFunction(with one: Int, and two: String) -> Bool'
If you look closely at the suggestion text you can see that there's a missing space between "for" and the symbol name.
With these changes this suggestion text isn't missing that space:
suggestion: Remove '-struct' for 'func myFunction(with one: Int, and two: String) -> Bool'
^
with this change there is an added space here
Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift
Show resolved
Hide resolved
Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift
Show resolved
Hide resolved
@swift-ci please test |
@swift-ci please test |
I started updating the user facing documentation related to link disambiguation but found that I want to make slightly larger documentation changes that I first thought and I feel that those updates would benefit from a separate review. I will merge this PR now since it's a big improvement and there doesn't seem to be any major feedback anymore. If there's more changes that you're like to request, please message me and I'll make a follow up PR. I already have further refinements and enhancements in mind so I plan to continue to iterate on this code over the coming months anyway. |
Bug/issue #, if applicable: rdar://112224233
Summary
Adds support for disambiguating symbol links with information from the symbol graph's
functionSignature
data.This new syntax was pitched on the Swift Forums in this thread.
With these changes DocC will support type signature disambiguation in links and will use it in diagnostics but topic references and page URLs will continue to only use kind-and-hash disambiguation to ensure that all pages have the same URLs as without these changes.
Dependencies
None.
Testing
Describe how a reviewer can test the functionality of your PR. Provide test content to test with if
applicable.
Steps:
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded