4

Is it possible to set the Sphinx autodoc Python module path from Jupyter Book, for example via _config.yml?

I'm using Jupyter Book to document a Python system and publish to Read The Docs. I can set the module path from Sphinx by adding code like this to conf.py:

import os
import sys
sys.path.insert(0, os.path.abspath("my/module/path"))

However, I'd prefer to control the path entirely from the Jupyter Book side. Otherwise I have to manually edit conf.py after generating the file with jupyter-book config sphinx path/to/book.

  • 2
    A more robust solution would be to avoid mangling the path entirely and using metadata files (`pyproject.toml` or its older brother, `setup.py`) to make the library code installable. – astrojuanlu Dec 07 '21 at 16:22
  • How do I make the library code installable via `setup.py`? – Paolo Amoroso Dec 07 '21 at 21:01
  • There are various guides out there, I'd recommend skipping `setup.py` entirely and use flit with `pyproject.toml` instead https://flit.readthedocs.io/ – astrojuanlu Dec 08 '21 at 11:22
  • Edit suggestion : add the link to the documentation of the API doc integration in Jupyter-Notebook : https://jupyterbook.org/en/stable/advanced/developers.html This might be helpful since the official documentations are usually less reachable than question on SO via googling. – FraSchelle Dec 15 '22 at 10:32

0 Answers0