Simplify CrossReference resolve#1571
Open
tompng wants to merge 1 commit into
Open
Conversation
Collaborator
|
🚀 Preview deployment available at: https://76e6fa73.rdoc-6cd.pages.dev (commit: 028d4bc) |
a7f83c2 to
f46ea96
Compare
Member
|
@tompng I think this needs a rebase |
Simply return nil if crossref resolve failed
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies cross-reference resolution so unresolved or suppressed references return nil, with HTML rendering layers now responsible for fallback display behavior.
Changes:
- Removes the
textargument fromRDoc::CrossReference#resolve. - Updates HTML cross-reference fallback handling and
<tt>suppressed-reference behavior. - Adjusts tests for nil unresolved refs, escaped labels, and suppressed refs in
<tt>.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
lib/rdoc/cross_reference.rb |
Simplifies resolution return values and caching to refs or nil. |
lib/rdoc/markup/to_html_crossref.rb |
Updates callers and HTML fallback logic for nil unresolved refs. |
test/rdoc/rdoc_cross_reference_test.rb |
Updates resolver tests for the new nil-on-failure behavior. |
test/rdoc/markup/to_html_crossref_test.rb |
Adds/updates HTML cross-reference tests for suppression and escaping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| end | ||
| ref = @context.find_symbol name | ||
|
|
||
| ref = resolve_local_symbol name unless ref |
Comment on lines
+174
to
+175
| if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref) | ||
| text = "<code>#{text}</code>" |
Comment on lines
+250
to
+252
| if code.start_with?('\\') | ||
| # Remove leading backslash if crossref exists | ||
| "<code>#{convert_string(code[1..])}</code>" if cross_reference(code[1..])&.include?('<code>') |
| result = @to.convert '<tt>C1#m()</tt> <tt>\\C1#m()</tt>' | ||
| assert_equal para('<a href="C1.html#method-i-m"><code>C1#m()</code></a> <code>C1#m()</code>'), result | ||
|
|
||
| # Keep backshash if crossref doesn't exitst |
Comment on lines
+244
to
+245
| # REGEXP sometimes matches to a string starts with backslash which is not a suppressed crossref. (e.g. `\+`) | ||
| # We need to check the backslash removed part matches to crossref_regexp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Simply return nil if crossref resolve failed.
Crossref suppression (already done in another part) is not what
CrossReference#resolvehave to do.So
resolve(name, text)don't needtextarg.Cache mechanism of
resolvewill be simple: no string label cache, only cacherefornil.