-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Unknown node: pending_xref_condition
#9240
Comments
Thank you for reporting. I guess Sphinx's post processing has a bug when 3rd party extension resolves a missing-reference. Could you check this patch works fine?
(I'll try this tomorrow. But I need to build the environment to build the example project. I don't know PyQt at all...) |
Not quite. It removes the exception, but the I was thinking of something more along the lines of --- a/sphinx/transforms/post_transforms/__init__.py
+++ b/sphinx/transforms/post_transforms/__init__.py
@@ -69,11 +69,15 @@
default_priority = 10
def run(self, **kwargs: Any) -> None:
for node in self.document.traverse(addnodes.pending_xref):
- contnode = cast(nodes.TextElement, node[0].deepcopy())
+ content = find_pending_xref_condition(node, 'resolved')
+ if content:
+ contnode = content.children[0] # type: ignore
+ else:
+ contnode = cast(nodes.TextElement, node[0].deepcopy())
newnode = None
typ = node['reftype']
target = node['reftarget']
refdoc = node.get('refdoc', self.env.docname) (although you might need to somehow handle the case, where The above patch fixes the error and produces the desired results for the minimal test case, that I have provided, but I am not sure, if it plays well with other components of the reference resolution process. With a little refactoring you should also be able to remove the duplicated code fragments in the following functions:
All these functions are called from
or via connecting to the
You shouldn't need any |
… raised Unknown node error for pending_xref_condition is raised if an extension that does not support the node installs a missing-reference handler.
… raised Unknown node error for pending_xref_condition is raised if an extension that does not support the node installs a missing-reference handler.
… raised Unknown node error for pending_xref_condition is raised if an extension that does not support the node installs a missing-reference handler.
… raised Unknown node error for pending_xref_condition is raised if an extension that does not support the node installs a missing-reference handler.
… raised Unknown node error for pending_xref_condition is raised if an extension that does not support the node installs a missing-reference handler.
Thank you for confirmation. And it seems your proposal is better than mine. I posted #9246 to resolve this issue. Could you confirm this, please?
On my local, I can't install
|
I've tried the 9246 fix, and it seems to work fine for me.
Ah, do you have a headless machine or something? Unfortunately,
Why not? Do you mean that you don't have the admin privileges? Unfortunately, I don't think there's anything you can do in that case other than contacting your admin. |
Thank you for confirming.
Thank you for your wisdom. I confirm |
…condition Fix #9240: Unknown node error for pending_xref_condition is raised
Fixed in #9246. But keep opened for refactoring in 4.x branch. |
…doc#9240) After sphinx-doc#9246, `find_pending_xref_conditions()` should be only called from intended modules. At present, the Python Domain is the only module to call it intendedly. Therefore, this removes the needless calls of the utility function from "unintended" modules.
…doc#9240) After sphinx-doc#9246, `find_pending_xref_conditions()` should be only called from intended modules. At present, the Python Domain is the only module to call it intendedly. Therefore, this removes the needless calls of the utility function from "unintended" modules.
…itions refactor: reduce calls of find_pending_xref_conditions (refs: #9240)
Refactored by #9254. Closing. |
To Reproduce
python -m venv .venv . .venv/bin/activate pip install sphinx==4.0.1 sphinx-qt-documentation==0.3 PyQt5==5.15.4 mkdir docs
foo.py
:docs/conf.py
:docs/index.rst
:Run:
Result
Environment info
sphinx.ext.autodoc
,sphinx.ext.intersphinx
,sphinx_qt_documentation
Additional context
This is similar to the issue that was fixed in #8996. I think, that I've tracked the issue to the
sphinx-qt-documentation
plugin. This plugin connects itself tomissing-reference
events like thishowever, their
missing_reference
implementation doesn't have thesnippet, which eventually leads to the above
Unknown node: pending_xref_condition
error.I could submit this as a bug report to the author of
sphinx-qt-documentation
, but I wanted to make sure, that this behaviour is intended. It seems to me like a potential antipattern. For example, the above snippet (with minor variations) is already duplicated internally insphinx/domains/python.py:PythonDomain.resolve_xref
sphinx/domains/python.py:PythonDomain.resolve_any_xref
sphinx/domains/python.py:builtin_resolver
sphinx/ext/intersphinx.py:missing_reference
And any plugin that connects to the
missing-reference
event must also now add this snippet (which is complicated by the fact thatfind_pending_xref_condition
doesn't seem to be available insphinx<4
). Do you think that maybe thecontnode
value should be resolved when themissing-reference
event is created insphinx/transforms/post_transforms/__init__.py
?The text was updated successfully, but these errors were encountered: