Frank C.
Frank C.

Reputation: 8088

Is there a way Automate sphinx-apidoc generation in readthedocs

I'm somewhat new at both these tool sets.

Currently I am running sphinx-apidoc... and then checking in the resulting doc/source/*.rst files so that readthedocs produces more than an empty document.

However; is there a way to have this done automatically during the readthedoc build process?

It would save remembering to build and checkin all the *.rst files in doc/source on the repo.

Upvotes: 1

Views: 469

Answers (1)

Manuel Kaufmann
Manuel Kaufmann

Reputation: 480

The correct way of executing an extra command on Read the Docs is using the "Build customization" feature via build.jobs configuration option. See the docs at https://docs.readthedocs.io/en/stable/build-customization.html

You can do the following in your case:

# .readthedocs.yaml
version: 2

build:
  os: ubuntu-22.04
  tools:
    python: 3
  jobs:
    pre_build:
     - sphinx-apidoc ...

Hopefully that works for you!

Upvotes: 3

Related Questions