Search code examples
dnspython-sphinxrestructuredtext

How to use Intersphinx to link documents when the underlying domain will change?


I have a use case for reStructured Text documentation in an offline scenario. It will move from one domain to another when installed and often No Internet access will be available. I'm assuming HTML output of sphinx. I have multiple microservice projects that I'd like to be able to share links between them using Intersphinx. The projects will ride together and someone browsing one project will have access to the others. I expect they could always be arranged to be in a project folder on the same top level domain even.

All the examples I see on the Internet seem to assume that a static domain will be in use and the documentation isn't copied to new places. Is there some way to easily account for a changing domain?

An additional concern that maybe covers the previous is relative linking. Can we account for the domain change in a way that won't require me to rebuild the docs? In HTML I'd have links to "/some/page.html" instead of "http://example.com/some/page.html".


Solution

  • Sounds like you're just looking to use relative paths instead of domain names. If that's the case, you would do something like this in your conf.py:

    intersphinx_mapping = {
        'other': ('example/', 'example/example.inv'),
    } 
    

    From the intersphinx extension docs:

    Relative local paths for target locations are taken as relative to the base of the built documentation, while relative local paths for inventory locations are taken as relative to the source directory.