]> jfr.im git - z_archive/twitter.git/commitdiff
Improve documentation. twitter-1.6
authorMike Verdone <redacted>
Tue, 29 Mar 2011 20:08:44 +0000 (22:08 +0200)
committerMike Verdone <redacted>
Tue, 29 Mar 2011 20:08:44 +0000 (22:08 +0200)
twitter/__init__.py
twitter/stream.py

index 8f311815ffa0ef703a60971ea04fe72ea477552b..d48fd9bfc394c1c71da03d7d592153217144a5a3 100644 (file)
@@ -1,15 +1,55 @@
 """
 The minimalist yet fully featured Twitter API and Python toolset.
 
-The Twitter class is the key to building your own Twitter-enabled
-applications. Get help on it like this::
-
-    help(twitter.Twitter)
-
+The Twitter and TwitterStream classes are the key to building your own
+Twitter-enabled applications.
 
 """
 
 from .api import Twitter, TwitterError, TwitterHTTPError, TwitterResponse
-from .auth import NoAuth
+from .auth import NoAuth, UserPassAuth
 from .oauth import OAuth, read_token_file, write_token_file
 from .stream import TwitterStream
+
+
+# Who needs Sphinx? Not me!
+
+__doc__ += """
+The Twitter class
+=================
+"""
+__doc__ += Twitter.__doc__
+
+__doc__ += """
+The TwitterStream class
+=======================
+"""
+__doc__ += TwitterStream.__doc__
+
+
+__doc__ += """
+Twitter Response Objects
+========================
+"""
+__doc__ += TwitterResponse.__doc__
+
+
+__doc__ += """
+Authentication Objects
+======================
+
+You can authenticate with Twitter in three ways: NoAuth, OAuth, or
+UserPassAuth. Get help() on these classes to learn how to use them.
+
+
+Other things
+============
+
+read_token_file and write_token_file are utility methods to read and
+write OAuth token and secret key values. The values are stored as
+strings in the file. Not terribly exciting.
+"""
+
+__all__ = ["Twitter", "TwitterStream", "TwitterResponse", "TwitterError",
+           "TwitterHTTPError", "NoAuth", "OAuth", "UserPassAuth",
+           "read_token_file", "write_token_file"]
index 2c609187f7cda41b6f9870e65088df10e478a055..295e49062ea6187747a502efb395cc75240bc3ad 100644 (file)
@@ -35,6 +35,21 @@ class TwitterStreamCall(TwitterCall):
         return iter(TwitterJSONIter(handle, uri, arg_data))
 
 class TwitterStream(TwitterStreamCall):
+    """
+    Interface to the Twitter Stream API (stream.twitter.com). This can
+    be used pretty much the same as the Twitter class except the
+    result of calling a method will be an iterator that yields objects
+    decoded from the stream. For example::
+
+        twitter_stream = TwitterStream(auth=UserPassAuth('joe', 'joespassword'))
+        iterator = twitter_stream.statuses.sample()
+
+        for tweet in iterator:
+            ...do something with this tweet...
+
+    The iterator will yield tweets forever and ever (until the stream
+    breaks at which point it raises a TwitterHTTPError.)
+    """
     def __init__(
         self, domain="stream.twitter.com", secure=False, auth=None,
         api_version='1'):