Skip to content

Commit 4a3e78e

Browse files
feanilsarina
authored andcommitted
build: Don't try to read the database when building docs.
Sphinx tries to explore all the defined objects when trying to generate docs from the code. When it tries to introspect the QuerySet object, it results in that object trying to query the database which we don't really want to setup for a docs build as it's not relevant and fairly expensive to do. To circumvent this issue, we add a new filter to the docs build that essentially skips further introspection of QuerySet objects.
1 parent 5b19512 commit 4a3e78e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

docs/conf.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import django
1515
import git
16+
from django.db.models.query import QuerySet
1617

1718
from path import Path
1819

@@ -379,7 +380,14 @@ def on_init(app): # lint-amnesty, pylint: disable=redefined-outer-name, unused-
379380
check_call(args)
380381

381382

383+
def skip_querysets(app, what, name, obj, skip, options):
384+
# If the object is a Django QuerySet, skip it
385+
if isinstance(obj, QuerySet):
386+
return True
387+
return skip
388+
389+
382390
def setup(app): # lint-amnesty, pylint: disable=redefined-outer-name
383391
"""Sphinx extension: run sphinx-apidoc."""
384-
event = 'builder-inited'
385-
app.connect(event, on_init)
392+
app.connect('builder-inited', on_init)
393+
app.connect('autodoc-skip-member', skip_querysets)

0 commit comments

Comments
 (0)