-
Notifications
You must be signed in to change notification settings - Fork 143
Fix custom doc link title issue #376
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
Fix custom doc link title issue #376
Conversation
31007e5
to
a89cd8f
Compare
@swift-ci please test |
a89cd8f
to
63e708f
Compare
Testing passed here with the Markdown change: swiftlang/swift#61506 |
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.
This is looking really great, thank you @Kyle-Ye!
@Kyle-Ye is there remaining work for this PR? |
The implementation is done. But there is some Code Review discussion to be processed. Could you help give a look at the following thread👇 |
bd06ddd
to
4a7bf85
Compare
4a7bf85
to
f7f1d9f
Compare
f7f1d9f
to
7b80cf8
Compare
There is still one thing wrong. The _isAutoLink property will get lost after visiting it and visiting back. This issue was identified in the failed test case, To address this problem, we can save and restore the original mutating func visitLink(_ link: Link) -> Markup? {
...
let isAutolink = link.isAutolink // save the original isAutolink status
var link = link
link.destination = resolvedURL.absoluteString
link.isAutolink = isAutolink // restore the original isAutolink status
return link
} |
7b80cf8
to
37fe8bc
Compare
return [ | ||
RenderInlineContent.reference( | ||
identifier: .init(resolved.absoluteString), | ||
isActive: true, | ||
overridingTitle: link.isAutolink ? nil : overridingTitle, | ||
overridingTitleInlineContent: link.isAutolink ? nil : overridingTitleInlineContent | ||
) | ||
] |
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.
A possible solution to fix the failed test case and remove the need of Swift-Markdown's support for Markdown.Link._isAutolink
property / Markdown.Link.isAutolink
setter
return [ | |
RenderInlineContent.reference( | |
identifier: .init(resolved.absoluteString), | |
isActive: true, | |
overridingTitle: link.isAutolink ? nil : overridingTitle, | |
overridingTitleInlineContent: link.isAutolink ? nil : overridingTitleInlineContent | |
) | |
] | |
let useOverriding: Bool | |
if link.isAutolink { // If the link is an auto link, we don't use overriding info | |
useOverriding = false | |
} else if let overridingTitle, | |
overridingTitle.hasPrefix(DocumentationSchemeHandler.scheme + ":"), | |
destination.hasPrefix(DocumentationSchemeHandler.fullScheme), | |
destination.hasSuffix(overridingTitle.dropFirst((DocumentationSchemeHandler.scheme + ":").count)) { // If the link is a transformed doc link, we don't use overriding info | |
useOverriding = false | |
} else { | |
useOverriding = true | |
} | |
return [ | |
RenderInlineContent.reference( | |
identifier: .init(resolved.absoluteString), | |
isActive: true, | |
overridingTitle: useOverriding ? overridingTitle : nil, | |
overridingTitleInlineContent: useOverriding ? overridingTitleInlineContent : nil | |
) | |
] |
5eb2bd7
to
c2ad5b4
Compare
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.
This looks good, thanks!
@swift-ci Please test |
Looks like the |
ce6d3a6
to
025bce5
Compare
@swift-ci please test |
025bce5
to
420271d
Compare
@swift-ci please test |
The Swift-Markdown is fixed and the test passed on Swift-DocC. Are we ready to merge this? @QuietMisdreavus |
Refactor link rendering to use overriding titles only when appropriate
rdar://79992417
420271d
to
9399211
Compare
@swift-ci please test |
Bug/issue #, if applicable:
Close #271
Summary
Before the PR (current behavior)

After the PR (expected behavior)

Dependencies
swiftlang/swift-markdown#82swiftlang/swift-markdown#110
Testing
See RenderContentCompilerTests.swift
swiftlang/swift#61506
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded