Hi Carl,

On Sun, 5 May 2024 09:44:16 -0700 (PDT), Carl Gay wrote:

> My project has some external HTML files that are put in place as a
> separate build step and I would like to add a link to them in my
> toctree. Currently I have this, and it works fine, but it assumes a
> static URL and therefore when testing the site on another host/port the
> URLs are incorrect...
> 
> .. toctree::
>    :caption: Reference :hidden:
> 
>    Dylan Reference Manual <https://opendylan.org/books/drm/>
>    Package Docs <package/index>
>    Open Dylan Libraries <library-reference/index>
>    All Documentation <documentation/index>
>    Full Index <genindex>
> 
> So instead of <https://opendylan.org/books/drm/> I would like to use
> something like <${base-url}/books/drm/> where the current base URL is
> substituted.
> 
> Simply using </books/drm/> doesn't work; I get "WARNING: toctree
> contains reference to nonexisting document 'books/drm'" and the link is
> omitted from the output.
> 
> As always, I feel like I'm missing something obvious.  Is there a way to
> do this?
I am not sure I understood your use case, so my solution might not be 
useful. 

First of all: in a toctree you can not use replacement or roles, so your 
approach can not work. Therefore, I think the simplest solution is to 
wrap 
the entire toctree in an only:: directive, e.g.,

.. only:: main

   .. toctree::
      :caption: Reference
      :hidden:
 
      Dylan Reference Manual <https://opendylan.org/books/drm/>
      Package Docs <package/index>
      Open Dylan Libraries <library-reference/index>
      All Documentation <documentation/index>
      Full Index <genindex>

Then you duplicate this block, changing "main" to something else 
("dylan"), and the URL to the one you want to test (https://otherurl.org/
books/drm/)

At build time, you pass a -t main or -t dylan option to build the one you 
want, e.g., sphinx-build -t dylan -b html source build

If you use make, you can define two Makefiles and add the -t main/dylan 
to 
the SPHINXOPTS of either Makefile, then pass the correct file to make 
(make -f Makefile vs. make -f -Makefile-dylan)

HTH,
Stefano


-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sphinx-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sphinx-users/v1cjtg%24kos%241%40ciao.gmane.io.

Reply via email to