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 0421d7e

Browse filesBrowse files
authored
Merge pull request #52 from edoburu/bugfix/inheritance-diagram
Fix rendering of inheritance diagrams
2 parents c26bf9f + be8c151 commit 0421d7e
Copy full SHA for 0421d7e

File tree

5 files changed

+25
-2
lines changed
Filter options

5 files changed

+25
-2
lines changed

‎CHANGES.rst

Copy file name to clipboardExpand all lines: CHANGES.rst
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Unreleased
55
----------
66

77
* Drop support for sphinx < 3.4.0
8+
* [ `#45 <https://github.com/edoburu/sphinxcontrib-django/issues/45>`_ ] Fix rendering of inheritance diagrams
89

910

1011
Version 2.4 (2023-07-02)

‎sphinxcontrib_django/docstrings/classes.py

Copy file name to clipboardExpand all lines: sphinxcontrib_django/docstrings/classes.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ def improve_model_docstring(app: Sphinx, model: models.Model, lines: list[str])
104104
and "sphinx.ext.graphviz" in app.extensions
105105
and not any("inheritance-diagram::" in line for line in lines)
106106
):
107-
lines.append(".. inheritance-diagram::") # pragma: no cover
107+
lines.append("")
108+
lines.append(f".. inheritance-diagram:: {model.__module__}.{model.__name__}")
109+
lines.append("")
108110

109111

110112
def add_db_table_name(app: Sphinx, model: models.Model, lines: list[str]) -> None:

‎tests/roots/test-docstrings/conf.py

Copy file name to clipboardExpand all lines: tests/roots/test-docstrings/conf.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
sys.path.insert(0, os.path.abspath("."))
66

77
project = "sphinx dummy Test"
8-
extensions = ["sphinxcontrib_django"]
8+
extensions = [
9+
"sphinxcontrib_django",
10+
"sphinx.ext.graphviz",
11+
"sphinx.ext.inheritance_diagram",
12+
]
913

1014
# Configure Django settings module
1115
django_settings = "dummy_django_app.settings"

‎tests/test_class_docstrings.py

Copy file name to clipboardExpand all lines: tests/test_class_docstrings.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def test_simple_model(app, do_autodoc):
8181
" :class:`~dummy_django_app.models.ChildModelB`"
8282
),
8383
"",
84+
" .. inheritance-diagram:: dummy_django_app.models.SimpleModel",
85+
"",
8486
]
8587

8688

@@ -168,6 +170,8 @@ def test_database_table(app, do_autodoc):
168170
" :class:`~dummy_django_app.models.ChildModelB`"
169171
),
170172
"",
173+
" .. inheritance-diagram:: dummy_django_app.models.SimpleModel",
174+
"",
171175
]
172176

173177

@@ -199,6 +203,8 @@ def test_abstract_model(app, do_autodoc):
199203
" :class:`~dummy_django_app.models.AbstractModel`"
200204
),
201205
"",
206+
" .. inheritance-diagram:: dummy_django_app.models.AbstractModel",
207+
"",
202208
]
203209

204210

@@ -232,6 +238,8 @@ def test_abstract_model_with_tables_names_and_ignore_abstract(app, do_autodoc):
232238
" :class:`~dummy_django_app.models.AbstractModel`"
233239
),
234240
"",
241+
" .. inheritance-diagram:: dummy_django_app.models.AbstractModel",
242+
"",
235243
]
236244

237245

@@ -272,6 +280,8 @@ def test_abstract_model_with_tables_names_and_abstract_show(app, do_autodoc):
272280
" :class:`~dummy_django_app.models.AbstractModel`"
273281
),
274282
"",
283+
" .. inheritance-diagram:: dummy_django_app.models.AbstractModel",
284+
"",
275285
]
276286

277287

@@ -300,6 +310,8 @@ def test_file_model(app, do_autodoc):
300310
" :class:`~dummy_django_app.models.SimpleModel`"
301311
),
302312
"",
313+
" .. inheritance-diagram:: dummy_django_app.models.FileModel",
314+
"",
303315
]
304316

305317

@@ -339,6 +351,8 @@ def test_tagged_item(app, do_autodoc):
339351
" :class:`~django.contrib.contenttypes.models.ContentType`"
340352
),
341353
"",
354+
" .. inheritance-diagram:: dummy_django_app.models.TaggedItem",
355+
"",
342356
]
343357

344358

‎tests/test_django_configured.py

Copy file name to clipboardExpand all lines: tests/test_django_configured.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ def test_django_configured(app, do_autodoc):
1515
" :param id: Primary key: ID",
1616
" :type id: ~django.db.models.AutoField",
1717
"",
18+
" .. inheritance-diagram:: dummy_django_app.models.MonkeyPatched",
19+
"",
1820
]

0 commit comments

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