Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 84cfda6

Browse filesBrowse files
committed
Fix readthedocs build
- Update python version to 3.11 - Define fully qualified name for types
1 parent 91d3f83 commit 84cfda6
Copy full SHA for 84cfda6

File tree

7 files changed

+64
-22
lines changed
Filter options

7 files changed

+64
-22
lines changed

‎.readthedocs.yaml

Copy file name to clipboardExpand all lines: .readthedocs.yaml
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
# Required
66
version: 2
77

8+
# Set the OS, Python version and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.11"
13+
814
# Build documentation in the docs/ directory with Sphinx
915
sphinx:
1016
configuration: docs/conf.py

‎docs/conf.py

Copy file name to clipboardExpand all lines: docs/conf.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
# Warn about all references where the target cannot be found
3232
nitpicky = True
3333

34+
# A list of (type, target) tuples that should be ignored when :attr:`nitpicky` is ``True``
35+
nitpick_ignore = [("py:class", "sphinx.ext.autodoc.Options")]
36+
3437
# Add any paths that contain templates here, relative to this directory.
3538
templates_path = ["templates"]
3639

‎sphinxcontrib_django/__init__.py

Copy file name to clipboardExpand all lines: sphinxcontrib_django/__init__.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66

77
__version__ = "2.5"
88

9-
from sphinx.application import Sphinx
9+
from typing import TYPE_CHECKING
1010

1111
from . import docstrings, roles
1212

13+
if TYPE_CHECKING:
14+
import sphinx
1315

14-
def setup(app: Sphinx) -> dict:
16+
17+
def setup(app: sphinx.application.Sphinx) -> dict:
1518
"""
1619
Allow this module to be used as sphinx extension.
1720

‎sphinxcontrib_django/docstrings/__init__.py

Copy file name to clipboardExpand all lines: sphinxcontrib_django/docstrings/__init__.py
+15-7Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@
3131
from .methods import improve_method_docstring
3232

3333
if TYPE_CHECKING:
34-
from sphinx.application import Sphinx
35-
from sphinx.config import Config
36-
from sphinx.ext.autodoc import Options
34+
import sphinx
3735

3836

39-
def setup(app: Sphinx) -> dict:
37+
def setup(app: sphinx.application.Sphinx) -> dict:
4038
"""
4139
Allow this package to be used as Sphinx extension.
4240
@@ -93,7 +91,7 @@ def setup(app: Sphinx) -> dict:
9391
}
9492

9593

96-
def setup_django(app: Sphinx, config: Config) -> None:
94+
def setup_django(app: sphinx.application.Sphinx, config: sphinx.config.Config) -> None:
9795
"""
9896
This function calls :func:`django.setup` so it doesn't have to be done in the app's
9997
``conf.py``.
@@ -127,7 +125,12 @@ def setup_django(app: Sphinx, config: Config) -> None:
127125

128126

129127
def autodoc_skip(
130-
app: Sphinx, what: str, name: str, obj: object, options: Options, lines: list[str]
128+
app: sphinx.application.Sphinx,
129+
what: str,
130+
name: str,
131+
obj: object,
132+
options: sphinx.ext.autodoc.Options,
133+
lines: list[str],
131134
) -> bool | None:
132135
"""
133136
Hook to tell autodoc to include or exclude certain fields (see :event:`autodoc-skip-member`).
@@ -151,7 +154,12 @@ def autodoc_skip(
151154

152155

153156
def improve_docstring(
154-
app: Sphinx, what: str, name: str, obj: object, options: Options, lines: list[str]
157+
app: sphinx.application.Sphinx,
158+
what: str,
159+
name: str,
160+
obj: object,
161+
options: sphinx.ext.autodoc.Options,
162+
lines: list[str],
155163
) -> list[str]:
156164
"""
157165
Hook to improve the autodoc docstrings for Django models

‎sphinxcontrib_django/docstrings/classes.py

Copy file name to clipboardExpand all lines: sphinxcontrib_django/docstrings/classes.py
+17-6Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,22 @@
33
"""
44
from __future__ import annotations
55

6+
from typing import TYPE_CHECKING
7+
68
from django import forms
79
from django.db import models
8-
from sphinx.application import Sphinx
910
from sphinx.pycode import ModuleAnalyzer
1011

1112
from .field_utils import get_field_type, get_field_verbose_name
1213

14+
if TYPE_CHECKING:
15+
import django
16+
import sphinx
17+
1318

14-
def improve_class_docstring(app: Sphinx, cls: type, lines: list[str]) -> None:
19+
def improve_class_docstring(
20+
app: sphinx.application.Sphinx, cls: type, lines: list[str]
21+
) -> None:
1522
"""
1623
Improve the documentation of a class if it's a Django model or form
1724
@@ -25,7 +32,9 @@ def improve_class_docstring(app: Sphinx, cls: type, lines: list[str]) -> None:
2532
improve_form_docstring(cls, lines)
2633

2734

28-
def improve_model_docstring(app: Sphinx, model: models.Model, lines: list[str]) -> None:
35+
def improve_model_docstring(
36+
app: sphinx.application.Sphinx, model: django.db.models.Model, lines: list[str]
37+
) -> None:
2938
"""
3039
Improve the documentation of a Django :class:`~django.db.models.Model` subclass.
3140
@@ -109,7 +118,9 @@ def improve_model_docstring(app: Sphinx, model: models.Model, lines: list[str])
109118
lines.append("")
110119

111120

112-
def add_db_table_name(app: Sphinx, model: models.Model, lines: list[str]) -> None:
121+
def add_db_table_name(
122+
app: sphinx.application.Sphinx, model: django.db.models.Model, lines: list[str]
123+
) -> None:
113124
"""
114125
Format and add table name by extension configuration.
115126
@@ -126,7 +137,7 @@ def add_db_table_name(app: Sphinx, model: models.Model, lines: list[str]) -> Non
126137

127138

128139
def add_model_parameters(
129-
fields: list[models.Field], lines: list[str], field_docs: dict
140+
fields: list[django.db.models.Field], lines: list[str], field_docs: dict
130141
) -> None:
131142
"""
132143
Add the given fields as model parameter with the ``:param:`` directive
@@ -151,7 +162,7 @@ def add_model_parameters(
151162
lines.append(f":type {field.name}: {get_field_type(field, include_role=False)}")
152163

153164

154-
def improve_form_docstring(form: forms.Form, lines: list[str]) -> None:
165+
def improve_form_docstring(form: django.forms.Form, lines: list[str]) -> None:
155166
"""
156167
Improve the documentation of a Django :class:`~django.forms.Form` class.
157168
This highlights the available fields in the form.

‎sphinxcontrib_django/docstrings/field_utils.py

Copy file name to clipboardExpand all lines: sphinxcontrib_django/docstrings/field_utils.py
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
"""
66
from __future__ import annotations
77

8+
from typing import TYPE_CHECKING
9+
810
from django.apps import apps
911
from django.contrib import contenttypes
1012
from django.db import models
1113
from django.utils.encoding import force_str
1214

15+
if TYPE_CHECKING:
16+
import django
17+
1318

14-
def get_field_type(field: models.Field, include_role: bool = True) -> str:
19+
def get_field_type(field: django.db.models.Field, include_role: bool = True) -> str:
1520
"""
1621
Get the type of a field including the correct intersphinx mappings.
1722
@@ -43,7 +48,7 @@ def get_field_type(field: models.Field, include_role: bool = True) -> str:
4348
return f"~{type(field).__module__}.{type(field).__name__}"
4449

4550

46-
def get_field_verbose_name(field: models.Field) -> str:
51+
def get_field_verbose_name(field: django.db.models.Field) -> str:
4752
"""
4853
Get the verbose name of the field.
4954
If the field has a ``help_text``, it is also included.
@@ -133,7 +138,9 @@ def get_field_verbose_name(field: models.Field) -> str:
133138
return verbose_name
134139

135140

136-
def get_model_from_string(field: models.Field, model_string: str) -> type[models.Model]:
141+
def get_model_from_string(
142+
field: django.db.models.Field, model_string: str
143+
) -> type[django.db.models.Model]:
137144
"""
138145
Get a model class from a string
139146

‎sphinxcontrib_django/roles.py

Copy file name to clipboardExpand all lines: sphinxcontrib_django/roles.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@
2424
from __future__ import annotations
2525

2626
import logging
27+
from typing import TYPE_CHECKING
2728

28-
from sphinx.application import Sphinx
29-
from sphinx.config import Config
3029
from sphinx.errors import ExtensionError
3130

3231
from . import __version__
3332

33+
if TYPE_CHECKING:
34+
import sphinx
35+
3436
logger = logging.getLogger(__name__)
3537

3638

37-
def setup(app: Sphinx) -> dict:
39+
def setup(app: sphinx.application.Sphinx) -> dict:
3840
"""
3941
Allow this module to be used as Sphinx extension.
4042
@@ -68,7 +70,9 @@ def setup(app: Sphinx) -> dict:
6870
}
6971

7072

71-
def add_default_intersphinx_mappings(app: Sphinx, config: Config) -> None:
73+
def add_default_intersphinx_mappings(
74+
app: sphinx.application.Sphinx, config: sphinx.config.Config
75+
) -> None:
7276
"""
7377
This function provides a default intersphinx mapping to the documentations of Python, Django
7478
and Sphinx if ``intersphinx_mapping`` is not given in ``conf.py``.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.