pythonpython-sphinxread-the-docs

API reference section blank on readthedocs


I am trying to get documentation on the readthedocs for my package epspy (https://github.com/shikharmittal04/epspy.git). I can see all the sections on the documentation except for the API reference section, which is completely blank. Note that when I am working on my local PC I can see the API generated successfully.

I have only one module called meps.py in src/epspy

I followed the solution on https://github.com/readthedocs/readthedocs.org/issues/1139 I added the following set of code in my conf.py

def run_apidoc(_):
    from sphinx.ext.apidoc import main
    sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    module = os.path.join(cur_dir,"..","src/epspy")
    main(['-e', '-o', cur_dir, module, '--force'])

def setup(app):
    app.connect('builder-inited', run_apidoc)

However, the API section is still blank.


Solution

  • I finally found the issues. Firstly, I had to add all the dependent packages in the requirements.txt in the docs directory. In my case I had the following

    mpi4py
    healpy
    transformcl
    numpy
    scipy
    sphinx
    sphinx_rtd_theme
    numpydoc
    sphinx-autoapi
    

    Next, under the python section and install subsection, add

    - method: pip
      path: .
    

    If it weren't for mpi4py, everything would work fine. However, since mpi4py needs additional libraries installed, we need to add

    apt_packages:
      - libopenmpi-dev
    

    under the build section of .readthedocs.yaml file.