From adaf92085fb2e1c45bfcf9b66ce00bf0ffd3f92d Mon Sep 17 00:00:00 2001 From: Paolo Melchiorre Date: Tue, 14 Feb 2023 16:55:26 +0100 Subject: [PATCH] Fix #353 Improve code blocks in documentation --- README.rst | 10 +++++----- docs/cookbook.rst | 8 +++----- docs/index.rst | 2 +- docs/patterns.rst | 8 ++++---- docs/values.rst | 22 +++++++++++++++------- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/README.rst b/README.rst index 2876635..98c5f1e 100644 --- a/README.rst +++ b/README.rst @@ -47,13 +47,13 @@ Install django-configurations: .. code-block:: console - pip install django-configurations + $ python -m pip install django-configurations or, alternatively, if you want to use URL-based values: .. code-block:: console - pip install django-configurations[cache,database,email,search] + $ python -m pip install django-configurations[cache,database,email,search] Then subclass the included ``configurations.Configuration`` class in your project's **settings.py** or any other module you're using to store the @@ -73,14 +73,14 @@ you just created, e.g. in bash: .. code-block:: console - export DJANGO_CONFIGURATION=Dev + $ export DJANGO_CONFIGURATION=Dev and the ``DJANGO_SETTINGS_MODULE`` environment variable to the module import path as usual, e.g. in bash: .. code-block:: console - export DJANGO_SETTINGS_MODULE=mysite.settings + $ export DJANGO_SETTINGS_MODULE=mysite.settings *Alternatively* supply the ``--configuration`` option when using Django management commands along the lines of Django's default ``--settings`` @@ -88,7 +88,7 @@ command line option, e.g. .. code-block:: console - python manage.py runserver --settings=mysite.settings --configuration=Dev + $ python -m manage runserver --settings=mysite.settings --configuration=Dev To enable Django to use your configuration you now have to modify your **manage.py**, **wsgi.py** or **asgi.py** script to use django-configurations's versions diff --git a/docs/cookbook.rst b/docs/cookbook.rst index 21624e5..0a3d76f 100644 --- a/docs/cookbook.rst +++ b/docs/cookbook.rst @@ -74,7 +74,7 @@ Example: .. code-block:: console - $ tree mysite_env/ + $ tree --noreport mysite_env/ mysite_env/ ├── DJANGO_SETTINGS_MODULE ├── DJANGO_DEBUG @@ -82,10 +82,8 @@ Example: ├── DJANGO_CACHE_URL └── PYTHONSTARTUP - 0 directories, 3 files $ cat mysite_env/DJANGO_CACHE_URL redis://user@host:port/1 - $ Then, to enable the ``mysite_env`` environment variables, simply use the ``envdir`` command line tool as a prefix for your program, e.g.: @@ -151,13 +149,13 @@ First install Django 1.8.x and django-configurations: .. code-block:: console - $ pip install -r https://raw.github.com/jazzband/django-configurations/templates/1.8.x/requirements.txt + $ python -m pip install -r https://raw.github.com/jazzband/django-configurations/templates/1.8.x/requirements.txt Or Django 1.8: .. code-block:: console - $ django-admin.py startproject mysite -v2 --template https://github.com/jazzband/django-configurations/archive/templates/1.8.x.zip + $ python -m django startproject mysite -v2 --template https://github.com/jazzband/django-configurations/archive/templates/1.8.x.zip Now you have a default Django 1.8.x project in the ``mysite`` directory that uses django-configurations. diff --git a/docs/index.rst b/docs/index.rst index 702654e..9c0d55c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -93,6 +93,6 @@ Bugs and feature requests As always your mileage may vary, so please don't hesitate to send feature requests and bug reports: - https://github.com/jazzband/django-configurations/issues +- https://github.com/jazzband/django-configurations/issues Thanks! \ No newline at end of file diff --git a/docs/patterns.rst b/docs/patterns.rst index 2763b35..729ca96 100644 --- a/docs/patterns.rst +++ b/docs/patterns.rst @@ -31,9 +31,9 @@ it should be ``Prod``. In Bash that would be: .. code-block:: console - export DJANGO_SETTINGS_MODULE=mysite.settings - export DJANGO_CONFIGURATION=Prod - python manage.py runserver + $ export DJANGO_SETTINGS_MODULE=mysite.settings + $ export DJANGO_CONFIGURATION=Prod + $ python -m manage runserver Alternatively you can use the ``--configuration`` option when using Django management commands along the lines of Django's default ``--settings`` @@ -41,7 +41,7 @@ command line option, e.g. .. code-block:: console - python manage.py runserver --settings=mysite.settings --configuration=Prod + $ python -m manage runserver --settings=mysite.settings --configuration=Prod Property settings ----------------- diff --git a/docs/values.rst b/docs/values.rst index d7b10b8..48e4e0d 100644 --- a/docs/values.rst +++ b/docs/values.rst @@ -86,9 +86,11 @@ prefixed with ``DJANGO_``. E.g.: django-configurations will try to read the ``DJANGO_ROOT_URLCONF`` environment variable when deciding which value the ``ROOT_URLCONF`` setting should have. When you run the web server simply specify that environment variable -(e.g. in your init script):: +(e.g. in your init script): - DJANGO_ROOT_URLCONF=mysite.debugging_urls gunicorn mysite.wsgi:application +.. code-block:: console + + $ DJANGO_ROOT_URLCONF=mysite.debugging_urls gunicorn mysite.wsgi:application If the environment variable can't be found it'll use the default ``'mysite.urls'``. @@ -125,7 +127,9 @@ Allow final value to be used outside the configuration context You may use the ``environ_name`` parameter to allow a :class:`~Value` to be directly converted to its final value for use outside of the configuration -context:: +context: + +.. code-block:: pycon >>> type(values.Value([])) @@ -283,17 +287,21 @@ Type values MONTY_PYTHONS = ListValue(['John Cleese', 'Eric Idle'], converter=check_monty_python) - You can override this list with an environment variable like this:: + You can override this list with an environment variable like this: - DJANGO_MONTY_PYTHONS="Terry Jones,Graham Chapman" gunicorn mysite.wsgi:application +.. code-block:: console + + $ DJANGO_MONTY_PYTHONS="Terry Jones,Graham Chapman" gunicorn mysite.wsgi:application Use a custom separator:: EMERGENCY_EMAILS = ListValue(['admin@mysite.net'], separator=';') - And override it:: + And override it: + +.. code-block:: console - DJANGO_EMERGENCY_EMAILS="admin@mysite.net;manager@mysite.org;support@mysite.com" gunicorn mysite.wsgi:application + $ DJANGO_EMERGENCY_EMAILS="admin@mysite.net;manager@mysite.org;support@mysite.com" gunicorn mysite.wsgi:application .. class:: TupleValue