Skip to content

Commit

Permalink
[1.9.x] Fixed #26021 -- Applied hanging indentation to docs.
Browse files Browse the repository at this point in the history
Backport of 4a4d7f9 from master
  • Loading branch information
kutenai authored and timgraham committed Jun 3, 2016
1 parent a0ebfa0 commit 6d0c9f9
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 107 deletions.
6 changes: 4 additions & 2 deletions docs/howto/custom-management-commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ options can be added in the :meth:`~BaseCommand.add_arguments` method like this:
parser.add_argument('poll_id', nargs='+', type=int)

# Named (optional) arguments
parser.add_argument('--delete',
parser.add_argument(
'--delete',
action='store_true',
dest='delete',
default=False,
help='Delete poll instead of closing it')
help='Delete poll instead of closing it',
)

def handle(self, *args, **options):
# ...
Expand Down
10 changes: 6 additions & 4 deletions docs/howto/error-reporting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,12 @@ filtered out of error reports in a production environment (that is, where

@sensitive_post_parameters('pass_word', 'credit_card_number')
def record_user_profile(request):
UserProfile.create(user=request.user,
password=request.POST['pass_word'],
credit_card=request.POST['credit_card_number'],
name=request.POST['name'])
UserProfile.create(
user=request.user,
password=request.POST['pass_word'],
credit_card=request.POST['credit_card_number'],
name=request.POST['name'],
)
...

In the above example, the values for the ``pass_word`` and
Expand Down
6 changes: 3 additions & 3 deletions docs/howto/static-files/deployment.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ Here's how this might look in a fabfile::
def deploy_static():
local('./manage.py collectstatic')
project.rsync_project(
remote_dir = env.remote_static_root,
local_dir = env.local_static_root,
delete = True
remote_dir=env.remote_static_root,
local_dir=env.local_static_root,
delete=True,
)

.. _staticfiles-from-cdn:
Expand Down
24 changes: 9 additions & 15 deletions docs/intro/tutorial05.txt
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ class:
in the past, positive for questions that have yet to be published).
"""
time = timezone.now() + datetime.timedelta(days=days)
return Question.objects.create(question_text=question_text,
pub_date=time)
return Question.objects.create(question_text=question_text, pub_date=time)


class QuestionViewTests(TestCase):
Expand Down Expand Up @@ -495,8 +494,7 @@ class:
"""
create_question(question_text="Future question.", days=30)
response = self.client.get(reverse('polls:index'))
self.assertContains(response, "No polls are available.",
status_code=200)
self.assertContains(response, "No polls are available.")
self.assertQuerysetEqual(response.context['latest_question_list'], [])

def test_index_view_with_future_question_and_past_question(self):
Expand Down Expand Up @@ -580,24 +578,20 @@ in the future is not:
The detail view of a question with a pub_date in the future should
return a 404 not found.
"""
future_question = create_question(question_text='Future question.',
days=5)
response = self.client.get(reverse('polls:detail',
args=(future_question.id,)))
future_question = create_question(question_text='Future question.', days=5)
url = reverse('polls:detail', args=(future_question.id,))
response = self.client.get(url)
self.assertEqual(response.status_code, 404)

def test_detail_view_with_a_past_question(self):
"""
The detail view of a question with a pub_date in the past should
display the question's text.
"""
past_question = create_question(question_text='Past Question.',
days=-5)
response = self.client.get(reverse('polls:detail',
args=(past_question.id,)))
self.assertContains(response, past_question.question_text,
status_code=200)

past_question = create_question(question_text='Past Question.', days=-5)
url = reverse('polls:detail', args=(past_question.id,))
response = self.client.get(url)
self.assertContains(response, past_question.question_text)

Ideas for more tests
--------------------
Expand Down
33 changes: 18 additions & 15 deletions docs/ref/contrib/admin/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,12 @@ subclass::
color_code = models.CharField(max_length=6)

def colored_name(self):
return format_html('<span style="color: #{};">{} {}</span>',
self.color_code,
self.first_name,
self.last_name)
return format_html(
'<span style="color: #{};">{} {}</span>',
self.color_code,
self.first_name,
self.last_name,
)

class PersonAdmin(admin.ModelAdmin):
list_display = ('first_name', 'last_name', 'colored_name')
Expand Down Expand Up @@ -706,9 +708,11 @@ subclass::
color_code = models.CharField(max_length=6)

def colored_first_name(self):
return format_html('<span style="color: #{};">{}</span>',
self.color_code,
self.first_name)
return format_html(
'<span style="color: #{};">{}</span>',
self.color_code,
self.first_name,
)

colored_first_name.admin_order_field = 'first_name'

Expand Down Expand Up @@ -912,13 +916,11 @@ subclass::

def lookups(self, request, model_admin):
if request.user.is_superuser:
return super(AuthDecadeBornListFilter,
self).lookups(request, model_admin)
return super(AuthDecadeBornListFilter, self).lookups(request, model_admin)

def queryset(self, request, queryset):
if request.user.is_superuser:
return super(AuthDecadeBornListFilter,
self).queryset(request, queryset)
return super(AuthDecadeBornListFilter, self).queryset(request, queryset)

Also as a convenience, the ``ModelAdmin`` object is passed to
the ``lookups`` method, for example if you want to base the
Expand Down Expand Up @@ -1268,8 +1270,8 @@ subclass::

class PersonAdmin(admin.ModelAdmin):
def view_on_site(self, obj):
return 'https://example.com' + reverse('person-detail',
kwargs={'slug': obj.slug})
url = reverse('person-detail', kwargs={'slug': obj.slug})
return 'https://example.com' + url

Custom template options
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -1885,8 +1887,9 @@ provided some extra mapping data that would not otherwise be available::
def change_view(self, request, object_id, form_url='', extra_context=None):
extra_context = extra_context or {}
extra_context['osm_data'] = self.get_osm_info()
return super(MyModelAdmin, self).change_view(request, object_id,
form_url, extra_context=extra_context)
return super(MyModelAdmin, self).change_view(
request, object_id, form_url, extra_context=extra_context,
)

These views return :class:`~django.template.response.TemplateResponse`
instances which allow you to easily customize the response data before
Expand Down
4 changes: 2 additions & 2 deletions docs/ref/contrib/gis/db-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ raster models::

>>> from django.contrib.gis.gdal import GDALRaster
>>> rast = GDALRaster({'width': 10, 'height': 10, 'name': 'Canyon', 'srid': 4326,
... 'scale': [0.1, -0.1]'bands': [{"data": range(100)}]}
... 'scale': [0.1, -0.1], 'bands': [{"data": range(100)}]})
>>> dem = Elevation(name='Canyon', rast=rast)
>>> dem.save()

Expand All @@ -126,7 +126,7 @@ Note that this equivalent to::
>>> dem = Elevation.objects.create(
... name='Canyon',
... rast={'width': 10, 'height': 10, 'name': 'Canyon', 'srid': 4326,
... 'scale': [0.1, -0.1]'bands': [{"data": range(100)}]}
... 'scale': [0.1, -0.1], 'bands': [{"data": range(100)}]},
... )

.. _spatial-lookups-intro:
Expand Down
11 changes: 7 additions & 4 deletions docs/ref/contrib/gis/tutorial.txt
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,15 @@ with the following code::
'mpoly' : 'MULTIPOLYGON',
}

world_shp = os.path.abspath(os.path.join(os.path.dirname(__file__), 'data', 'TM_WORLD_BORDERS-0.3.shp'))
world_shp = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'data', 'TM_WORLD_BORDERS-0.3.shp'),
)

def run(verbose=True):
lm = LayerMapping(WorldBorder, world_shp, world_mapping,
transform=False, encoding='iso-8859-1')

lm = LayerMapping(
WorldBorder, world_shp, world_mapping,
transform=False, encoding='iso-8859-1',
)
lm.save(strict=True, verbose=verbose)

A few notes about what's going on:
Expand Down
9 changes: 5 additions & 4 deletions docs/ref/contrib/messages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,7 @@ Adding extra message tags
For more direct control over message tags, you can optionally provide a string
containing extra tags to any of the add methods::

messages.add_message(request, messages.INFO, 'Over 9000!',
extra_tags='dragonball')
messages.add_message(request, messages.INFO, 'Over 9000!', extra_tags='dragonball')
messages.error(request, 'Email box full', extra_tags='email')

Extra tags are added before the default tag for that level and are space
Expand All @@ -336,8 +335,10 @@ if they don't want to, you may pass an additional keyword argument
``fail_silently=True`` to any of the ``add_message`` family of methods. For
example::

messages.add_message(request, messages.SUCCESS, 'Profile details updated.',
fail_silently=True)
messages.add_message(
request, messages.SUCCESS, 'Profile details updated.',
fail_silently=True,
)
messages.info(request, 'Hello world.', fail_silently=True)

.. note::
Expand Down
10 changes: 7 additions & 3 deletions docs/ref/contrib/sites.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,14 @@ Here's an example of what the form-handling view looks like::
# ...

current_site = get_current_site(request)
send_mail('Thanks for subscribing to %s alerts' % current_site.name,
'Thanks for your subscription. We appreciate it.\n\n-The %s team.' % current_site.name,
send_mail(
'Thanks for subscribing to %s alerts' % current_site.name,
'Thanks for your subscription. We appreciate it.\n\n-The %s team.' % (
current_site.name,
),
'editor@%s' % current_site.domain,
[user.email])
[user.email],
)

# ...

Expand Down
23 changes: 16 additions & 7 deletions docs/ref/forms/fields.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1033,16 +1033,25 @@ Slightly complex built-in ``Field`` classes
}
# Or define a different message for each field.
fields = (
CharField(error_messages={'incomplete': 'Enter a country calling code.'},
validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid country calling code.')]),
CharField(error_messages={'incomplete': 'Enter a phone number.'},
validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid phone number.')]),
CharField(validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid extension.')],
required=False),
CharField(
error_messages={'incomplete': 'Enter a country calling code.'},
validators=[
RegexValidator(r'^[0-9]+$', 'Enter a valid country calling code.'),
],
),
CharField(
error_messages={'incomplete': 'Enter a phone number.'},
validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid phone number.')],
),
CharField(
validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid extension.')],
required=False,
),
)
super(PhoneField, self).__init__(
error_messages=error_messages, fields=fields,
require_all_fields=False, *args, **kwargs)
require_all_fields=False, *args, **kwargs
)

.. attribute:: MultiValueField.widget

Expand Down
7 changes: 5 additions & 2 deletions docs/ref/forms/widgets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ widget on the field. In the following example, the

class SimpleForm(forms.Form):
birth_year = forms.DateField(widget=forms.SelectDateWidget(years=BIRTH_YEAR_CHOICES))
favorite_colors = forms.MultipleChoiceField(required=False,
widget=forms.CheckboxSelectMultiple, choices=FAVORITE_COLORS_CHOICES)
favorite_colors = forms.MultipleChoiceField(
required=False,
widget=forms.CheckboxSelectMultiple,
choices=FAVORITE_COLORS_CHOICES,
)

See the :ref:`built-in widgets` for more information about which widgets
are available and which arguments they accept.
Expand Down
3 changes: 2 additions & 1 deletion docs/ref/models/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ SQL that is generated. Here's a brief example::
expression,
distinct='DISTINCT ' if distinct else '',
output_field=IntegerField(),
**extra)
**extra
)


``Value()`` expressions
Expand Down
8 changes: 5 additions & 3 deletions docs/ref/models/fields.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ define a suitably-named constant for each value::
(JUNIOR, 'Junior'),
(SENIOR, 'Senior'),
)
year_in_school = models.CharField(max_length=2,
choices=YEAR_IN_SCHOOL_CHOICES,
default=FRESHMAN)
year_in_school = models.CharField(
max_length=2,
choices=YEAR_IN_SCHOOL_CHOICES,
default=FRESHMAN,
)

def is_upperclass(self):
return self.year_in_school in (self.JUNIOR, self.SENIOR)
Expand Down
5 changes: 3 additions & 2 deletions docs/topics/auth/customizing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -950,9 +950,10 @@ authentication app::
Creates and saves a superuser with the given email, date of
birth and password.
"""
user = self.create_user(email,
user = self.create_user(
email,
password=password,
date_of_birth=date_of_birth
date_of_birth=date_of_birth,
)
user.is_admin = True
user.save(using=self._db)
Expand Down
8 changes: 5 additions & 3 deletions docs/topics/auth/default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,11 @@ in ``myapp``::
from django.contrib.contenttypes.models import ContentType

content_type = ContentType.objects.get_for_model(BlogPost)
permission = Permission.objects.create(codename='can_publish',
name='Can Publish Posts',
content_type=content_type)
permission = Permission.objects.create(
codename='can_publish',
name='Can Publish Posts',
content_type=content_type,
)

The permission can then be assigned to a
:class:`~django.contrib.auth.models.User` via its ``user_permissions``
Expand Down
6 changes: 4 additions & 2 deletions docs/topics/db/queries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -849,14 +849,16 @@ precede the definition of any keyword arguments. For example::

Poll.objects.get(
Q(pub_date=date(2005, 5, 2)) | Q(pub_date=date(2005, 5, 6)),
question__startswith='Who')
question__startswith='Who',
)

... would be a valid query, equivalent to the previous example; but::

# INVALID QUERY
Poll.objects.get(
question__startswith='Who',
Q(pub_date=date(2005, 5, 2)) | Q(pub_date=date(2005, 5, 6)))
Q(pub_date=date(2005, 5, 2)) | Q(pub_date=date(2005, 5, 6))
)

... would not be valid.

Expand Down

0 comments on commit 6d0c9f9

Please sign in to comment.