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
Fixing broken references on multi-repository site build #7634
Comments
Thank you for the detailed report. AFAIK, Sphinx core generates |
AFAIK |
Ok, so I took a look at the doxygen generated XML files, and they do have the location (aka path) of the file where a reference is found, so technically it looks like it is possible to fix this on |
No, |
@tk0miya, I believe this is a problem in Sphinx, at least in the C++ domain, but I think it is in all domains. .. cpp:function:: template<typename T> \
T f()
:cpp:any:`T` where the Similarly, are there other attributes of |
I am trying to fix some issues with broken links when building this site: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/index.html
The build steps are given here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/doc_build.html
It basically consists on cloning many different open-source repositories, where the documentation is distributed among them. The details are not relevant, and are handled automatically by tooling. Since those projects consist primarily of C (or C++) source code and doxygen documentation,
breathe
is used to build from it, andintersphinx
is used to resolve references between different projects, which seems to be the source of the issue we're having.One example of a broken link in a document can be seen here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/bluetooth/gatt_dm.html#_CPPv4N15bt_gatt_dm_attr4uuidE. If trying to read the documentation for
bt_uuid
it goes to a broken link. At the same time links that were not generated from source code , eg: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/nrf9160/lwm2m_carrier/README.html, going to "From Zephyr" and clicking on "MQTT" goes to the correct site.I did some digging and found a few things. We currently use relative paths in our
intersphinx_mapping
, and one obvious solution would be to use a URL and everything would work, with a few new issues, like documentation not working locally, versioned documentation requiring extra handling on builds, etc.Trying to find the reason for why some relative path based links work, and some don't, I found out that
intersphinx
resolves links on itsmissing_reference
callback, for relative paths it happens here: https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/ext/intersphinx.py#L312. It uses therefdoc
value (a document path) to deduce how many directories it has to move up before joining with the path given inintersphinx_mapping
. This works correctly for documentation generated from .rst files, eg:ref:'MQTT <zephyr:mqtt_socket_interface>'
, the working example I linked above. For the broken links, which are originated from source code parsed by the cpp domain parser,refdoc
is not available, which preventsintersphinx
from correctly resolving the paths.To fix the issue I made something that feels like a terrible hack, but seems to work correctly here. I changed the
transformation
code where references are resolved with the following diff:Although this seems wrong to do (and modifying a parameter!), adding the
refdoc
there fixes the links.Since I am not very acquainted with the sphinx projects' source code just yet, it would be nice to hear opinions on how to properly fix the issue.
The text was updated successfully, but these errors were encountered: