简体   繁体   中英

Controlling where sphinx generated .rst files are saved

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

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) .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM