Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view the HTML Sphinx generates in Django?

OK - I have a Django project that I want to document -- so I installed Sphinx. The install went fine, and I can ouput all the HTML to a _build folder. But...

The question is: how do I actually view my documentation in a browser?

Is it assumed that the documentation will not be viewed within the Django project but in its own website? If viewed within the Django project, do I need to set up a url pattern to handle the documentation?

I'm a little bit confused how to actually view this information in my browser within the Django project.

like image 556
Garfonzo Avatar asked May 15 '12 05:05

Garfonzo


People also ask

What is sphinx Django?

Sphinx is a popular tool for documenting Python projects, including the ability to generate automatic documentation using docstrings in your source code.


1 Answers

url(r'^docs/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.DOCS_ROOT}),
url(r'^docs/', 'django.views.static.serve', {'document_root': settings.DOCS_ROOT, 'path': 'index.html'}),

Where settings.DOCS_ROOT is an absolute path to your docs/_build/html directory generated by Sphinx.

There's a reusable app for exactly this purpose: django-docs ;)

like image 155
littlepea Avatar answered Oct 15 '22 02:10

littlepea