-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Allow reordered refs and translated display text in pending_xref #14144
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
Allow reordered refs and translated display text in pending_xref #14144
Conversation
…g_xref Add two parameters to `_NodeUpdater.compare_references()` method to support flexible reference comparison in translations: - `key_func`: Extract comparison key from references (default: rawsource) - `ignore_order`: Sort keys before comparing to allow reordering
|
@mattwang44 can you add a CHANGES entry? |
| # Compare by reftarget only, allowing translated display text. | ||
| # Ignore order since translators may legitimately reorder references. | ||
| key_func=lambda ref: ref.get('reftarget'), | ||
| ignore_order=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.
Should any of the other compare_references() calls have ignore_order=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.
To be honest, I'm not pretty sure.
I only applied it to update_pending_xrefs() since this would slash all those building warnings regarding sequence issue from the pydoc-zh-tw project, but I believe making it the default behavior (and remove ignore_order) should be safe. Either making it default behavior or stay as it is and apply ignore_order=True on demand both fine for me. What do you think?
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.
@mattwang44 are translators able to re-order any of the other ones?
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 believe so, but chances are rare.
|
cc @mattwang44 I want to release a 9.0.4 with this fix, can you have a look at my comments above? A |
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
|
@mattwang44 can you add a CHANGES entry? A |
Purpose
Reduce false positive
i18n.inconsistent_referenceswarnings forpending_xrefnodes.For
pending_xref, compare byreftargetonly (not fullrawsource) and ignore order. This allows translators to:Other reference types retain the original behavior.
References