3
votes

I have a Python project with Sphinx documentation, and to keep the code repository small, some of the images and other files I want to include in the docs are in a separate repo.

For the Sphinx docs build, I do have a shell environment variable set to point to the other repo. I tried using it from an image directive like this:

.. image:: $OTHER_REPO/docs_images/image.png

but that doesn't work.

For now, I've put some code in docs/conf.py that copy over the files I need into the docs source tree, and then it works. But this feels like a hack, there must be a proper / better way to do this?

1

1 Answers

0
votes

I found the following solution that solves my problem.

Visit Change variable in sphinx conf.py as part of build command

Basically, we can define the env variable in Jupyter that can initialize in the make.bat file by set the following comments:

Jupyter notebook:

try:
    status_flag = %env status_flag
    print('Status_flag defined as ' + status_flag + '!')
    
except:
    status_flag = 'MP4'
    print('Status_flag defined as ' + status_flag + '!')

make.bat:

SET status_flag=HTML
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%