You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
INFO - Doc file 'api/numcodecs_wasm_random_projection/index.md' contains a link '#numcodecs_wasm_random_projection.RandomProjection--fn:1', but there is no
such anchor on this page.
INFO - Doc file 'api/numcodecs_wasm_random_projection/index.md' contains a link '#numcodecs_wasm_random_projection.RandomProjection--fn:2', but there is no
such anchor on this page.
INFO - Doc file 'api/numcodecs_wasm_random_projection/index.md' contains a link '#numcodecs_wasm_random_projection.RandomProjection--fnref:1', but there is no
such anchor on this page.
INFO - Doc file 'api/numcodecs_wasm_random_projection/index.md' contains a link '#numcodecs_wasm_random_projection.RandomProjection--fnref:2', but there is no
such anchor on this page.
These links are the forward and backward links of the footnotes.
Hey @juntyr, thanks for the report. I tried building your docs but I'm getting missed cross-reference warnings instead of info logs about footnotes. Could you try to provide a minimal reproduction example?
INFO - Cleaning site directory
INFO - Building documentation to directory: /workspaces/mkdocs-footnotes/site
INFO - Doc file 'api.md' contains a link '#pkg.Cls--fn:1', but there is no such anchor on this page.
INFO - Doc file 'api.md' contains a link '#pkg.Cls--fnref:1', but there is no such anchor on this page.
INFO - Documentation built in 0.23 seconds
Not sure to understand why we have this line. Surely enabling verbose mode doesn't mean we want anchor validation to be disabled.
The reproduction indicates the culprit is mkdocstrings, and upon investigation, I think it is indeed, because when creating a new, inner Markdown instance to render docstrings, it registers MkDocs' _RelativePathTreeprocessor again, but using the same instance, not a new one. So when mkdocstrings converts the docstring, it populates the relpath processor's links_to_anchors attribute, which is then assigned to the page's own links_to_anchors attribute:
Then later MkDocs runs validation and boom, footnotes generated by mkdocstrings' inner Markdown instance are iterated on in the upper MkDocs level, where MkDocs wasn't able to extract anchors from mkdocstrings' generated HTML.
I suppose the easiest fix (and probably correct fix too) is to create a new instance of the relpath processor in mkdocstrings.
Activity
pawamoy commentedon Feb 3, 2025
Hey @juntyr, thanks for the report. I tried building your docs but I'm getting missed cross-reference warnings instead of info logs about footnotes. Could you try to provide a minimal reproduction example?
juntyr commentedon Feb 3, 2025
I created https://github.com/juntyr/mkdocs-footnotes which provides the following build output - there are footnotes both in the index.md and api.md files.
pawamoy commentedon Feb 3, 2025
Thanks, I was able to reproduce the issue you describe. What's weird is that the info logs disappear in verbose mode. Probably because of this line:
mkdocs/mkdocs/structure/pages.py
Line 291 in 7e4892a
Not sure to understand why we have this line. Surely enabling verbose mode doesn't mean we want anchor validation to be disabled.
The reproduction indicates the culprit is mkdocstrings, and upon investigation, I think it is indeed, because when creating a new, inner Markdown instance to render docstrings, it registers MkDocs'
_RelativePathTreeprocessoragain, but using the same instance, not a new one. So when mkdocstrings converts the docstring, it populates the relpath processor'slinks_to_anchorsattribute, which is then assigned to the page's ownlinks_to_anchorsattribute:mkdocs/mkdocs/structure/pages.py
Line 292 in 7e4892a
Then later MkDocs runs validation and boom, footnotes generated by mkdocstrings' inner Markdown instance are iterated on in the upper MkDocs level, where MkDocs wasn't able to extract anchors from mkdocstrings' generated HTML.
I suppose the easiest fix (and probably correct fix too) is to create a new instance of the relpath processor in mkdocstrings.
fix: Renew MkDocs' `relpath` processor instead of using same instance
pawamoy commentedon Feb 3, 2025
Fixed in mkdocstrings, will release soon.