Improve the Sphinx autodoc for Django classes.
Project description
sphinxcontrib-django2
Improvements for the output of Sphinx’s autodoc for Django classes.
This is a fork of sphinxcontrib-django, which seems to be no longer maintained. In comparison to the upstream repository, this provides the following:
Support for current versions of Python and Django
Support for ModelForms
Support Intersphinx mappings to Django classes
100% test coverage
The original repository already implemented the following features:
Properly show which fields a model has.
Properly show which fields a form has.
Document the model fields as parameters in the model __init__().
Link foreign key and related fields to the documentation of the referenced class.
Hide irrelevant runtime information like declared_fieldsets, fieldsets and Meta from classes.
A :django:setting: role to allow linking to Django documentation. (e.g. :django:setting:`SITE_ID`)
Installation
Usage:
pip install sphinxcontrib-django2
Add to the Sphinx config file (conf.py):
extensions = [
'sphinx.ext.autodoc',
'sphinxcontrib_django2',
]
Autodoc works by importing your code on the fly, and extracting the data from the Python classes. Thus, the project should be able to import Django models. Typically the following needs to be added to conf.py:
sys.path.insert(0, os.path.abspath('../src'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
django.setup()
To support the :django:setting: role, configure Intersphinx:
intersphinx_mapping = {
'http://docs.python.org/': None,
'https://docs.djangoproject.com/en/stable': 'https://docs.djangoproject.com/en/stable/_objects',
}
Contributing
Pull requests are always welcome!
You can install all requirements of the development setup with Pipenv:
pipenv install --dev
pipenv run pre-commit install
Then, run the tests with:
pipenv run coverage run runtests.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sphinxcontrib-django2-0.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c673da1edef6e8605f15177df7ae9ef61a2e54b4f8065f665a2a83005df9708 |
|
MD5 | 9fb9a0152582b1223cfaa85855533135 |
|
BLAKE2b-256 | 25003b9b63d81a74f856cce9d802b4f290ffca3edcf4e847ff8bc657f4ca0e67 |
Hashes for sphinxcontrib_django2-0.7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d4688a49fc7a526675a213b763e21210400c60d520425b23256353d0c9842f7 |
|
MD5 | 90fa639094bfe186f4bbc3be8c2f572b |
|
BLAKE2b-256 | 4b85e5add21832ca2582def0fc79c06dc1a60ace0f39438984b4a0b82ad069d0 |