Skip to content

Commit 0057322

Browse files
committed
adds more documentation and cleans up some of the inline-documentation
1 parent 674b291 commit 0057322

11 files changed

Lines changed: 267 additions & 83 deletions

File tree

doc/conf.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14-
import sys, os
14+
import sys
15+
import os
16+
import shlex
17+
18+
sys.path.append(os.path.abspath('../'))
1519

1620
# If extensions (or modules to document with autodoc) are in another directory,
1721
# add these directories to sys.path here. If the directory is relative to the
@@ -25,7 +29,12 @@
2529

2630
# Add any Sphinx extension module names here, as strings. They can be extensions
2731
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
28-
extensions = []
32+
extensions = [
33+
'sphinx.ext.autodoc',
34+
'sphinx.ext.coverage',
35+
'sphinx.ext.viewcode',
36+
'sphinx.ext.napoleon'
37+
]
2938

3039
# Add any paths that contain templates here, relative to this directory.
3140
templates_path = ['_templates']
@@ -41,16 +50,16 @@
4150

4251
# General information about the project.
4352
project = u'python-twitter'
44-
copyright = u'2013, python-twitter@googlegroups.com'
53+
copyright = u'2016, python-twitter@googlegroups.com'
4554

4655
# The version info for the project you're documenting, acts as replacement for
4756
# |version| and |release|, also used in various other places throughout the
4857
# built documents.
4958
#
5059
# The short X.Y version.
51-
version = '1.0'
60+
version = '3.0rc1'
5261
# The full version, including alpha/beta/rc tags.
53-
release = '1.0'
62+
release = '3.0rc1'
5463

5564
# The language for content autogenerated by Sphinx. Refer to documentation
5665
# for a list of supported languages.
@@ -94,7 +103,7 @@
94103

95104
# The theme to use for HTML and HTML Help pages. See the documentation for
96105
# a list of builtin themes.
97-
html_theme = 'default'
106+
html_theme = 'sphinx_rtd_theme'
98107

99108
# Theme options are theme-specific and customize the look and feel of a theme
100109
# further. For a list of options available for each theme, see the

doc/index.rst

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,29 @@
11
.. python-twitter documentation master file, created by
2-
sphinx-quickstart on Fri Aug 30 14:37:05 2013.
3-
You can adapt this file completely to your liking, but it should at least
4-
contain the root `toctree` directive.
52
63
Welcome to python-twitter's documentation!
74
==========================================
85
**A Python wrapper around the Twitter API.**
96

107
Author: The Python-Twitter Developers <python-twitter@googlegroups.com>
118

12-
Introduction
13-
------------
14-
This library provides a pure Python interface for the `Twitter API <https://dev.twitter.com/>`_. It works with Python version 2.6+. Python 3 support is under development.
15-
16-
`Twitter <http://twitter.com>`_ provides a service that allows people to connect via the web, IM, and SMS. Twitter exposes a `web services API <http://dev.twitter.com/doc>`_ and this library is intended to make it even easier for Python programmers to use.
17-
18-
19-
Building
20-
--------
21-
From source:
22-
23-
Install the dependencies:
24-
25-
- `Requests <http://docs.python-requests.org/en/latest/>`_
26-
- `Requests OAuthlib <https://requests-oauthlib.readthedocs.org/en/latest/>`_
27-
28-
Alternatively use `pip`::
29-
30-
$ pip install -r requirements.txt
31-
32-
Download the latest `python-twitter` library from: http://code.google.com/p/python-twitter/
33-
34-
Extract the source distribution and run::
35-
36-
$ python setup.py build
37-
$ python setup.py install
38-
399

40-
Testing
41-
-------
42-
With setuptools installed::
10+
Contents:
4311

44-
$ python setup.py test
45-
46-
47-
Without setuptools installed::
48-
49-
$ python twitter_test.py
50-
51-
52-
Getting the code
53-
----------------
54-
The code is hosted at `Github <https://github.com/bear/python-twitter>`_.
55-
56-
Check out the latest development version anonymously with::
12+
.. toctree::
13+
:maxdepth: 1
5714

58-
$ git clone git://github.com/bear/python-twitter.git
59-
$ cd python-twitter
15+
installation.rst
16+
migration_v30.rst
17+
models.rst
18+
searching.rst
19+
with_django.rst
6020

6121

62-
.. toctree::
63-
:maxdepth: 2
22+
Introduction
23+
------------
24+
This library provides a pure Python interface for the `Twitter API <https://dev.twitter.com/>`_. It works with Python 2.7+ and Python 3.
6425

26+
`Twitter <http://twitter.com>`_ provides a service that allows people to connect via the web, IM, and SMS. Twitter exposes a `web services API <http://dev.twitter.com/doc>`_ and this library is intended to make it even easier for Python programmers to use.
6527

6628

6729
Indices and tables
@@ -70,4 +32,3 @@ Indices and tables
7032
* :ref:`genindex`
7133
* :ref:`modindex`
7234
* :ref:`search`
73-

doc/installation.rst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Installation & Testing
2+
------------
3+
4+
Installation
5+
============
6+
7+
**From PyPI** ::
8+
9+
$ pip install python-twitter
10+
11+
12+
**From source**
13+
14+
Install the dependencies:
15+
16+
- `Requests <http://docs.python-requests.org/en/latest/>`_
17+
- `Requests OAuthlib <https://requests-oauthlib.readthedocs.org/en/latest/>`_
18+
19+
Alternatively use `pip`::
20+
21+
$ pip install -r requirements.txt
22+
23+
Download the latest `python-twitter` library from: https://github.com/bear/python-twitter/
24+
25+
Extract the source distribution and run::
26+
27+
$ python setup.py build
28+
$ python setup.py install
29+
30+
31+
Testing
32+
=======
33+
34+
Run::
35+
36+
$ python test.py
37+
38+
If you would like to see coverage information and have `Nose <https://nose.readthedocs.org>`_ installed::
39+
40+
$ nosetests --with-coverage
41+
42+
43+
Getting the code
44+
================
45+
46+
The code is hosted at `Github <https://github.com/bear/python-twitter>`_.
47+
48+
Check out the latest development version anonymously with::
49+
50+
$ git clone git://github.com/bear/python-twitter.git
51+
$ cd python-twitter

doc/migration_v30.rst

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,70 @@
1+
Migration from v2 to v3
2+
-----------------------
3+
4+
15
Changes to Existing Methods
26
===========================
37

4-
GetFollowers():
5-
* Method no longer honors a `count` or `cursor` parameter. These have been deprecated in favor of making this method explicitly a convenience function to return a list of every `twitter.User` who is following the specified or authenticated user. A warning will be raised if `count` or `cursor` is passed with the expectation that breaking behavior will be introduced in a later version.
6-
* Method now takes an optional parameter of `total_count`, which limits the number of users to return. If this is not set, the data returned will be all users following the specified user.
7-
* The kwarg `include_user_entities` now defaults to True. This was set to False previously, but would not be included in query parameters sent to Twitter. Without the query parameter in the URL, Twitter would default to returning user_entities, so this change makes this behavior explicit.
8+
GetSearch()
9+
++++++++++++++++++++++++++++
10+
* Adds ``raw_query`` method. See :ref:`raw_queries` for more information.
811

9-
GetFriends():
10-
* Method no longer honors a `count` or `cursor` parameter. These have been deprecated in favor of making this method explicitly a convenience function to return a list of every `twitter.User` who is followed by the specified or authenticated user. A warning will be raised if `count` or `cursor` is passed with the expectation that breaking behavior will be introduced in a later version.
11-
* Method now takes an optional parameter of `total_count`, which limits the number of users to return. If this is not set, the data returned will be all users followed by the specified user.
12-
* The kwarg `include_user_entities` now defaults to True. This was set to False previously, but would not be included in query parameters sent to Twitter. Without the query parameter in the URL, Twitter would default to returning user_entities, so this change makes this behavior explicit.
12+
GetFollowers()
13+
++++++++++++++++++++++++++++
14+
* Method no longer honors a ``count`` or ``cursor`` parameter. These have been deprecated in favor of making this method explicitly a convenience function to return a list of every ``twitter.User`` who is following the specified or authenticated user. A warning will be raised if ``count`` or ``cursor`` is passed with the expectation that breaking behavior will be introduced in a later version.
15+
* Method now takes an optional parameter of ``total_count``, which limits the number of users to return. If this is not set, the data returned will be all users following the specified user.
16+
* The kwarg ``include_user_entities`` now defaults to ``True``. This was set to ``False`` previously, but would not be included in query parameters sent to Twitter. Without the query parameter in the URL, Twitter would default to returning user_entities, so this change makes this behavior explicit.
1317

14-
GetFriendsPaged():
15-
* The third value of the tuple returned by this method is now a list of twitter.User objects in accordance with its doc string rather than the raw data from API. Closes #277
16-
* The kwarg `include_user_entities` now defaults to True. This was set to False previously, but would not be included in query parameters sent to Twitter. Without the query parameter in the URL, Twitter would default to returning user_entities, so this change makes this behavior explicit.
18+
GetFriends()
19+
++++++++++++++++++++++++++++
20+
* Method no longer honors a ``count`` or ``cursor`` parameter. These have been deprecated in favor of making this method explicitly a convenience function to return a list of every ``twitter.User`` who is followed by the specified or authenticated user. A warning will be raised if ``count`` or ``cursor`` is passed with the expectation that breaking behavior will be introduced in a later version.
21+
* Method now takes an optional parameter of ``total_count``, which limits the number of users to return. If this is not set, the data returned will be all users followed by the specified user.
22+
* The kwarg ``include_user_entities`` now defaults to ``True``. This was set to ``False`` previously, but would not be included in query parameters sent to Twitter. Without the query parameter in the URL, Twitter would default to returning user_entities, so this change makes this behavior explicit.
1723

18-
GetFollowersPaged():
19-
* The third value of the tuple returned by this method is now a list of twitter.User objects in accordance with its doc string rather than the raw data from API. Closes #277
20-
* The kwarg `include_user_entities` now defaults to True. This was set to False previously, but would not be included in query parameters sent to Twitter. Without the query parameter in the URL, Twitter would default to returning user_entities, so this change makes this behavior explicit and consistent with the previously ambiguous behavior.
24+
GetFriendsPaged()
25+
++++++++++++++++++++++++++++
26+
* The third value of the tuple returned by this method is now a list of twitter.User objects in accordance with its doc string rather than the raw data from API.
27+
* The kwarg ``include_user_entities`` now defaults to ``True``. This was set to ``False`` previously, but would not be included in query parameters sent to Twitter. Without the query parameter in the URL, Twitter would default to returning user_entities, so this change makes this behavior explicit.
2128

22-
GetSearch():
23-
* You can now specify a user for whom you wish to limit the search. For example, to only get tweets from the user `twitterapi`, you can call `GetSearch(who='twitterapi')` and only that account's tweets will be returned.
29+
GetFollowersPaged()
30+
++++++++++++++++++++++++++++
31+
* The third value of the tuple returned by this method is now a list of twitter.User objects in accordance with its doc string rather than the raw data from API.
32+
* The kwarg ``include_user_entities`` now defaults to ``True``. This was set to ``False`` previously, but would not be included in query parameters sent to Twitter. Without the query parameter in the URL, Twitter would default to returning user_entities, so this change makes this behavior explicit and consistent with the previously ambiguous behavior.
2433

25-
GetUserStream():
34+
GetUserStream()
35+
++++++++++++++++++++++++++++
2636
* Parameter 'stall_warning' is now 'stall_warnings' in line with GetStreamFilter and Twitter's naming convention. This should now actually return stall warnings, whereas it did not have any effect previously.
2737

38+
PostUpdate()
39+
++++++++++++
40+
* Now accepts three new parameters: ``media``, ``media_additional_owners``, and ``media_category``. ``media`` can be a URL, a local file, or a file-like object (something with a ``read()`` method), or a list of any combination of the above.
41+
* ``media_additional_owners`` should be a list of user ids representing Twitter users that should be able to use the uploaded media in their tweets. If you pass a list of media, then **additional owners will apply to each object.** If you need more granular control, please use the UploadMedia* methods.
42+
* ``media_category``: Only for use with the AdsAPI. See https://dev.twitter.com/ads/creative/promoted-video-overview if this applies to your application.
43+
2844

2945
Deprecation
3046
===========
3147

32-
PostMedia():
48+
PostMedia()
49+
++++++++++++++++++++++++++++
3350
* This endpoint is deprecated by Twitter. Python-twitter will throw a warning about using the method and advise you to use PostUpdate() instead. There is no schedule for when this will be removed from Twitter.
3451

52+
PostMultipleMedia()
53+
+++++++++++++++++++
54+
* This method should be replaced by passing a list of media objects (either URLs, local files, or file-like objects) to PostUpdate. You are limited to a maximum of 4 media files per tweet.
55+
3556

3657
New Methods
3758
===========
3859

39-
UploadMediaChunked():
40-
* API method allows chunked upload to upload.twitter.com. Similar to Api.PostMedia(), this method can take either a local filename (str), a URL (str), or a file-like object. The image or video type will be determined by `mimetypes` (see twitter/twitter_utils.py for details).
60+
UploadMediaChunked()
61+
++++++++++++++++++++++++++++
62+
* API method allows chunked upload to upload.twitter.com. Similar to Api.PostMedia(), this method can take either a local filename (str), a URL (str), or a file-like object. The image or video type will be determined by ``mimetypes`` (see :py:func:`twitter.twitter_utils.parse_media_file` for details).
4163
* Optionally, you can specify a chunk_size for uploads when instantiating the Api object. This should be given in bytes. The default is 1MB (that is, 1048576 bytes). Any chunk_size given below 16KB will result in a warning: Twitter will return an error if you try to upload more than 999 chunks of data; for example, if you are uploading a 15MB video, then a chunk_size lower than 15729 bytes will result in 1000 APPEND commands being sent to the API, so you'll get an error. 16KB seems like a reasonable lower bound, but if your use case is well-defined, then python-twitter will not enforce this behavior.
4264
* Another thing to take into consideration: if you're working in a RAM-constrained environment, a very large chunk_size will increase your RAM usage when uploading media through this endpoint.
43-
* The return value will be the media_id of the uploaded file.
65+
* The return value will be the ``media_id`` of the uploaded file.
4466

45-
UploadMediaSimple():
67+
UploadMediaSimple()
68+
++++++++++++++++++++++++++++
4669
* Provides the ability to upload a single media file to Twitter without using the ChunkedUpload endpoint. This method should be used on smaller files and reduces the roundtrips from Twitter from three (for UploadMediaChunked) to one.
47-
* Return value is the `media_id` of the uploaded file.
70+
* Return value is the ``media_id`` of the uploaded file.

doc/models.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Models
2+
======
3+
4+
Python-twitter provides the following models of the objects returned by the Twitter API:
5+
6+
* :py:mod:`twitter.category.Category`
7+
* :py:mod:`twitter.direct_message.DirectMessage`
8+
* :py:mod:`twitter.hashtag.Hashtag`
9+
* :py:mod:`twitter.list.List`
10+
* :py:mod:`twitter.media.Media`
11+
* :py:mod:`twitter.status.Status`
12+
* :py:mod:`twitter.trend.Trend`
13+
* :py:mod:`twitter.url.Url`
14+
* :py:mod:`twitter.user.User`
15+
* :py:mod:`twitter.user.UserStatus`
16+

doc/modules.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. _modules:
2+
3+
Modules
4+
*******
5+
6+
.. toctree::
7+
:maxdepth: 4
8+
9+
twitter
10+

doc/searching.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
.. _searching:
2+
3+
Searching
4+
+++++++++
5+
6+
7+
.. _raw_queries:
8+
19
Raw Queries
210
===========
311

@@ -7,4 +15,4 @@ For example, if you want to search for only tweets containing the word "twitter"
715

816
results = api.GetSearch(raw_query="q=twitter%20&result_type=recent&since=2014-07-19&count=100")
917

10-
If you want to build a search query and you're not quite sure how it should look all put together, you can use Twitter's Advanced Search tool: https://twitter.com/search-advanced, and then use the part of search URL after the "?" to use for the Api, removing the "&src=typd" portion.
18+
If you want to build a search query and you're not quite sure how it should look all put together, you can use Twitter's Advanced Search tool: https://twitter.com/search-advanced, and then use the part of search URL after the "?" to use for the Api, removing the ``&src=typd`` portion.

doc/twitter.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
python-twitter package
2+
=============
3+
4+
5+
twitter.api
6+
----------------
7+
8+
.. automodule:: twitter.api
9+
:members:
10+
:undoc-members:
11+
:show-inheritance:
12+
13+
.. automodule:: twitter.category
14+
:members:
15+
:undoc-members:
16+
:show-inheritance:
17+
18+
.. automodule:: twitter.direct_message
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
23+
.. automodule:: twitter.hashtag
24+
:members:
25+
:undoc-members:
26+
:show-inheritance:
27+
28+
.. automodule:: twitter.list
29+
:members:
30+
:undoc-members:
31+
:show-inheritance:
32+
33+
.. automodule:: twitter.media
34+
:members:
35+
:undoc-members:
36+
:show-inheritance:
37+
38+
.. automodule:: twitter.status
39+
:members:
40+
:undoc-members:
41+
:show-inheritance:
42+
43+
.. automodule:: twitter.trend
44+
:members:
45+
:undoc-members:
46+
:show-inheritance:
47+
48+
.. automodule:: twitter.url
49+
:members:
50+
:undoc-members:
51+
:show-inheritance:
52+
53+
.. automodule:: twitter.user
54+
:members:
55+
:undoc-members:
56+
:show-inheritance:
57+
58+
.. automodule:: twitter.twitter_utils
59+
:members:
60+
:undoc-members:
61+
:show-inheritance:

0 commit comments

Comments
 (0)