diff --git a/docs/_theme/djangodocs/static/djangodocs.css b/docs/_theme/djangodocs/static/djangodocs.css index bd47749a06..0b6a8b9ad3 100644 --- a/docs/_theme/djangodocs/static/djangodocs.css +++ b/docs/_theme/djangodocs/static/djangodocs.css @@ -103,6 +103,7 @@ dt .literal, table .literal { background:none; } #bd a.reference { text-decoration: none; } #bd a.reference tt.literal { border-bottom: 1px #234f32 dotted; } div.code-block-caption { color: white; background-color: #234F32; margin: 0; padding: 2px 5px; width: 100%; font-family: monospace; font-size: small; line-height: 1.3em; } +div.code-block-caption .literal {color: white; } div.literal-block-wrapper pre { margin-top: 0; } /* Restore colors of pygments hyperlinked code */ diff --git a/docs/howto/overriding-templates.txt b/docs/howto/overriding-templates.txt index eed379b3df..80a18f3bac 100644 --- a/docs/howto/overriding-templates.txt +++ b/docs/howto/overriding-templates.txt @@ -112,7 +112,7 @@ For example, you can use this technique to add a custom logo to the ``admin/base_site.html`` template: .. code-block:: html+django - :caption: templates/admin/base_site.html + :caption: ``templates/admin/base_site.html`` {% extends "admin/base_site.html" %} diff --git a/docs/howto/writing-migrations.txt b/docs/howto/writing-migrations.txt index 8ccd650661..24c47058e3 100644 --- a/docs/howto/writing-migrations.txt +++ b/docs/howto/writing-migrations.txt @@ -40,7 +40,7 @@ You can also provide hints that will be passed to the :meth:`allow_migrate()` method of database routers as ``**hints``: .. code-block:: python - :caption: myapp/dbrouters.py + :caption: ``myapp/dbrouters.py`` class MyRouter: @@ -98,7 +98,7 @@ the respective field according to your needs. ``AlterField``, and add imports of ``uuid`` and ``models``. For example: .. code-block:: python - :caption: 0006_remove_uuid_null.py + :caption: ``0006_remove_uuid_null.py`` # Generated by Django A.B on YYYY-MM-DD HH:MM from django.db import migrations, models @@ -122,7 +122,7 @@ the respective field according to your needs. similar to this: .. code-block:: python - :caption: 0004_add_uuid_field.py + :caption: ``0004_add_uuid_field.py`` class Migration(migrations.Migration): @@ -149,7 +149,7 @@ the respective field according to your needs. of ``uuid``. For example: .. code-block:: python - :caption: 0005_populate_uuid_values.py + :caption: ``0005_populate_uuid_values.py`` # Generated by Django A.B on YYYY-MM-DD HH:MM from django.db import migrations @@ -283,7 +283,7 @@ project anywhere without first installing and then uninstalling the old app. Here's a sample migration: .. code-block:: python - :caption: myapp/migrations/0124_move_old_app_to_new_app.py + :caption: ``myapp/migrations/0124_move_old_app_to_new_app.py`` from django.apps import apps as global_apps from django.db import migrations diff --git a/docs/internals/contributing/writing-code/coding-style.txt b/docs/internals/contributing/writing-code/coding-style.txt index 8aebcfa556..76198b6860 100644 --- a/docs/internals/contributing/writing-code/coding-style.txt +++ b/docs/internals/contributing/writing-code/coding-style.txt @@ -167,7 +167,7 @@ Imports For example (comments are for explanatory purposes only): .. code-block:: python - :caption: django/contrib/admin/example.py + :caption: ``django/contrib/admin/example.py`` # future from __future__ import unicode_literals diff --git a/docs/internals/contributing/writing-code/unit-tests.txt b/docs/internals/contributing/writing-code/unit-tests.txt index 2bc261666e..ee7abf04ed 100644 --- a/docs/internals/contributing/writing-code/unit-tests.txt +++ b/docs/internals/contributing/writing-code/unit-tests.txt @@ -564,7 +564,7 @@ Since this pattern involves a lot of boilerplate, Django provides the installed, you should pass the set of targeted ``app_label`` as arguments: .. code-block:: python - :caption: tests/app_label/tests.py + :caption: ``tests/app_label/tests.py`` from django.db import models from django.test import SimpleTestCase diff --git a/docs/internals/howto-release-django.txt b/docs/internals/howto-release-django.txt index ca096e6690..45994af420 100644 --- a/docs/internals/howto-release-django.txt +++ b/docs/internals/howto-release-django.txt @@ -63,7 +63,7 @@ You'll need a few things before getting started: * Access to Django's record on PyPI. Create a file with your credentials: .. code-block:: ini - :caption: ~/.pypirc + :caption: ``~/.pypirc`` [pypi] username:YourUsername diff --git a/docs/intro/overview.txt b/docs/intro/overview.txt index b28c1af285..81612ca6b0 100644 --- a/docs/intro/overview.txt +++ b/docs/intro/overview.txt @@ -26,7 +26,7 @@ representing your models -- so far, it's been solving many years' worth of database-schema problems. Here's a quick example: .. code-block:: python - :caption: mysite/news/models.py + :caption: ``mysite/news/models.py`` from django.db import models @@ -146,7 +146,7 @@ a website that lets authenticated users add, change and delete objects. The only step required is to register your model in the admin site: .. code-block:: python - :caption: mysite/news/models.py + :caption: ``mysite/news/models.py`` from django.db import models @@ -157,7 +157,7 @@ only step required is to register your model in the admin site: reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE) .. code-block:: python - :caption: mysite/news/admin.py + :caption: ``mysite/news/admin.py`` from django.contrib import admin @@ -189,7 +189,7 @@ Here's what a URLconf might look like for the ``Reporter``/``Article`` example above: .. code-block:: python - :caption: mysite/news/urls.py + :caption: ``mysite/news/urls.py`` from django.urls import path @@ -229,7 +229,7 @@ and renders the template with the retrieved data. Here's an example view for ``year_archive`` from above: .. code-block:: python - :caption: mysite/news/views.py + :caption: ``mysite/news/views.py`` from django.shortcuts import render @@ -258,7 +258,7 @@ Let's say the ``news/year_archive.html`` template was found. Here's what that might look like: .. code-block:: html+django - :caption: mysite/news/templates/news/year_archive.html + :caption: ``mysite/news/templates/news/year_archive.html`` {% extends "base.html" %} @@ -299,7 +299,7 @@ Here's what the "base.html" template, including the use of :doc:`static files `, might look like: .. code-block:: html+django - :caption: mysite/templates/base.html + :caption: ``mysite/templates/base.html`` {% load static %} diff --git a/docs/intro/reusable-apps.txt b/docs/intro/reusable-apps.txt index 21a6e0f634..e120857586 100644 --- a/docs/intro/reusable-apps.txt +++ b/docs/intro/reusable-apps.txt @@ -144,7 +144,7 @@ this. For a small app like polls, this process isn't too difficult. #. Create a file ``django-polls/README.rst`` with the following contents: .. code-block:: rst - :caption: django-polls/README.rst + :caption: ``django-polls/README.rst`` ===== Polls @@ -192,14 +192,14 @@ this. For a small app like polls, this process isn't too difficult. following contents: .. code-block:: toml - :caption: django-polls/pyproject.toml + :caption: ``django-polls/pyproject.toml`` [build-system] requires = ['setuptools>=40.8.0', 'wheel'] build-backend = 'setuptools.build_meta:__legacy__' .. code-block:: ini - :caption: django-polls/setup.cfg + :caption: ``django-polls/setup.cfg`` [metadata] name = django-polls @@ -233,7 +233,7 @@ this. For a small app like polls, this process isn't too difficult. Django >= X.Y # Replace "X.Y" as appropriate .. code-block:: python - :caption: django-polls/setup.py + :caption: ``django-polls/setup.py`` from setuptools import setup @@ -247,7 +247,7 @@ this. For a small app like polls, this process isn't too difficult. contents: .. code-block:: text - :caption: django-polls/MANIFEST.in + :caption: ``django-polls/MANIFEST.in`` include LICENSE include README.rst diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt index 368760dfb8..1c35424c97 100644 --- a/docs/intro/tutorial01.txt +++ b/docs/intro/tutorial01.txt @@ -245,7 +245,7 @@ Let's write the first view. Open the file ``polls/views.py`` and put the following Python code in it: .. code-block:: python - :caption: polls/views.py + :caption: ``polls/views.py`` from django.http import HttpResponse @@ -273,7 +273,7 @@ Your app directory should now look like:: In the ``polls/urls.py`` file include the following code: .. code-block:: python - :caption: polls/urls.py + :caption: ``polls/urls.py`` from django.urls import path @@ -288,7 +288,7 @@ The next step is to point the root URLconf at the ``polls.urls`` module. In :func:`~django.urls.include` in the ``urlpatterns`` list, so you have: .. code-block:: python - :caption: mysite/urls.py + :caption: ``mysite/urls.py`` from django.contrib import admin from django.urls import include, path diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index 8050848035..df595e947c 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -141,7 +141,7 @@ These concepts are represented by Python classes. Edit the :file:`polls/models.py` file so it looks like this: .. code-block:: python - :caption: polls/models.py + :caption: ``polls/models.py`` from django.db import models @@ -217,7 +217,7 @@ add that dotted path to the :setting:`INSTALLED_APPS` setting. It'll look like this: .. code-block:: python - :caption: mysite/settings.py + :caption: ``mysite/settings.py`` INSTALLED_APPS = [ 'polls.apps.PollsConfig', @@ -424,7 +424,7 @@ representation of this object. Let's fix that by editing the ``Question`` model ``Choice``: .. code-block:: python - :caption: polls/models.py + :caption: ``polls/models.py`` from django.db import models @@ -448,7 +448,7 @@ automatically-generated admin. Let's also add a custom method to this model: .. code-block:: python - :caption: polls/models.py + :caption: ``polls/models.py`` import datetime @@ -646,7 +646,7 @@ have an admin interface. To do this, open the :file:`polls/admin.py` file, and edit it to look like this: .. code-block:: python - :caption: polls/admin.py + :caption: ``polls/admin.py`` from django.contrib import admin diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt index 82d0d85cec..b9c9d2b54e 100644 --- a/docs/intro/tutorial03.txt +++ b/docs/intro/tutorial03.txt @@ -70,7 +70,7 @@ Now let's add a few more views to ``polls/views.py``. These views are slightly different, because they take an argument: .. code-block:: python - :caption: polls/views.py + :caption: ``polls/views.py`` def detail(request, question_id): return HttpResponse("You're looking at question %s." % question_id) @@ -86,7 +86,7 @@ Wire these new views into the ``polls.urls`` module by adding the following :func:`~django.urls.path` calls: .. code-block:: python - :caption: polls/urls.py + :caption: ``polls/urls.py`` from django.urls import path @@ -147,7 +147,7 @@ view, which displays the latest 5 poll questions in the system, separated by commas, according to publication date: .. code-block:: python - :caption: polls/views.py + :caption: ``polls/views.py`` from django.http import HttpResponse @@ -196,7 +196,7 @@ Django as ``polls/index.html``. Put the following code in that template: .. code-block:: html+django - :caption: polls/templates/polls/index.html + :caption: ``polls/templates/polls/index.html`` {% if latest_question_list %}