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
Better 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
File details
Details for the file sphinxcontrib-django2-0.6.tar.gz
.
File metadata
- Download URL: sphinxcontrib-django2-0.6.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fcacbfe986d5be226c5ca5757eb872dbf86ae4e051d0dec8d4398413cb8e445 |
|
MD5 | 23e3ac65be82372ccd0c5e9f6d4437a2 |
|
BLAKE2b-256 | d35a193f672260753f6d2a5c97f81dcbcdf1d0c7f80bdb43a740af8c45b2ddc9 |
File details
Details for the file sphinxcontrib_django2-0.6-py2.py3-none-any.whl
.
File metadata
- Download URL: sphinxcontrib_django2-0.6-py2.py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39b3f83416387b03103a58259017e3df08fdbd7d0275f051db03f1af549a5e46 |
|
MD5 | 36df7ac2d57bb9f43bdb9b680f3372a0 |
|
BLAKE2b-256 | 16e3b7a2cc4f54036088ee797d707981d8b7fd7c86e845acdb03335ec127e460 |