Unable to build documentation for Django project
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Description
Hi there.
I am trying to build the documentation for our package.
It fails with either opening the development server or by trying to build the documention.
I am doing pdoc --http : <package> --config show_source_code=False
or
pdoc --html --config show_source_code=False <package>/
Both result in this traceback. Does Pdoc not work with Django? I'm sure it did work last time I had tried to generate documentation for my Django project.
/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/pdoc/cli.py:532: UserWarning: Couldn't read PEP-224 variable docstrings from <Module 'module'>: could not get source code
modules = [pdoc.Module(module, docfilter=docfilter,
Traceback (most recent call last):
File "/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/pdoc/__init__.py", line 225, in import_module
module = importlib.import_module(module_path)
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/django/db/models/base.py", line 108, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/django/apps/registry.py", line 252, in get_containing_app_config
self.check_apps_ready()
File "/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/django/apps/registry.py", line 134, in check_apps_ready
settings.INSTALLED_APPS
File "/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 83, in __getattr__
self._setup(name)
File "/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 64, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: 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.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jacob/.virtualenvs/venv/bin/pdoc", line 33, in <module>
sys.exit(load_entry_point('pdoc3==0.9.2', 'console_scripts', 'pdoc')())
File "/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/pdoc/cli.py", line 532, in main
modules = [pdoc.Module(module, docfilter=docfilter,
File "/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/pdoc/cli.py", line 532, in <listcomp>
modules = [pdoc.Module(module, docfilter=docfilter,
File "/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/pdoc/__init__.py", line 708, in __init__
m = Module(import_module(fullname),
File "/home/jacob/.virtualenvs/venv/lib/python3.9/site-packages/pdoc/__init__.py", line 227, in import_module
raise ImportError('Error importing {!r}: {}: {}'
ImportError: Error importing 'module': ImproperlyConfigured: 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two pdoc commands from the issue with a Django project and inspect pdoc/cli.py and pdoc/init.py, especially import_module. Determine how Django settings affect module importing and documentation generation. Done means the failure is fixed or the supported configuration and limitation are clearly established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100