Parcourir la source

Improves source guide examples

Ask Solem il y a 13 ans
Parent
commit
e89701ccce
2 fichiers modifiés avec 31 ajouts et 22 suppressions
  1. 7 8
      docs/configuration.rst
  2. 24 14
      docs/internals/guide.rst

+ 7 - 8
docs/configuration.rst

@@ -554,47 +554,47 @@ This backend requires the following configuration directives to be set.
 CASSANDRA_SERVERS
 ~~~~~~~~~~~~~~~~~
 
-List of `host:port` Cassandra servers. e.g. `["localhost:9160]"`.
+List of ``host:port`` Cassandra servers. e.g. ``["localhost:9160]"``.
 
 .. setting:: CASSANDRA_KEYSPACE
 
 CASSANDRA_KEYSPACE
 ~~~~~~~~~~~~~~~~~~
 
-The keyspace in which to store the results. e.g. `"tasks_keyspace"`.
+The keyspace in which to store the results. e.g. ``"tasks_keyspace"``.
 
 .. setting:: CASSANDRA_COLUMN_FAMILY
 
 CASSANDRA_COLUMN_FAMILY
 ~~~~~~~~~~~~~~~~~~~~~~~
 
-The column family in which to store the results. eg `"tasks"`
+The column family in which to store the results. eg ``"tasks"``
 
 .. setting:: CASSANDRA_READ_CONSISTENCY
 
 CASSANDRA_READ_CONSISTENCY
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-The read consistency used. Values can be `"ONE"`, `"QUORUM"` or `"ALL"`.
+The read consistency used. Values can be ``"ONE"``, ``"QUORUM"`` or ``"ALL"``.
 
 .. setting:: CASSANDRA_WRITE_CONSISTENCY
 
 CASSANDRA_WRITE_CONSISTENCY
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-The write consistency used. Values can be `"ONE"`, `"QUORUM"` or `"ALL"`.
+The write consistency used. Values can be ``"ONE"``, ``"QUORUM"`` or ``"ALL"``.
 
 .. setting:: CASSANDRA_DETAILED_MODE
 
 CASSANDRA_DETAILED_MODE
 ~~~~~~~~~~~~~~~~~~~~~~~
 
-Enable or disable detailed mode. Default is `"False"`.
+Enable or disable detailed mode. Default is :const:`False`.
 This mode allows to use the power of Cassandra wide columns to
 store all states for a task as a wide column, instead of only the last one.
 
 To use this mode, you need to configure your ColumnFamily to
-use the `TimeUUID` type as a comparator::
+use the ``TimeUUID`` type as a comparator::
 
     create column family task_results with comparator = TimeUUIDType;
 
@@ -610,7 +610,6 @@ Example configuration
     CASSANDRA_WRITE_CONSISTENCY = "ONE"
     CASSANDRA_DETAILED_MODE = True
 
-
 .. _conf-messaging:
 
 Message Routing

+ 24 - 14
docs/internals/guide.rst

@@ -33,22 +33,31 @@ Naming
 
 - Follows :pep:`8`.
 
-- Class names must be CamelCase.
-- but not if they are verbs, verbs shall be lower_case:
+- Class names must be `CamelCase`.
+- but not if they are verbs, verbs shall be `lower_case`:
 
     .. code-block:: python
 
-        class TestFrobulator(Case):         # BAD
-            ...
+        # - test case for a class
+        class TestMyClass(Case):                # BAD
+            pass
 
-        class test_Frobulator(Case):        # GOOD
-            ...
+        class test_MyClass(Case):               # GOOD
+            pass
 
-        class CreateContext(object):        # BAD
-            ...
+        # - test case for a function
+        class TestMyFunction(Case):             # BAD
+            pass
 
-        class create_context(object):       # GOOD
-            ...
+        class test_my_function(Case):           # GOOD
+            pass
+
+        # - "action" class (verb)
+        class UpdateTwitterStatus(object):    # BAD
+            pass
+
+        class update_twitter_status(object):    # GOOD
+            pass
 
     .. note::
 
@@ -58,7 +67,7 @@ Naming
         :class:`~celery.task.sets.subtask`, :class:`~celery.task.chords.chord`,
         ``inspect``, :class:`~kombu.utils.functional.promise` and more..
 
-- Factory functions and methods must be CamelCase (excluding verbs):
+- Factory functions and methods must be `CamelCase` (excluding verbs):
 
     .. code-block:: python
 
@@ -68,6 +77,7 @@ Naming
                 ...
 
             def Consumer(self):             # GOOD
+                ...
 
 Default values
 ~~~~~~~~~~~~~~
@@ -137,10 +147,10 @@ the exception class from the instance directly.
 Composites
 ~~~~~~~~~~
 
-Similarly to exceptions, composite classes used should be override-able by
-inheritance and/or instantiation.  Common sense should be used when
+Similarly to exceptions, composite classes should be override-able by
+inheritance and/or instantiation.  Common sense can be used when
 selecting what classes to include, but often it's better to add one
-too many as predicting what users need to override is hard (this has
+too many: predicting what users need to override is hard (this has
 saved us from many a monkey patch).
 
 **Example**: