Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make sphinx look for modules in virtualenv while building html?

I want to build html docs using a virtualenv instead of the native environment on my machine.

I've entered the virtualenv but when I run make html I get errors saying the module can't be imported - I know the errors are due to the module being unavailable in my native environment. How can I specify which environment should be used when searching for docs (eg the virtualenv)?

like image 998
cerberos Avatar asked Nov 08 '10 07:11

cerberos


People also ask

How do I build an HTML file in Sphinx?

$ sphinx-build -b html sourcedir builddir where sourcedir is the source directory, and builddir is the directory in which you want to place the built documentation. The -b option selects a builder; in this example Sphinx will build HTML files. Refer to the sphinx-build man page for all options that sphinx-build supports.

What is the Sphinx-build environment variable?

The sphinx-build refers following environment variables: A path to make command. A command name is also allowed. sphinx-build uses it to invoke sub-build process on make-mode. The Makefile and make.bat files created by sphinx-quickstart usually run sphinx-build only with the -b and -d options.

What is a Sphinx documentation project?

In this tutorial you will build a simple documentation project using Sphinx, and view it in your browser as HTML. The project will include narrative, handwritten documentation, as well as autogenerated API documentation. The tutorial is aimed towards Sphinx newcomers willing to learn the fundamentals of how projects are created and structured.

How to generate the skeleton of the Sphinx project in Python?

This script will generate the skeleton of the sphinx project. Create a python task in Run/Edit-Configurations... in PyCharm like below. Be careful with the python interpreter and your script (If you use python environment like me). This script will generate the rst files for your modules.


1 Answers

The problem is correctly spotted by Mathijs.

$ which sphinx-build /usr/local/bin/sphinx-build 

I solved this issue installing sphinx itself in the virtual environment.

With the environment activated:

$ source /home/migonzalvar/envs/myenvironment/bin/activate $ pip install sphinx $ which sphinx-build /home/migonzalvar/envs/myenvironment/bin/sphinx-build 

It seems neat enough.

like image 166
migonzalvar Avatar answered Oct 09 '22 08:10

migonzalvar