diff options
author | Carlton Gibson <carlton.gibson@noumenal.es> | 2023-02-09 16:48:46 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-02-10 19:19:13 +0100 |
commit | 534ac4829764f317cf2fbc4a18354fcc998c1425 (patch) | |
tree | c85c1df220ea6c3a87f9820106ba5a06e9ec9394 /docs/intro | |
parent | 7bb741d787ba360a9f0d490db92e22e0d28204ed (diff) | |
download | django-534ac4829764f317cf2fbc4a18354fcc998c1425.tar.gz |
Refs #34140 -- Applied rst code-block to non-Python examples.
Thanks to J.V. Zammit, Paolo Melchiorre, and Mariusz Felisiak for
reviews.
Diffstat (limited to 'docs/intro')
-rw-r--r-- | docs/intro/contributing.txt | 12 | ||||
-rw-r--r-- | docs/intro/install.txt | 4 | ||||
-rw-r--r-- | docs/intro/overview.txt | 4 | ||||
-rw-r--r-- | docs/intro/reusable-apps.txt | 22 | ||||
-rw-r--r-- | docs/intro/tutorial01.txt | 12 | ||||
-rw-r--r-- | docs/intro/tutorial02.txt | 8 | ||||
-rw-r--r-- | docs/intro/tutorial05.txt | 16 |
7 files changed, 57 insertions, 21 deletions
diff --git a/docs/intro/contributing.txt b/docs/intro/contributing.txt index 0953ff7182..0a9189e907 100644 --- a/docs/intro/contributing.txt +++ b/docs/intro/contributing.txt @@ -357,7 +357,9 @@ that's really what happens. ``cd`` to the Django ``tests/`` directory and run: $ ./runtests.py shortcuts If the tests ran correctly, you should see one failure corresponding to the test -method we added, with this error:: +method we added, with this error: + +.. code-block:: pytb ImportError: cannot import name 'make_toast' from 'django.shortcuts' @@ -407,7 +409,9 @@ Writing Documentation This is a new feature, so it should be documented. Open the file ``docs/topics/http/shortcuts.txt`` and add the following at the end of the -file:: +file: + +.. code-block:: rst ``make_toast()`` ================ @@ -421,7 +425,9 @@ file:: Since this new feature will be in an upcoming release it is also added to the release notes for the next version of Django. Open the release notes for the latest version in ``docs/releases/``, which at time of writing is ``2.2.txt``. -Add a note under the "Minor Features" header:: +Add a note under the "Minor Features" header: + +.. code-block:: rst :mod:`django.shortcuts` ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/intro/install.txt b/docs/intro/install.txt index 6f67f6c728..b590df951b 100644 --- a/docs/intro/install.txt +++ b/docs/intro/install.txt @@ -20,7 +20,9 @@ Get the latest version of Python at https://www.python.org/downloads/ or with your operating system's package manager. You can verify that Python is installed by typing ``python`` from your shell; -you should see something like:: +you should see something like: + +.. code-block:: pycon Python 3.x.y [GCC 4.x] on linux diff --git a/docs/intro/overview.txt b/docs/intro/overview.txt index 81612ca6b0..efdf77b1d9 100644 --- a/docs/intro/overview.txt +++ b/docs/intro/overview.txt @@ -66,7 +66,9 @@ Enjoy the free API With that, you've got a free, and rich, :doc:`Python API </topics/db/queries>` to access your data. The API is created on the fly, no code generation -necessary:: +necessary: + +.. code-block:: pycon # Import the models we created from our "news" app >>> from news.models import Article, Reporter diff --git a/docs/intro/reusable-apps.txt b/docs/intro/reusable-apps.txt index c9a29f8584..1daac593f9 100644 --- a/docs/intro/reusable-apps.txt +++ b/docs/intro/reusable-apps.txt @@ -53,7 +53,9 @@ projects and ready to publish for others to install and use. Your project and your reusable app ================================== -After the previous tutorials, our project should look like this:: +After the previous tutorials, our project should look like this: + +.. code-block:: text mysite/ manage.py @@ -256,9 +258,11 @@ this. For a small app like polls, this process isn't too difficult. #. It's optional, but recommended, to include detailed documentation with your app. Create an empty directory ``django-polls/docs`` for future - documentation. Add an additional line to ``django-polls/MANIFEST.in``:: + documentation. Add an additional line to ``django-polls/MANIFEST.in``: + + .. code-block:: text - recursive-include docs * + recursive-include docs * Note that the ``docs`` directory won't be included in your package unless you add some files to it. Many Django apps also provide their documentation @@ -291,16 +295,20 @@ working. We'll now fix this by installing our new ``django-polls`` package. solution (see below). #. To install the package, use pip (you already :ref:`installed it - <installing-reusable-apps-prerequisites>`, right?):: + <installing-reusable-apps-prerequisites>`, right?): - python -m pip install --user django-polls/dist/django-polls-0.1.tar.gz + .. code-block:: shell + + python -m pip install --user django-polls/dist/django-polls-0.1.tar.gz #. With luck, your Django project should now work correctly again. Run the server again to confirm this. -#. To uninstall the package, use pip:: +#. To uninstall the package, use pip: + + .. code-block:: shell - python -m pip uninstall django-polls + python -m pip uninstall django-polls Publishing your app =================== diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt index 4f9dc67da5..d9142e7a03 100644 --- a/docs/intro/tutorial01.txt +++ b/docs/intro/tutorial01.txt @@ -76,7 +76,9 @@ work, see :ref:`troubleshooting-django-admin`. Put your code in some directory **outside** of the document root, such as :file:`/home/mycode`. -Let's look at what :djadmin:`startproject` created:: +Let's look at what :djadmin:`startproject` created: + +.. code-block:: text mysite/ manage.py @@ -224,7 +226,9 @@ and type this command: $ python manage.py startapp polls -That'll create a directory :file:`polls`, which is laid out like this:: +That'll create a directory :file:`polls`, which is laid out like this: + +.. code-block:: text polls/ __init__.py @@ -257,7 +261,9 @@ This is the simplest view possible in Django. To call the view, we need to map it to a URL - and for this we need a URLconf. To create a URLconf in the polls directory, create a file called ``urls.py``. -Your app directory should now look like:: +Your app directory should now look like: + +.. code-block:: text polls/ __init__.py diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index b37d0c036b..e01975aeed 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -381,7 +381,9 @@ We're using this instead of simply typing "python", because :file:`manage.py` sets the :envvar:`DJANGO_SETTINGS_MODULE` environment variable, which gives Django the Python import path to your :file:`mysite/settings.py` file. -Once you're in the shell, explore the :doc:`database API </topics/db/queries>`:: +Once you're in the shell, explore the :doc:`database API </topics/db/queries>`: + +.. code-block:: pycon >>> from polls.models import Choice, Question # Import the model classes we just wrote. @@ -468,7 +470,9 @@ you aren't familiar with time zone handling in Python, you can learn more in the :doc:`time zone support docs </topics/i18n/timezones>`. Save these changes and start a new Python interactive shell by running -``python manage.py shell`` again:: +``python manage.py shell`` again: + +.. code-block:: pycon >>> from polls.models import Choice, Question diff --git a/docs/intro/tutorial05.txt b/docs/intro/tutorial05.txt index 4431af71ad..8eff8bf9d4 100644 --- a/docs/intro/tutorial05.txt +++ b/docs/intro/tutorial05.txt @@ -206,7 +206,9 @@ In the terminal, we can run our test: $ python manage.py test polls -and you'll see something like:: +and you'll see something like: + +.. code-block:: shell Creating test database for alias 'default'... System check identified no issues (0 silenced). @@ -267,7 +269,9 @@ past: now = timezone.now() return now - datetime.timedelta(days=1) <= self.pub_date <= now -and run the test again:: +and run the test again: + +.. code-block:: pytb Creating test database for alias 'default'... System check identified no issues (0 silenced). @@ -376,13 +380,17 @@ it earlier, check it before continuing. Next we need to import the test client class (later in ``tests.py`` we will use the :class:`django.test.TestCase` class, which comes with its own client, so -this won't be required):: +this won't be required): + +.. code-block:: pycon >>> from django.test import Client >>> # create an instance of the client for our use >>> client = Client() -With that ready, we can ask the client to do some work for us:: +With that ready, we can ask the client to do some work for us: + +.. code-block:: pycon >>> # get a response from '/' >>> response = client.get('/') |