I have a django project, which I document using reST in docstrings to do the following:
My documentation shows up properly within IDE (PyCharm), however I can't configure Sphinx to generate HTML documentation for me.
Here is the structure of my project
+--------------------------------------------+
| /saassapp # django project path |
| /docs # dir for sphinx |
| conf.py # sphinx config file |
| ... |
| settings.py # django settings |
| /studyview # django app |
| ...
| ... |
+--------------------------------------------+
Any ideas? An examle of the conf.py file would be very useful. Thank you.
EDIT
My project name is saassapp and the module I am trying to make a doc for is called studyview.
conf.py
file: http://pastebin.com/HTYdc1rR
index
file: http://pastebin.com/bu1r38TQ
make html
: http://pastebin.com/MWJj94EE
Create a documentation directory. Once you've installed Sphinx, you will need to create the document root folder. This folder will hold your documentation and other files you will need (images, about pages, and so on…). Create your document root folder in your project main folder and name it /docs.
Sphinx is a popular tool for documenting Python projects, including the ability to generate automatic documentation using docstrings in your source code.
The migration features introduced in Django 1.7 prevents the previous answers from working on newer versions. Instead you will have to do a manual setup. Analogous to all previous answers you'll first have to make sure Django can find your settings, and then call django.setup()
which will load the settings and setup your models. Add this to your Sphinx project's conf.py:
os.environ['DJANGO_SETTINGS_MODULE'] = 'projectname.settings'
import django
django.setup()
Add the following to your conf.py and you will not need to set DJANGO_SETTINGS_MODULE each time:
import sys, os
sys.path.append('/path/to/your/project') # The directory that contains settings.py
# Set up the Django settings/environment
from django.core.management import setup_environ
from myproject import settings
setup_environ(settings)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With