问题
I'm using sphinx-autodoc-annotation to read the function annotations in my Python code and use that to generate the appropriate expected argument types and return types. It's working great on my local machine, but I had to pip install sphinx-autodoc-annotation
of course.
I'm trying to generate the same documentation using Read the Docs, but it gives me an error:
Could not import extension sphinx_autodoc_annotation (exception: No module named sphinx_autodoc_annotation)
Is it possible to configure Read the Docs to work with sphinx-autodoc-annotation, and if so, how do I make it work?
回答1:
Activate the Install Project option for your Read the Docs project.
If the option is activated, Read the Docs will try to execute setup.py install
on your package (see: RtD docs). In setup.py
, you can install packages as specified in your requirements file.
Have a look at the source code of the Flask-MongoRest project for an example.
Add sphinx-autodoc-annotation
as the only requirement to your requirements.txt
file.
回答2:
I don't like having a bunch of documentation requirements packaged through setup.py
, so my recommendation is not to use the Install Project option on RTD. Instead, I prefer put a custom requirements.txt
in my doc/
folder, and point RTD to it:
Stick whatever you have in setup.py
's install_requires
and/or requirements.txt
into this file. Make sure that any additional sphinx extensions you are using are in there as well.
That should take care of all your dependencies. The other interesting settings I would recommend look like this:
来源:https://stackoverflow.com/questions/39187770/how-do-i-configure-read-the-docs-to-use-sphinx-autodoc-annotation