5

Suppose the following documentation structure for sphinx:

doc
 |_ _static
 |_ _templates
 |_ api
     |_ index.rst
     |_ classes.rst
     |_ functions.rst
 |_ index.rst
 |_ more_functions.rst
 |_ conf.py

And that classes.rst, functions.rst and more_functions.rst have classes and functions to auto-document with autodoc/autosummary. The build will generate .rst files for those classes and functions in:

  • doc/generated for more_functions.rst
  • doc/api/generated for classes.rst and functions.rst

Is there a way to control where those generated folders are created?


I'm trying to get a unique generated folder in the end. In this case, with this structure:

doc
 |_ generated
     |_ generated-from-more-functions.rst
     |_ api
         |_ generated-from-api/classes.rst
         |_ generated-from-api/functions-rst
Mathieu
  • 5,410
  • 6
  • 28
  • 55

2 Answers2

1

I don't think there is such native functionality in sphinx.

The fastest way to achieve this without many headaches is to create a shell script to run the build and then move (with mv or rm if you're on gnu/linux) the files according to your needs.

SystemSigma_
  • 1,059
  • 4
  • 18
-2

According to Sphinx documentation, you can run sphinx-build with the option BUILDDIR.

BUILDDIR The build directory to use instead of the one chosen in sphinx-quickstart.

I guess the default folders that you have mentioned are technically chosen by sphinx-quickstart.

example:

sphinx-build -b html sourcedir builddir

You can run the command through a subprocess or using os.system(command).

Bilal Qandeel
  • 727
  • 3
  • 6
  • The build directory is where e.g. the `html` pages will end up. By default `_build`. This has nothing to do with the location where `autodoc` saves the generated `.rst` files. – Mathieu Aug 27 '22 at 19:47