Search code examples
gitgithubpython-sphinxread-the-docs

autodoc directive works locally but not on readthedocs


My repo is located on github here: https://github.com/AshleySetter/optoanalysis

And the docs are in https://github.com/AshleySetter/optoanalysis/tree/master/optoanalysis/docs

ReadTheDocs doesn't fail but the produced documentation (hosted here: https://optoanalysis.readthedocs.io/en/latest/) doesn't display the doc strings that should be produced by the ..autodoc:: command.

However it runs fine locally and displays the documentation when I open the build/html/index.html file.

On ReadTheDocs it looks like:

READTHEDOCS documentation

Whereas the locally built html file looks like so:

locally hosted documentation

Why might this be?


Solution

  • You have modules written in Cython and compiled to C. I think ReadTheDocs doesn't support C extensions. You have to protect you imports to be generated at ReadTheDocs.

    Something like this:

    import os
    if 'READTHEDOCS' not in os.environ:
        import cython_generated_ext