Code

Ticket #1834: admin_templatetags_docstrings.diff

File admin_templatetags_docstrings.diff, 2.9 KB (added by Rupe, 4 years ago)

docstrings for admin templatetags and some internal functions

Line 
1Index: django/contrib/admin/templatetags/admin_list.py
2===================================================================
3--- django/contrib/admin/templatetags/admin_list.py     (revision 13063)
4+++ django/contrib/admin/templatetags/admin_list.py     (working copy)
5@@ -21,6 +21,9 @@
6 DOT = '.'
7 
8 def paginator_number(cl,i):
9+    """
10+    Generates an individual page index link in a paginated list.
11+    """
12     if i == DOT:
13         return u'... '
14     elif i == cl.page_num:
15@@ -30,6 +33,9 @@
16 paginator_number = register.simple_tag(paginator_number)
17 
18 def pagination(cl):
19+    """
20+    Generates the series of links to the pages in a paginated list.
21+    """
22     paginator, page_num = cl.paginator, cl.page_num
23 
24     pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page
25@@ -73,6 +79,9 @@
26 pagination = register.inclusion_tag('admin/pagination.html')(pagination)
27 
28 def result_headers(cl):
29+    """
30+    Generates the list column headers.
31+    """
32     lookup_opts = cl.lookup_opts
33 
34     for i, field_name in enumerate(cl.list_display):
35@@ -118,6 +127,9 @@
36     return mark_safe(u'<img src="%simg/admin/icon-%s.gif" alt="%s" />' % (settings.ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val))
37 
38 def items_for_result(cl, result, form):
39+    """
40+    Generates the actual list of data.
41+    """
42     first = True
43     pk = cl.lookup_opts.pk.attname
44     for field_name in cl.list_display:
45@@ -189,12 +201,18 @@
46             yield list(items_for_result(cl, res, None))
47 
48 def result_list(cl):
49+    """
50+    Displays the headers and data list together
51+    """
52     return {'cl': cl,
53             'result_headers': list(result_headers(cl)),
54             'results': list(results(cl))}
55 result_list = register.inclusion_tag("admin/change_list_results.html")(result_list)
56 
57 def date_hierarchy(cl):
58+    """
59+    Displays the date hierarchy for date drill-down functionality.
60+    """
61     if cl.date_hierarchy:
62         field_name = cl.date_hierarchy
63         year_field = '%s__year' % field_name
64@@ -255,6 +273,9 @@
65 date_hierarchy = register.inclusion_tag('admin/date_hierarchy.html')(date_hierarchy)
66 
67 def search_form(cl):
68+    """
69+    Displays a search form for searching the list.
70+    """
71     return {
72         'cl': cl,
73         'show_result_count': cl.result_count != cl.full_result_count,
74Index: django/contrib/admin/templatetags/admin_modify.py
75===================================================================
76--- django/contrib/admin/templatetags/admin_modify.py   (revision 13063)
77+++ django/contrib/admin/templatetags/admin_modify.py   (working copy)
78@@ -20,6 +20,9 @@
79 prepopulated_fields_js = register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True)(prepopulated_fields_js)
80 
81 def submit_row(context):
82+    """
83+    Displays the row of buttons for delete and save.
84+    """
85     opts = context['opts']
86     change = context['change']
87     is_popup = context['is_popup']