Browse Source

Adding more documentation and examples

Matt Sparks 15 years ago
parent
commit
db25e1180e
8 changed files with 63 additions and 10 deletions
  1. 13 1
      alphasign/charsets.py
  2. 24 1
      alphasign/colors.py
  3. 12 0
      alphasign/modes.py
  4. 6 0
      alphasign/string.py
  5. 5 2
      alphasign/text.py
  6. 0 1
      docs/charsets.rst
  7. 0 1
      docs/colors.rst
  8. 3 4
      docs/counters.rst

+ 13 - 1
alphasign/charsets.py

@@ -1,5 +1,7 @@
 """
-Character sets can be used to change the font style in TEXT and STRING files.
+Character sets can be used to change the font style in TEXT
+(:class:`alphasign.text.Text`) and STRING (:class:`alphasign.string.String`)
+files.
 
 The following character set constants are defined:
 
@@ -24,6 +26,16 @@ The following character sets are available only on Alpha 2.0 and 3.0 protocols:
 * :const:`SEVEN_HIGH_CUST`
 * :const:`TEN_HIGH_CUST`
 * :const:`FIFTEEN_HIGH_CUST`
+
+--------
+Examples
+--------
+
+Make a text file using the :const:`FIVE_WIDE` charset::
+
+  msg = alphasign.Text("%sthis is wide" % alphasign.charsets.FIVE_WIDE,
+                       label="A")
+
 """
 
 # Character sets

+ 24 - 1
alphasign/colors.py

@@ -1,5 +1,6 @@
 """
-The following constants are defined to change TEXT colors:
+The following constants are defined to change TEXT
+(:class:`alphasign.text.Text`) colors:
 
 * :const:`RED`
 * :const:`GREEN`
@@ -13,6 +14,28 @@ The following constants are defined to change TEXT colors:
 * :const:`RAINBOW_2`
 * :const:`COLOR_MIX`
 * :const:`AUTOCOLOR`
+
+.. autofunction:: rgb
+.. autofunction:: shadow_rgb
+
+--------
+Examples
+--------
+
+Make a text file with red text::
+
+  msg = alphasign.Text("%sthis text is red" % alphasign.colors.RED, label="A")
+
+Make a text file with purple text (#CC66FF)::
+
+  msg = alphasign.Text("%sthis text should be in purple" %
+                       alphasign.colors.rgb("CC66FF"), label="A")
+
+Make a bi-color text file (red primary with a green shadow)::
+
+  msg = alphasign.Text("%s%sred and green" %
+                       (alphasign.colors.rgb("FF0000"),
+                        alphasign.colors.rgb("00FF00")), label="A")
 """
 
 # Colors

+ 12 - 0
alphasign/modes.py

@@ -52,6 +52,18 @@ following special graphics are defined:
 * :const:`TURBO_CAR`
 * :const:`BALLOON_ANIMATION`
 * :const:`CHERRY_BOMB`
+
+--------
+Examples
+--------
+
+Make a text file stationary on the sign::
+
+  msg = alphasign.Text("hello world", label="A", mode=alphasign.modes.HOLD)
+
+To change the mode for an already created text file, do::
+
+  msg.mode = alphasign.modes.ROLL_IN
 """
 
 # Normal display modes

+ 6 - 0
alphasign/string.py

@@ -3,7 +3,13 @@ from packet import Packet
 
 
 class String(object):
+  """Class representing a STRING file."""
   def __init__(self, data=None, label=None, size=None):
+    """
+    :param data: initial string to insert into object
+    :param label: file label (default: "1")
+    :param size: maximum size of string data in bytes (default: 32)
+    """
     if data is None:
       data = ""
     if label is None:

+ 5 - 2
alphasign/text.py

@@ -5,12 +5,15 @@ from packet import Packet
 
 
 class Text(object):
-  """Class representing a TEXT file."""
+  """Class representing a TEXT file.
+
+  This class is aliased as :class:`alphasign.Text` in :mod:`alphasign.__init__`.
+  """
   def __init__(self, data=None, label=None, size=None,
                position=None, mode=None):
     """
     :param data: initial string to insert into object
-    :param label: file label: (default: "A")
+    :param label: file label (default: "A")
     :param size: amount of bytes to allocate for object on sign (default: 64)
     :param position: constant from :mod:`alphasign.positions`
     :param mode: constant from :mod:`alphasign.modes`

+ 0 - 1
docs/charsets.rst

@@ -2,5 +2,4 @@ Character sets
 ==============
 
 .. automodule:: alphasign.charsets
-  :members:
 

+ 0 - 1
docs/colors.rst

@@ -2,5 +2,4 @@ Colors
 ======
 
 .. automodule:: alphasign.colors
-  :members:
 

+ 3 - 4
docs/counters.rst

@@ -1,7 +1,6 @@
-Modes
-=====
+Counters
+========
 
-.. automodule:: alphasign.modes
+.. automodule:: alphasign.counters
   :members:
-  :undoc-members: