Search code examples
pythonhyperlinkpython-sphinxread-the-docsmyst

MyST implicit references work locally but not on Read The Docs


I am using Sphinx to build my documentation and I parse markdown files with MyST. I used implicit text to link to different references, for example [](#my-heading) or [](#MyPyClass). This works fine locally but not on Read The Docs; the text is not filled in and references to different pages are not resolved.

How it works locally:

See [](#my-heading) results in "See My_Heading" with a hyperlink to the section.

Using [](#MyPyClass) in fil1.html creates link references correctly from file://path/file1.html to file://path/modules/classes#MyPyClass and the text written will be "MyPyClass" or "modules.classes.MyPyClass" if I use the full dot-fragment.

On Read The Docs

Problem 1: Same Page: If I use see [](#my-heading) on a page where #My Heading is present it does not fill-in the text. [](#my-heading) results in an empty see <a href=#my-heading></a> block, instead of writing "see My Heading"

Problem 2: Different pages: If I use [](#MyPyClass) or [](#modules.classes.MyPyClass) it will also be empty and result only in a file-interal reference, e.g. file1.html#MyPyClass.


I double checked. I use the same python (3.10), sphinx ( v7.3.7) and myst_parser (3.0.1) versions in both envuronments. The logs are mostly similar, expect that at the end locally more warnings are generated. These local warnings are about 'myst' cross-reference not found that are not yet in the documentation and are therefor correct, online these warnings are not logged.

Any ideas or solutions why it is not working and the cross-referencing of myst is bugged?


Solution

  • I could not track down the fault, checking older logs the versioning was fine. In the end it was a versioning issue. I am not sure if docutils was the cause but locally I had 0.21 and on RTD it was downgraded to 0.18 instead. Currently MyST has a >=0.18 docutils dependency, hence no errors were reported, but something must have interfered when building the doctree to not generate those links.

    Adjusting the dependencies and having docutils at 0.21 fixed it for me.