Python Sphinx Autodoc Not Rendering On Readthedocs
Solution 1:
Your project's dependencies are not specified on RTD, but you have installed the dependencies locally. You can verify this in the build log. Visit your project's Builds, click a build, and click "view raw".
WARNING: autodoc: failed to importclass'trial.TrialInfo'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importclass'trial.Trial'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importfunction'trial.load'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importclass'channels.ChannelInfo'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importclass'channels.Channel'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importclass'channels.Event'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importclass'channels.Keyboard'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importclass'channels.Waveform'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importclass'channels.Wavemark'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importclass'sig_proc.SignalProcessing'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importfunction'plot.plot_channel'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importfunction'plot.plot_trial'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
WARNING: autodoc: failed to importfunction'read.read'frommodule'spike2py'; the following exception was raised:
cannot import name 'Literal'from'typing' (/home/docs/.pyenv/versions/3.7.9/lib/python3.7/typing.py)
To remedy the situation, you must specify that your project's dependencies must be installed. See Specifying Dependencies.
You must either:
- Create a pip requirements file that specifies requirements, or
- Create a file that specifies a
pip install
option which will install requirements that are already defined elsewhere, such as in asetup.py
docs_requires
stanza. See an example in the Pyramid repository with its rtd.txt and setup.py.
rtd.txt
-e .[docs]
setup.py
docs_extras = [
'Sphinx >= 3.0.0', # Force RTD to use >= 3.0.0'docutils',
'pylons-sphinx-themes >= 1.0.8', # Ethical Ads'pylons_sphinx_latesturl',
'repoze.sphinx.autointerface',
'sphinxcontrib-autoprogram',
]
# ...extras_require={'testing': testing_extras, 'docs': docs_extras},
One you have defined your project requirements in this file, then you must configure Read the Docs to recognize this file to install dependencies. The preferred method is to use a configuration file, but you can also do this through the project's Admin Dashboard.
Solution 2:
I had exactly the same problem. Readthedocs could not extract the docstrings from my Project because it did not find my project module.
I solved this by adding 2 relative paths in the docs/conf.py:
sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath("../"))
So that now the top of the docs/conf.py looks as follows:
import os
import sys
import sphinx_rtd_theme
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath("../"))
sys.path.insert(1, os.path.dirname(os.path.abspath("../")) + os.sep + "feature_engine")
Post a Comment for "Python Sphinx Autodoc Not Rendering On Readthedocs"