sphinxcontrib-django
This is a sphinx extension which improves the documentation of Django apps.
Features
Improvements for the output of Sphinx’s autodoc for Django classes:
List all model and form fields as class parameters
Improve model field representations
Link related and reverse related fields to the referenced class
Hide irrelevant runtime information like declared_fieldsets, fieldsets and Meta from classes
Add information about autogenerated methods
Fix intersphinx mappings to Django modules
Custom text roles to cross-reference the documentations of Django (:setting:, :templatetag:, :templatefilter:, :fieldlookup:) and Sphinx (:event:, :confval:)
Installation
Install the package via pip:
pip install sphinxcontrib-django
Configuration
Add the following to your Sphinx config file conf.py:
# Add source directory to sys.path
sys.path.insert(0, os.path.abspath("../src"))
# Add sphinxcontrib_django to installed extensions
extensions = [
"sphinxcontrib_django",
]
# Configure the path to the Django settings module
django_settings = "myapp.settings"
Optionally, you can include the table names of your models in their docstrings with:
# Include the database table names of Django models
django_show_db_tables = True # Boolean, default: False
# Add abstract database tables names (only takes effect if django_show_db_tables is True)
django_show_db_tables_abstract = True # Boolean, default: False
Optionally, you can extend amount of displayed choices in model fields with them:
# Integer amount of model field choices to show, default 10
django_choices_to_show = 10
Advanced Usage
If you want to run custom code which depends on Django, e.g. to monkeypatch your application during documentation build, you might run into an ImproperlyConfigured exception:
Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Therefore, this Sphinx extension emits the event django-configured after django.setup() is finished, so you can run your code the following way in conf.py:
def patch_django(app):
"""
Your custom code here
"""
def setup(app):
app.connect("django-configured", patch_django)
Contributing
Pull requests are always welcome!
You can install all requirements of the development setup with the extras dev, test, doc and optional:
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[dev,test,doc,optional]
pre-commit install
Run the tests and generate the coverage report with:
coverage run
coverage html
Build the documentation with:
cd docs
make html
The documentation is automatically deployed to Read the Docs.
Metadata
Release files for sphinxcontrib-django 2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sphinxcontrib-django-2.5.tar.gz | 23.8 kB | Without provenance | Details for sphinxcontrib-django-2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sphinxcontrib_django-2.5-py3-none-any.whl | Python 3 | none | any | Details for sphinxcontrib_django-2.5-py3-none-any.whl |
Total release size: 45.3 kB
Release files / sphinxcontrib-django-2.5.tar.gz
| Download URL | sphinxcontrib-django-2.5.tar.gz |
|---|---|
| Size | 23.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45a54c0cc1f641d6c15872828862f0738348ca8d7d5b92777bcaa530678c2cc4
|
|
BLAKE2b-256 checksum How to use checksums |
dc2892f6d685899fbd74a6c575c50dcc1abb8ab69c6da0160bc99d557d2104d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / sphinxcontrib_django-2.5-py3-none-any.whl
| Download URL | sphinxcontrib_django-2.5-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70148af4ccbb5184c5b1add939c3827c79a29a7d20ed18c25ceab347e3f14ca8
|
|
BLAKE2b-256 checksum How to use checksums |
453c2de4b64abb71cf0f27f9e4401695d8843efed9fdd89ab49957f157a23519
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for sphinxcontrib-django 2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.