-
Notifications
You must be signed in to change notification settings - Fork 196
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
“'myst' reference target not found: b.md#anchor” when building in parallel #411
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
thanks, I'll try to have a look soon(ish) 😬 |
Well that's why it as related and not fixed 😅 I had a brief look in that PR, but could not see anything obviously wrong with the myst-parser implementation. The issue is possibly to do with the merging of global environments from the parallel processes, after reading documents, here: https://github.com/sphinx-doc/sphinx/blob/a284aa65717f7a0c494c4c0859d2158094284ad1/sphinx/environment/__init__.py#L316-L317 The myst-parser renderer add to the standard domain here: MyST-Parser/myst_parser/sphinx_renderer.py Lines 155 to 160 in 0846a1f
Then sphinx should merge this into the final global environment here: https://github.com/sphinx-doc/sphinx/blob/a284aa65717f7a0c494c4c0859d2158094284ad1/sphinx/domains/std.py#L727-L743 The data should then be available for the post-transform (performed after all documents have been read), here: MyST-Parser/myst_parser/myst_refs.py Line 201 in 0846a1f
I would maybe check if the final global environment: I probably won't have time to do this soon, but you or anyone is welcome to have a go |
I’m not exactly sure what to look for, but I do notice that the pickled environment from the parallel build is missing the >>> a = pickle.load(open("build-serial/.doctrees/environment.pickle", "rb"))
>>> a
<sphinx.environment.BuildEnvironment object at 0x7f47e873feb0>
>>> a.myst_anchors
True
>>> b = pickle.load(open("build-parallel/.doctrees/environment.pickle", "rb"))
>>> b
<sphinx.environment.BuildEnvironment object at 0x7f47e8701fd0>
>>> b.myst_anchors
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'BuildEnvironment' object has no attribute 'myst_anchors' |
Indeed, removing the --- a/myst_parser/myst_refs.py
+++ b/myst_parser/myst_refs.py
@@ -203,7 +203,7 @@ class MystReferenceResolver(ReferencesResolver):
) -> Optional[Element]:
"""Resolve doc with anchor."""
target = node["reftarget"] # type: str
- if not ("#" in target and hasattr(self.env, "myst_anchors")):
+ if "#" not in target:
return None
# the link may be a heading anchor; we need to first get the relative path
rel_path, anchor = target.rsplit("#", 1) |
Its okay, I know why it is, fixing now |
Work around executablebooks/MyST-Parser#411. Signed-off-by: Anders Kaseorg <[email protected]>
Work around executablebooks/MyST-Parser#411. Signed-off-by: Anders Kaseorg <[email protected]>
Work around executablebooks/MyST-Parser#411. Signed-off-by: Anders Kaseorg <[email protected]>
Work around executablebooks/MyST-Parser#411. Signed-off-by: Anders Kaseorg <[email protected]>
Work around executablebooks/MyST-Parser#411. Signed-off-by: Anders Kaseorg <[email protected]>
Work around executablebooks/MyST-Parser#411. Signed-off-by: Anders Kaseorg <[email protected]>
Work around executablebooks/MyST-Parser#411. Signed-off-by: Anders Kaseorg <[email protected]>
Describe the problem
I configured
myst_heading_anchors = 2
as documented, but anchor links are giving me this warning if I enable parallelism (sphinx-build -W -j N
for anyN
other than 1):When building without parallelism, there is no warning and the anchor works fine.
Link to your repository or website
https://github.com/andersk/myst-anchor-test
Steps to reproduce
If you want to reproduce again,
rm -rf build
.The version of Python you're using
3.9.6
Your operating system
NixOS 21.11
Versions of your packages
Additional context
No response
The text was updated successfully, but these errors were encountered: