Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Reworded docstrings and settings documentation from [1068]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1098 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e19c9ccfcbd5b240c170df4b39a04af118d26e52 1 parent b14a50b
Adrian Holovaty authored November 06, 2005
81  django/core/template/__init__.py
@@ -236,15 +236,12 @@ def delete_first_token(self):
236 236
 
237 237
 class TokenParser:
238 238
     """
239  
-    You need to subclass this class and implement the
240  
-    top method to parse your template line. When instantiating
241  
-    the parser, you pass in the line from the django template
242  
-    parser.
  239
+    Subclass this and implement the top() method to parse a template line. When
  240
+    instantiating the parser, pass in the line from the Django template parser.
243 241
 
244  
-    If your tag needs to know what tag name it was called with,
245  
-    you find it in the tagname instance variable of the parser.
  242
+    The parser's "tagname" instance-variable stores the name of the tag that
  243
+    the filter was called with.
246 244
     """
247  
-
248 245
     def __init__(self, subject):
249 246
         self.subject = subject
250 247
         self.pointer = 0
@@ -252,31 +249,21 @@ def __init__(self, subject):
252 249
         self.tagname = self.tag()
253 250
 
254 251
     def top(self):
255  
-        """
256  
-        You need to overload this method to do the actual parsing
257  
-        and return the result.
258  
-        """
  252
+        "Overload this method to do the actual parsing and return the result."
259 253
         raise NotImplemented
260 254
 
261 255
     def more(self):
262  
-        """
263  
-        This returns True if there is more stuff in the tag.
264  
-        """
  256
+        "Returns True if there is more stuff in the tag."
265 257
         return self.pointer < len(self.subject)
266 258
 
267 259
     def back(self):
268  
-        """
269  
-        This method undos the last microparser. This can be
270  
-        used for lookahead and backtracking.
271  
-        """
  260
+        "Undoes the last microparser. Use this for lookahead and backtracking."
272 261
         if not len(self.backout):
273 262
             raise TemplateSyntaxError, "back called without some previous parsing"
274 263
         self.pointer = self.backout.pop()
275 264
 
276 265
     def tag(self):
277  
-        """
278  
-        This microparser just returns the next tag from the line.
279  
-        """
  266
+        "A microparser that just returns the next tag from the line."
280 267
         subject = self.subject
281 268
         i = self.pointer
282 269
         if i >= len(subject):
@@ -292,21 +279,18 @@ def tag(self):
292 279
         return s
293 280
 
294 281
     def value(self):
295  
-        """
296  
-        This microparser parses for a value - some string constant or
297  
-        variable name.
298  
-        """
  282
+        "A microparser that parses for a value: some string constant or variable name."
299 283
         subject = self.subject
300 284
         i = self.pointer
301 285
         if i >= len(subject):
302  
-            raise TemplateSyntaxError, "searching for value expected another value, found end of string: %s" % subject
  286
+            raise TemplateSyntaxError, "Searching for value. Expected another value but found end of string: %s" % subject
303 287
         if subject[i] in ('"', "'"):
304 288
             p = i
305 289
             i += 1
306 290
             while i < len(subject) and subject[i] != subject[p]:
307 291
                 i += 1
308 292
             if i >= len(subject):
309  
-                raise TemplateSyntaxError, "searching for value, unexpected end of string in column %d: %s" % subject
  293
+                raise TemplateSyntaxError, "Searching for value. Unexpected end of string in column %d: %s" % subject
310 294
             i += 1
311 295
             res = subject[p:i]
312 296
             while i < len(subject) and subject[i] in (' ', '\t'):
@@ -326,18 +310,19 @@ def value(self):
326 310
             return s
327 311
 
328 312
 class FilterParser:
329  
-    """Parse a variable token and its optional filters (all as a single string),
330  
-       and return a list of tuples of the filter name and arguments.
331  
-       Sample:
332  
-            >>> token = 'variable|default:"Default value"|date:"Y-m-d"'
333  
-            >>> p = FilterParser(token)
334  
-            >>> p.filters
335  
-            [('default', 'Default value'), ('date', 'Y-m-d')]
336  
-            >>> p.var
337  
-            'variable'
338  
-
339  
-        This class should never be instantiated outside of the
340  
-        get_filters_from_token helper function.
  313
+    """
  314
+    Parses a variable token and its optional filters (all as a single string),
  315
+    and return a list of tuples of the filter name and arguments.
  316
+    Sample:
  317
+        >>> token = 'variable|default:"Default value"|date:"Y-m-d"'
  318
+        >>> p = FilterParser(token)
  319
+        >>> p.filters
  320
+        [('default', 'Default value'), ('date', 'Y-m-d')]
  321
+        >>> p.var
  322
+        'variable'
  323
+
  324
+    This class should never be instantiated outside of the
  325
+    get_filters_from_token helper function.
341 326
     """
342 327
     def __init__(self, s):
343 328
         self.s = s
@@ -346,8 +331,8 @@ def __init__(self, s):
346 331
         self.filters = []
347 332
         self.current_filter_name = None
348 333
         self.current_filter_arg = None
349  
-        # First read the variable part - decide on wether we need
350  
-        # to parse a string or a variable by peeking into the stream
  334
+        # First read the variable part. Decide whether we need to parse a
  335
+        # string or a variable by peeking into the stream.
351 336
         if self.peek_char() in ('_', '"', "'"):
352 337
             self.var = self.read_constant_string_token()
353 338
         else:
@@ -378,15 +363,17 @@ def next_char(self):
378 363
             self.current = None
379 364
 
380 365
     def read_constant_string_token(self):
381  
-        """Read a constant string that must be delimited by either "
382  
-        or ' characters. The string is returned with it's delimiters."""
  366
+        """
  367
+        Reads a constant string that must be delimited by either " or '
  368
+        characters. The string is returned with its delimiters.
  369
+        """
383 370
         val = ''
384 371
         qchar = None
385 372
         i18n = False
386 373
         self.next_char()
387 374
         if self.current == '_':
388 375
             i18n = True
389  
-            self.next_char() 
  376
+            self.next_char()
390 377
             if self.current != '(':
391 378
                 raise TemplateSyntaxError, "Bad character (expecting '(') '%s'" % self.current
392 379
             self.next_char()
@@ -409,8 +396,10 @@ def read_constant_string_token(self):
409 396
         return val
410 397
 
411 398
     def read_alphanumeric_token(self):
412  
-        """Read a variable name or filter name, which are continuous strings of
413  
-        alphanumeric characters + the underscore"""
  399
+        """
  400
+        Reads a variable name or filter name, which are continuous strings of
  401
+        alphanumeric characters + the underscore.
  402
+        """
414 403
         var = ''
415 404
         while 1:
416 405
             self.next_char()
9  django/core/template/defaulttags.py
@@ -2,10 +2,7 @@
2 2
 
3 3
 from django.core.template import Node, NodeList, Template, Context, resolve_variable, resolve_variable_with_filters, get_filters_from_token, registered_filters
4 4
 from django.core.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, register_tag
5  
-from django.utils import translation
6  
-
7 5
 import sys
8  
-import re
9 6
 
10 7
 class CommentNode(Node):
11 8
     def render(self, context):
@@ -531,12 +528,10 @@ def do_if(parser, token):
531 528
         {% endif %}
532 529
 
533 530
         {% if not athlete_list or coach_list %}
534  
-            There are no athletes or there are some coaches (OK, so
535  
-            writing English translations of boolean logic sounds
536  
-            stupid; it's not my fault).
  531
+            There are no athletes, or there are some coaches.
537 532
         {% endif %}
538 533
 
539  
-    For simplicity, ``if`` tags do not allow ``and`` clauses; use nested ``if``
  534
+    For simplicity, ``if`` tags do not allow ``and`` clauses. Use nested ``if``
540 535
     tags instead::
541 536
 
542 537
         {% if athlete_list %}
51  django/utils/functional.py
@@ -4,24 +4,17 @@ def _curried(*moreargs, **morekwargs):
4 4
     return _curried
5 5
 
6 6
 def lazy(func, *resultclasses):
7  
-
8 7
     """
9  
-    lazy turns any callable passed in into a lazy evaluated callable.
10  
-    you need to give result classes or types - at least one is needed
11  
-    so that the automatic forcing of the lazy evaluation code is
12  
-    triggered. Results are not memoized - the function is evaluated
13  
-    on every access.
  8
+    Turns any callable into a lazy evaluated callable. You need to give result
  9
+    classes or types -- at least one is needed so that the automatic forcing of
  10
+    the lazy evaluation code is triggered. Results are not memoized; the
  11
+    function is evaluated on every access.
14 12
     """
15  
-
16 13
     class __proxy__:
17  
-    
18  
-        """
19  
-        This inner class encapsulates the code that should be evaluated
20  
-        lazyly. On calling of one of the magic methods it will force
21  
-        the evaluation and store the result - afterwards the result
22  
-        is delivered directly. So the result is memoized.
23  
-        """
24  
-
  14
+        # This inner class encapsulates the code that should be evaluated
  15
+        # lazily. On calling of one of the magic methods it will force
  16
+        # the evaluation and store the result. Afterwards, the result
  17
+        # is delivered directly. So the result is memoized.
25 18
         def __init__(self, args, kw):
26 19
            self.__func = func
27 20
            self.__args = args
@@ -31,35 +24,23 @@ def __init__(self, args, kw):
31 24
                self.__dispatch[resultclass] = {}
32 25
                for (k, v) in resultclass.__dict__.items():
33 26
                    setattr(self, k, self.__promise__(resultclass, k, v))
34  
-	
  27
+
35 28
         def __promise__(self, klass, funcname, func):
36  
-        
37  
-            """
38  
-            This function builds a wrapper around some magic method and
39  
-            registers that magic method for the given type and methodname.
40  
-            """
41  
-    
  29
+            # Builds a wrapper around some magic method and registers that magic
  30
+            # method for the given type and method name.
42 31
             def __wrapper__(*args, **kw):
43  
-                """
44  
-                This wrapper function automatically triggers the evaluation of
45  
-                a lazy value. It then applies the given magic method of the
46  
-                result type.
47  
-                """
  32
+                # Automatically triggers the evaluation of a lazy value and
  33
+                # applies the given magic method of the result type.
48 34
                 res = self.__func(*self.__args, **self.__kw)
49 35
                 return self.__dispatch[type(res)][funcname](res, *args, **kw)
50  
-  
  36
+
51 37
             if not self.__dispatch.has_key(klass):
52 38
                 self.__dispatch[klass] = {}
53 39
             self.__dispatch[klass][funcname] = func
54 40
             return __wrapper__
55  
-  
  41
+
56 42
     def __wrapper__(*args, **kw):
57  
-        """
58  
-        This wrapper function just creates the proxy object that is returned
59  
-        instead of the actual value.
60  
-        """
  43
+        # Creates the proxy object, instead of the actual value.
61 44
         return __proxy__(args, kw)
62 45
 
63 46
     return __wrapper__
64  
-
65  
-
11  docs/settings.txt
@@ -355,12 +355,13 @@ See http://www.thaiopensource.com/relaxng/jing.html .
355 355
 LANGUAGE_CODE
356 356
 -------------
357 357
 
358  
-Default: ``'en'``
  358
+Default: ``'en-us'``
359 359
 
360  
-A string representing the language code for this installation. This should
361  
-be in locale format, that's 'en_US' for us-english. If you want to send
362  
-out the language in your HTML code, use the LANGUAGE_CODE attribute of the
363  
-request, instead, as the chosen language will depend on the browsers settings.
  360
+A string representing the language code for this installation. This should be
  361
+in standard language format. For example, U.S. English is ``"en-us"``. See the
  362
+`internationalization docs`_.
  363
+
  364
+.. _internationalization docs: http://www.djangoproject.com/documentation/i18n/
364 365
 
365 366
 MANAGERS
366 367
 --------

0 notes on commit e19c9cc

Please sign in to comment.
Something went wrong with that request. Please try again.