How do I configure Read the Docs to use sphinx-autodoc-annotation?

谁说胖子不能爱 提交于 2019-12-07 23:49:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!