We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add contribution guide to documentation
Add a guide to the documentation which explains how to contribute to this project.

It should contain the following:

- [x] Bug Reporting Guide
- [x] Code Style Guide
- [x] GitHub Workflow Guide
- [x] Code of Conduct

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sphinx/conf.py`
Content:
```
1 """
2 Configuration file for the Sphinx documentation builder.
3 
4 This file only contains a selection of the most common options. For a full
5 list see the documentation:
6 https://www.sphinx-doc.org/en/master/usage/configuration.html
7 """
8 
9 # -- Path setup --------------------------------------------------------------
10 
11 import os
12 import sys
13 import inspect
14 import importlib
15 import django
16 
17 from sphinx.writers.html import HTMLTranslator
18 
19 from backend.settings import VERSION
20 
21 # Append project source directory to path environment variable
22 sys.path.append(os.path.abspath('../src/'))
23 os.environ['DJANGO_SETTINGS_MODULE'] = 'backend.settings'
24 
25 
26 # Setup Django
27 django.setup()
28 
29 
30 def setup(app):
31     """
32     Registeration and setup.
33 
34     This method does the initial setup for the docs generation.
35     """
36     # Register the docstring processor with sphinx to improve the appearance of Django models
37     app.connect('autodoc-process-docstring', process_django_models)
38     # Patch HTMLTranslator to open external links in new tab
39     app.set_translator('html', PatchedHTMLTranslator)
40 
41 
42 # -- Project information -----------------------------------------------------
43 
44 
45 project = 'integreat-cms'
46 # pylint: disable=redefined-builtin
47 copyright = '2020, Integreat'
48 author = 'Integreat'
49 
50 # The full version, including alpha/beta/rc tags
51 release = VERSION
52 
53 # -- General configuration ---------------------------------------------------
54 
55 # All enabled sphinx extensions
56 extensions = [
57     'sphinx.ext.autodoc',
58     'sphinx.ext.githubpages',
59     'sphinx.ext.intersphinx',
60     'sphinx.ext.linkcode',
61     'sphinxcontrib_django',
62     'sphinx_rtd_theme',
63 ]
64 
65 # Enable cross-references to other documentations
66 intersphinx_mapping = {
67     'python': ('https://docs.python.org/3.7', None),
68     'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
69     'django': ('https://docs.djangoproject.com/en/2.2/',
70                'https://docs.djangoproject.com/en/2.2/_objects/'),
71     'django-mptt': ('https://django-mptt.readthedocs.io/en/latest/', None),
72 }
73 
74 # The path for patched template files
75 templates_path = ['templates']
76 
77 # -- Options for HTML output -------------------------------------------------
78 
79 # The theme to use for HTML and HTML Help pages.
80 html_theme = 'sphinx_rtd_theme'
81 # Do not show the project name, only the logo
82 html_theme_options = {
83     'logo_only': True,
84     'collapse_navigation': False,
85 }
86 # The logo shown in the menu bar
87 html_logo = '../src/cms/static/images/integreat-logo-white.png'
88 # The facivon of the html doc files
89 html_favicon = '../src/cms/static/images/favicon.ico'
90 # The url where the docs should be published (via gh-pages)
91 html_baseurl = 'https://Integreat.github.io/cms-django/'
92 # Do not include links to the documentation source (.rst files) in build
93 html_show_sourcelink = False
94 
95 # -- Modify default Django model parameter types------------------------------
96 
97 
98 # pylint: disable=unused-argument, too-many-locals, too-many-branches
99 def process_django_models(app, what, name, obj, options, lines):
100     """Append correct param types from fields to model documentation."""
101     if inspect.isclass(obj) and issubclass(obj, django.db.models.Model):
102         # Intersphinx mapping to django.contrib.postgres documentation does not work, so here the manual link
103         postgres_docu = intersphinx_mapping.get('django')[1][0] + 'ref/contrib/postgres/fields/'
104         # include_hidden to get also ManyToManyFields
105         for field in obj._meta.get_fields(include_hidden=True):
106             field_type = type(field).__name__
107             field_module = type(field).__module__
108             if field_module == 'django.contrib.postgres.fields.array':
109                 # Fix intersphinx mappings for django.contrib.postgres fields
110                 type_line = f':type {field.name}: `{field_module}.ArrayField <{postgres_docu}#arrayfield>`_'
111             elif field_module == 'django.contrib.postgres.fields.jsonb':
112                 # Fix intersphinx mappings for django.contrib.postgres fields
113                 type_line = f':type {field.name}: `{field_module}.JSONField <{postgres_docu}#jsonfield>`_'
114             elif field_module in ['django.db.models.fields.related', 'mptt.fields']:
115                 # Fix intersphinx mappings for related fields (ForeignKey, OneToOneField, ManyToManyField, ...)
116                 # Also includes related MPTT fields (TreeForeignKey, TreeOneToOneField, TreeManyToManyField, ...)
117                 remote_model = field.remote_field.get_related_field().model
118                 type_line = f':type {field.name}: {field_type} to :class:`~{remote_model.__module__}.{remote_model.__name__}`'
119             elif field_module == 'django.db.models.fields.reverse_related':
120                 # Fix intersphinx mappings for reverse related fields (ManyToOneRel, OneToOneRel, ManyToManyRel, ...)
121                 remote_model = field.remote_field.model
122                 type_line = f':type {field.name}: Reverse {field_type[:-3]} Relation from :class:`~{remote_model.__module__}.{remote_model.__name__}`'
123             else:
124                 if 'django.db.models' in field_module:
125                     # Scope with django.db.models * imports (remove all sub-module-paths)
126                     field_module = 'django.db.models'
127                 # Fix type hint to enable correct intersphinx mappings to other documentations
128                 type_line = f':type {field.name}: {field_module}.{field_type}'
129             # This loop gets the indexes which are needed to update the type hints of the model parameters.
130             # It makes it possible to split the parameter section into multiple parts, e.g. params inherited from a base
131             # model and params of a sub model (otherwise the type hints would not be recognized when separated from
132             # the parameter description).
133             param_index = None
134             next_param_index = None
135             type_index = None
136             for index, line in enumerate(lines):
137                 if param_index is None and f':param {field.name}:' in line:
138                     # The index of the field param is only used to determine the next param line
139                     param_index = index
140                 elif param_index is not None and next_param_index is None and (':param ' in line or line == ''):
141                     # The line of the next param after the field, this is the index where we will insert the type.
142                     # Sometimes the param descriptions extend over multiple lines, so we cannot just do param_index + 1.
143                     # If the line is empty, the param description is finished, even if it extends over multiple lines.
144                     next_param_index = index
145                 elif type_index is None and f':type {field.name}:' in line:
146                     # The index of the old type hint, we will either move this line or replace it
147                     type_index = index
148                     break
149             if next_param_index is None:
150                 # In case the current field is the last param, we just append the type at the very end of lines
151                 next_param_index = len(lines)
152             # For some params, the type line is not automatically generated and thus the type_index might be `None`
153             if type_index is not None:
154                 # We delete the old type index, because we will replace it with the new type line
155                 del lines[type_index]
156             # Insert the new type line just before the next param
157             lines.insert(next_param_index, type_line)
158     return lines
159 
160 
161 # -- Source Code links to GitHub ---------------------------------------------
162 
163 
164 def linkcode_resolve(domain, info):
165     """Link source code to GitHub."""
166     if domain != 'py' or not info['module']:
167         return None
168     filename = info['module'].replace('.', '/')
169     module = importlib.import_module(info['module'])
170     basename = os.path.splitext(module.__file__)[0]
171     if basename.endswith('__init__'):
172         filename += '/__init__'
173     item = module
174     line_number_reference = ''
175     for piece in info['fullname'].split('.'):
176         item = getattr(item, piece)
177         try:
178             line_number_reference = f'#L{inspect.getsourcelines(item)[1]}'
179         except (TypeError, IOError):
180             pass
181     return f"https://github.com/Integreat/cms-django/blob/develop/src/{filename}.py{line_number_reference}"
182 
183 # -- Link targets ------------------------------------------------------------
184 
185 
186 # pylint: disable=abstract-method
187 class PatchedHTMLTranslator(HTMLTranslator):
188     """Open external links in a new tab"""
189 
190     def visit_reference(self, node):
191         if (
192                 node.get('newtab') or
193                 not (
194                     node.get('target') or
195                     node.get('internal') or
196                     'refuri' not in node
197                 )
198         ):
199             node['target'] = '_blank'
200         super().visit_reference(node)
201
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sphinx/conf.py b/sphinx/conf.py
--- a/sphinx/conf.py
+++ b/sphinx/conf.py
@@ -65,7 +65,9 @@
 # Enable cross-references to other documentations
 intersphinx_mapping = {
     'python': ('https://docs.python.org/3.7', None),
+    'pipenv': ('https://pipenv.pypa.io/en/latest/', None),
     'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
+    'sphinx-rtd-tutorial': ('https://sphinx-rtd-tutorial.readthedocs.io/en/latest/', None),
     'django': ('https://docs.djangoproject.com/en/2.2/',
                'https://docs.djangoproject.com/en/2.2/_objects/'),
     'django-mptt': ('https://django-mptt.readthedocs.io/en/latest/', None),
@@ -80,7 +82,7 @@
 html_theme = 'sphinx_rtd_theme'
 # Do not show the project name, only the logo
 html_theme_options = {
-    'logo_only': True,
+    'logo_only': False,
     'collapse_navigation': False,
 }
 # The logo shown in the menu bar
@@ -91,6 +93,10 @@
 html_baseurl = 'https://Integreat.github.io/cms-django/'
 # Do not include links to the documentation source (.rst files) in build
 html_show_sourcelink = False
+# Do not include a link to sphinx
+html_show_sphinx = False
+# Include last updated timestamp
+html_last_updated_fmt = '%b %d, %Y'
 
 # -- Modify default Django model parameter types------------------------------

{"golden_diff": "diff --git a/sphinx/conf.py b/sphinx/conf.py\n--- a/sphinx/conf.py\n+++ b/sphinx/conf.py\n@@ -65,7 +65,9 @@\n # Enable cross-references to other documentations\n intersphinx_mapping = {\n     'python': ('https://docs.python.org/3.7', None),\n+    'pipenv': ('https://pipenv.pypa.io/en/latest/', None),\n     'sphinx': ('https://www.sphinx-doc.org/en/master/', None),\n+    'sphinx-rtd-tutorial': ('https://sphinx-rtd-tutorial.readthedocs.io/en/latest/', None),\n     'django': ('https://docs.djangoproject.com/en/2.2/',\n                'https://docs.djangoproject.com/en/2.2/_objects/'),\n     'django-mptt': ('https://django-mptt.readthedocs.io/en/latest/', None),\n@@ -80,7 +82,7 @@\n html_theme = 'sphinx_rtd_theme'\n # Do not show the project name, only the logo\n html_theme_options = {\n-    'logo_only': True,\n+    'logo_only': False,\n     'collapse_navigation': False,\n }\n # The logo shown in the menu bar\n@@ -91,6 +93,10 @@\n html_baseurl = 'https://Integreat.github.io/cms-django/'\n # Do not include links to the documentation source (.rst files) in build\n html_show_sourcelink = False\n+# Do not include a link to sphinx\n+html_show_sphinx = False\n+# Include last updated timestamp\n+html_last_updated_fmt = '%b %d, %Y'\n \n # -- Modify default Django model parameter types------------------------------\n", "issue": "Add contribution guide to documentation\nAdd a guide to the documentation which explains how to contribute to this project.\r\n\r\nIt should contain the following:\r\n\r\n- [x] Bug Reporting Guide\r\n- [x] Code Style Guide\r\n- [x] GitHub Workflow Guide\r\n- [x] Code of Conduct\n", "before_files": [{"content": "\"\"\"\nConfiguration file for the Sphinx documentation builder.\n\nThis file only contains a selection of the most common options. For a full\nlist see the documentation:\nhttps://www.sphinx-doc.org/en/master/usage/configuration.html\n\"\"\"\n\n# -- Path setup --------------------------------------------------------------\n\nimport os\nimport sys\nimport inspect\nimport importlib\nimport django\n\nfrom sphinx.writers.html import HTMLTranslator\n\nfrom backend.settings import VERSION\n\n# Append project source directory to path environment variable\nsys.path.append(os.path.abspath('../src/'))\nos.environ['DJANGO_SETTINGS_MODULE'] = 'backend.settings'\n\n\n# Setup Django\ndjango.setup()\n\n\ndef setup(app):\n    \"\"\"\n    Registeration and setup.\n\n    This method does the initial setup for the docs generation.\n    \"\"\"\n    # Register the docstring processor with sphinx to improve the appearance of Django models\n    app.connect('autodoc-process-docstring', process_django_models)\n    # Patch HTMLTranslator to open external links in new tab\n    app.set_translator('html', PatchedHTMLTranslator)\n\n\n# -- Project information -----------------------------------------------------\n\n\nproject = 'integreat-cms'\n# pylint: disable=redefined-builtin\ncopyright = '2020, Integreat'\nauthor = 'Integreat'\n\n# The full version, including alpha/beta/rc tags\nrelease = VERSION\n\n# -- General configuration ---------------------------------------------------\n\n# All enabled sphinx extensions\nextensions = [\n    'sphinx.ext.autodoc',\n    'sphinx.ext.githubpages',\n    'sphinx.ext.intersphinx',\n    'sphinx.ext.linkcode',\n    'sphinxcontrib_django',\n    'sphinx_rtd_theme',\n]\n\n# Enable cross-references to other documentations\nintersphinx_mapping = {\n    'python': ('https://docs.python.org/3.7', None),\n    'sphinx': ('https://www.sphinx-doc.org/en/master/', None),\n    'django': ('https://docs.djangoproject.com/en/2.2/',\n               'https://docs.djangoproject.com/en/2.2/_objects/'),\n    'django-mptt': ('https://django-mptt.readthedocs.io/en/latest/', None),\n}\n\n# The path for patched template files\ntemplates_path = ['templates']\n\n# -- Options for HTML output -------------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.\nhtml_theme = 'sphinx_rtd_theme'\n# Do not show the project name, only the logo\nhtml_theme_options = {\n    'logo_only': True,\n    'collapse_navigation': False,\n}\n# The logo shown in the menu bar\nhtml_logo = '../src/cms/static/images/integreat-logo-white.png'\n# The facivon of the html doc files\nhtml_favicon = '../src/cms/static/images/favicon.ico'\n# The url where the docs should be published (via gh-pages)\nhtml_baseurl = 'https://Integreat.github.io/cms-django/'\n# Do not include links to the documentation source (.rst files) in build\nhtml_show_sourcelink = False\n\n# -- Modify default Django model parameter types------------------------------\n\n\n# pylint: disable=unused-argument, too-many-locals, too-many-branches\ndef process_django_models(app, what, name, obj, options, lines):\n    \"\"\"Append correct param types from fields to model documentation.\"\"\"\n    if inspect.isclass(obj) and issubclass(obj, django.db.models.Model):\n        # Intersphinx mapping to django.contrib.postgres documentation does not work, so here the manual link\n        postgres_docu = intersphinx_mapping.get('django')[1][0] + 'ref/contrib/postgres/fields/'\n        # include_hidden to get also ManyToManyFields\n        for field in obj._meta.get_fields(include_hidden=True):\n            field_type = type(field).__name__\n            field_module = type(field).__module__\n            if field_module == 'django.contrib.postgres.fields.array':\n                # Fix intersphinx mappings for django.contrib.postgres fields\n                type_line = f':type {field.name}: `{field_module}.ArrayField <{postgres_docu}#arrayfield>`_'\n            elif field_module == 'django.contrib.postgres.fields.jsonb':\n                # Fix intersphinx mappings for django.contrib.postgres fields\n                type_line = f':type {field.name}: `{field_module}.JSONField <{postgres_docu}#jsonfield>`_'\n            elif field_module in ['django.db.models.fields.related', 'mptt.fields']:\n                # Fix intersphinx mappings for related fields (ForeignKey, OneToOneField, ManyToManyField, ...)\n                # Also includes related MPTT fields (TreeForeignKey, TreeOneToOneField, TreeManyToManyField, ...)\n                remote_model = field.remote_field.get_related_field().model\n                type_line = f':type {field.name}: {field_type} to :class:`~{remote_model.__module__}.{remote_model.__name__}`'\n            elif field_module == 'django.db.models.fields.reverse_related':\n                # Fix intersphinx mappings for reverse related fields (ManyToOneRel, OneToOneRel, ManyToManyRel, ...)\n                remote_model = field.remote_field.model\n                type_line = f':type {field.name}: Reverse {field_type[:-3]} Relation from :class:`~{remote_model.__module__}.{remote_model.__name__}`'\n            else:\n                if 'django.db.models' in field_module:\n                    # Scope with django.db.models * imports (remove all sub-module-paths)\n                    field_module = 'django.db.models'\n                # Fix type hint to enable correct intersphinx mappings to other documentations\n                type_line = f':type {field.name}: {field_module}.{field_type}'\n            # This loop gets the indexes which are needed to update the type hints of the model parameters.\n            # It makes it possible to split the parameter section into multiple parts, e.g. params inherited from a base\n            # model and params of a sub model (otherwise the type hints would not be recognized when separated from\n            # the parameter description).\n            param_index = None\n            next_param_index = None\n            type_index = None\n            for index, line in enumerate(lines):\n                if param_index is None and f':param {field.name}:' in line:\n                    # The index of the field param is only used to determine the next param line\n                    param_index = index\n                elif param_index is not None and next_param_index is None and (':param ' in line or line == ''):\n                    # The line of the next param after the field, this is the index where we will insert the type.\n                    # Sometimes the param descriptions extend over multiple lines, so we cannot just do param_index + 1.\n                    # If the line is empty, the param description is finished, even if it extends over multiple lines.\n                    next_param_index = index\n                elif type_index is None and f':type {field.name}:' in line:\n                    # The index of the old type hint, we will either move this line or replace it\n                    type_index = index\n                    break\n            if next_param_index is None:\n                # In case the current field is the last param, we just append the type at the very end of lines\n                next_param_index = len(lines)\n            # For some params, the type line is not automatically generated and thus the type_index might be `None`\n            if type_index is not None:\n                # We delete the old type index, because we will replace it with the new type line\n                del lines[type_index]\n            # Insert the new type line just before the next param\n            lines.insert(next_param_index, type_line)\n    return lines\n\n\n# -- Source Code links to GitHub ---------------------------------------------\n\n\ndef linkcode_resolve(domain, info):\n    \"\"\"Link source code to GitHub.\"\"\"\n    if domain != 'py' or not info['module']:\n        return None\n    filename = info['module'].replace('.', '/')\n    module = importlib.import_module(info['module'])\n    basename = os.path.splitext(module.__file__)[0]\n    if basename.endswith('__init__'):\n        filename += '/__init__'\n    item = module\n    line_number_reference = ''\n    for piece in info['fullname'].split('.'):\n        item = getattr(item, piece)\n        try:\n            line_number_reference = f'#L{inspect.getsourcelines(item)[1]}'\n        except (TypeError, IOError):\n            pass\n    return f\"https://github.com/Integreat/cms-django/blob/develop/src/{filename}.py{line_number_reference}\"\n\n# -- Link targets ------------------------------------------------------------\n\n\n# pylint: disable=abstract-method\nclass PatchedHTMLTranslator(HTMLTranslator):\n    \"\"\"Open external links in a new tab\"\"\"\n\n    def visit_reference(self, node):\n        if (\n                node.get('newtab') or\n                not (\n                    node.get('target') or\n                    node.get('internal') or\n                    'refuri' not in node\n                )\n        ):\n            node['target'] = '_blank'\n        super().visit_reference(node)\n", "path": "sphinx/conf.py"}], "after_files": [{"content": "\"\"\"\nConfiguration file for the Sphinx documentation builder.\n\nThis file only contains a selection of the most common options. For a full\nlist see the documentation:\nhttps://www.sphinx-doc.org/en/master/usage/configuration.html\n\"\"\"\n\n# -- Path setup --------------------------------------------------------------\n\nimport os\nimport sys\nimport inspect\nimport importlib\nimport django\n\nfrom sphinx.writers.html import HTMLTranslator\n\nfrom backend.settings import VERSION\n\n# Append project source directory to path environment variable\nsys.path.append(os.path.abspath('../src/'))\nos.environ['DJANGO_SETTINGS_MODULE'] = 'backend.settings'\n\n\n# Setup Django\ndjango.setup()\n\n\ndef setup(app):\n    \"\"\"\n    Registeration and setup.\n\n    This method does the initial setup for the docs generation.\n    \"\"\"\n    # Register the docstring processor with sphinx to improve the appearance of Django models\n    app.connect('autodoc-process-docstring', process_django_models)\n    # Patch HTMLTranslator to open external links in new tab\n    app.set_translator('html', PatchedHTMLTranslator)\n\n\n# -- Project information -----------------------------------------------------\n\n\nproject = 'integreat-cms'\n# pylint: disable=redefined-builtin\ncopyright = '2020, Integreat'\nauthor = 'Integreat'\n\n# The full version, including alpha/beta/rc tags\nrelease = VERSION\n\n# -- General configuration ---------------------------------------------------\n\n# All enabled sphinx extensions\nextensions = [\n    'sphinx.ext.autodoc',\n    'sphinx.ext.githubpages',\n    'sphinx.ext.intersphinx',\n    'sphinx.ext.linkcode',\n    'sphinxcontrib_django',\n    'sphinx_rtd_theme',\n]\n\n# Enable cross-references to other documentations\nintersphinx_mapping = {\n    'python': ('https://docs.python.org/3.7', None),\n    'pipenv': ('https://pipenv.pypa.io/en/latest/', None),\n    'sphinx': ('https://www.sphinx-doc.org/en/master/', None),\n    'sphinx-rtd-tutorial': ('https://sphinx-rtd-tutorial.readthedocs.io/en/latest/', None),\n    'django': ('https://docs.djangoproject.com/en/2.2/',\n               'https://docs.djangoproject.com/en/2.2/_objects/'),\n    'django-mptt': ('https://django-mptt.readthedocs.io/en/latest/', None),\n}\n\n# The path for patched template files\ntemplates_path = ['templates']\n\n# -- Options for HTML output -------------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.\nhtml_theme = 'sphinx_rtd_theme'\n# Do not show the project name, only the logo\nhtml_theme_options = {\n    'logo_only': False,\n    'collapse_navigation': False,\n}\n# The logo shown in the menu bar\nhtml_logo = '../src/cms/static/images/integreat-logo-white.png'\n# The facivon of the html doc files\nhtml_favicon = '../src/cms/static/images/favicon.ico'\n# The url where the docs should be published (via gh-pages)\nhtml_baseurl = 'https://Integreat.github.io/cms-django/'\n# Do not include links to the documentation source (.rst files) in build\nhtml_show_sourcelink = False\n# Do not include a link to sphinx\nhtml_show_sphinx = False\n# Include last updated timestamp\nhtml_last_updated_fmt = '%b %d, %Y'\n\n# -- Modify default Django model parameter types------------------------------\n\n\n# pylint: disable=unused-argument, too-many-locals, too-many-branches\ndef process_django_models(app, what, name, obj, options, lines):\n    \"\"\"Append correct param types from fields to model documentation.\"\"\"\n    if inspect.isclass(obj) and issubclass(obj, django.db.models.Model):\n        # Intersphinx mapping to django.contrib.postgres documentation does not work, so here the manual link\n        postgres_docu = intersphinx_mapping.get('django')[1][0] + 'ref/contrib/postgres/fields/'\n        # include_hidden to get also ManyToManyFields\n        for field in obj._meta.get_fields(include_hidden=True):\n            field_type = type(field).__name__\n            field_module = type(field).__module__\n            if field_module == 'django.contrib.postgres.fields.array':\n                # Fix intersphinx mappings for django.contrib.postgres fields\n                type_line = f':type {field.name}: `{field_module}.ArrayField <{postgres_docu}#arrayfield>`_'\n            elif field_module == 'django.contrib.postgres.fields.jsonb':\n                # Fix intersphinx mappings for django.contrib.postgres fields\n                type_line = f':type {field.name}: `{field_module}.JSONField <{postgres_docu}#jsonfield>`_'\n            elif field_module in ['django.db.models.fields.related', 'mptt.fields']:\n                # Fix intersphinx mappings for related fields (ForeignKey, OneToOneField, ManyToManyField, ...)\n                # Also includes related MPTT fields (TreeForeignKey, TreeOneToOneField, TreeManyToManyField, ...)\n                remote_model = field.remote_field.get_related_field().model\n                type_line = f':type {field.name}: {field_type} to :class:`~{remote_model.__module__}.{remote_model.__name__}`'\n            elif field_module == 'django.db.models.fields.reverse_related':\n                # Fix intersphinx mappings for reverse related fields (ManyToOneRel, OneToOneRel, ManyToManyRel, ...)\n                remote_model = field.remote_field.model\n                type_line = f':type {field.name}: Reverse {field_type[:-3]} Relation from :class:`~{remote_model.__module__}.{remote_model.__name__}`'\n            else:\n                if 'django.db.models' in field_module:\n                    # Scope with django.db.models * imports (remove all sub-module-paths)\n                    field_module = 'django.db.models'\n                # Fix type hint to enable correct intersphinx mappings to other documentations\n                type_line = f':type {field.name}: {field_module}.{field_type}'\n            # This loop gets the indexes which are needed to update the type hints of the model parameters.\n            # It makes it possible to split the parameter section into multiple parts, e.g. params inherited from a base\n            # model and params of a sub model (otherwise the type hints would not be recognized when separated from\n            # the parameter description).\n            param_index = None\n            next_param_index = None\n            type_index = None\n            for index, line in enumerate(lines):\n                if param_index is None and f':param {field.name}:' in line:\n                    # The index of the field param is only used to determine the next param line\n                    param_index = index\n                elif param_index is not None and next_param_index is None and (':param ' in line or line == ''):\n                    # The line of the next param after the field, this is the index where we will insert the type.\n                    # Sometimes the param descriptions extend over multiple lines, so we cannot just do param_index + 1.\n                    # If the line is empty, the param description is finished, even if it extends over multiple lines.\n                    next_param_index = index\n                elif type_index is None and f':type {field.name}:' in line:\n                    # The index of the old type hint, we will either move this line or replace it\n                    type_index = index\n                    break\n            if next_param_index is None:\n                # In case the current field is the last param, we just append the type at the very end of lines\n                next_param_index = len(lines)\n            # For some params, the type line is not automatically generated and thus the type_index might be `None`\n            if type_index is not None:\n                # We delete the old type index, because we will replace it with the new type line\n                del lines[type_index]\n            # Insert the new type line just before the next param\n            lines.insert(next_param_index, type_line)\n    return lines\n\n\n# -- Source Code links to GitHub ---------------------------------------------\n\n\ndef linkcode_resolve(domain, info):\n    \"\"\"Link source code to GitHub.\"\"\"\n    if domain != 'py' or not info['module']:\n        return None\n    filename = info['module'].replace('.', '/')\n    module = importlib.import_module(info['module'])\n    basename = os.path.splitext(module.__file__)[0]\n    if basename.endswith('__init__'):\n        filename += '/__init__'\n    item = module\n    line_number_reference = ''\n    for piece in info['fullname'].split('.'):\n        item = getattr(item, piece)\n        try:\n            line_number_reference = f'#L{inspect.getsourcelines(item)[1]}'\n        except (TypeError, IOError):\n            pass\n    return f\"https://github.com/Integreat/cms-django/blob/develop/src/{filename}.py{line_number_reference}\"\n\n# -- Link targets ------------------------------------------------------------\n\n\n# pylint: disable=abstract-method\nclass PatchedHTMLTranslator(HTMLTranslator):\n    \"\"\"Open external links in a new tab\"\"\"\n\n    def visit_reference(self, node):\n        if (\n                node.get('newtab') or\n                not (\n                    node.get('target') or\n                    node.get('internal') or\n                    'refuri' not in node\n                )\n        ):\n            node['target'] = '_blank'\n        super().visit_reference(node)\n", "path": "sphinx/conf.py"}]}