File tree Expand file tree Collapse file tree 3 files changed +11
-13
lines changed
sphinxcontrib_django/docstrings Expand file tree Collapse file tree 3 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -31,20 +31,19 @@ def get_field_type(field, include_role=True):
3131 f":class:`~{ type (field ).__module__ } .{ type (field ).__name__ } ` to"
3232 f" :class:`~{ to .__module__ } .{ to .__name__ } `"
3333 )
34- elif isinstance (field , models .fields .reverse_related .ForeignObjectRel ):
34+ if isinstance (field , models .fields .reverse_related .ForeignObjectRel ):
3535 to = field .remote_field .model
3636 return (
3737 "Reverse"
3838 f" :class:`~{ type (field .remote_field ).__module__ } .{ type (field .remote_field ).__name__ } `"
3939 f" from :class:`~{ to .__module__ } .{ to .__name__ } `"
4040 )
41- else :
42- if include_role :
43- # For the docstrings of attributes, the :class: role is required
44- return f":class:`~{ type (field ).__module__ } .{ type (field ).__name__ } `"
45- else :
46- # For the :param: role in class docstrings, the :class: role is not required
47- return f"~{ type (field ).__module__ } .{ type (field ).__name__ } "
41+ if include_role :
42+ # For the docstrings of attributes, the :class: role is required
43+ return f":class:`~{ type (field ).__module__ } .{ type (field ).__name__ } `"
44+
45+ # For the :param: role in class docstrings, the :class: role is not required
46+ return f"~{ type (field ).__module__ } .{ type (field ).__name__ } "
4847
4948
5049def get_field_verbose_name (field ):
Original file line number Diff line number Diff line change 11"""
22This module contains patches for Django to improve its interaction with Sphinx.
33"""
4+ import contextlib
5+
46from django import apps , forms , test
57from django .db import models
68
@@ -84,10 +86,8 @@ def patch_django_for_autodoc():
8486 for parent_module_str , django_modules in DJANGO_MODULE_PATHS .items ():
8587 for django_module in django_modules :
8688 for module_class in map (django_module .__dict__ .get , django_module .__all__ ):
87- try :
89+ with contextlib . suppress ( AttributeError ) :
8890 module_class .__module__ = parent_module_str
89- except AttributeError :
90- pass
9191
9292 # Fix module path of model manager
9393 models .manager .Manager .__module__ = "django.db.models"
Original file line number Diff line number Diff line change @@ -43,8 +43,7 @@ def setup_app_with_different_config(app_params, make_app):
4343 def setup_app_with_different_config (** confoverrides ):
4444 args , kwargs = app_params
4545 kwargs ["confoverrides" ] = confoverrides
46- _app = make_app (* args , ** kwargs )
47- return _app
46+ return make_app (* args , ** kwargs )
4847
4948 return setup_app_with_different_config
5049
You can’t perform that action at this time.
0 commit comments