From: Harmon Date: Sun, 26 Sep 2021 07:39:15 +0000 (-0500) Subject: Use sphinx-tabs for Models Reference and Pagination documentation X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8d6d51d528b86755e467cd810177ba585c4a8b73;p=tweepy.git Use sphinx-tabs for Models Reference and Pagination documentation --- diff --git a/docs/conf.py b/docs/conf.py index 160c289..fa7f644 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -30,7 +30,8 @@ extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.autosectionlabel', 'sphinx.ext.intersphinx', - 'sphinx.ext.napoleon' + 'sphinx.ext.napoleon', + 'sphinx_tabs.tabs' ] hoverxref_auto_ref = True diff --git a/docs/models.rst b/docs/models.rst index 7c04db9..650ea63 100644 --- a/docs/models.rst +++ b/docs/models.rst @@ -4,76 +4,76 @@ Models Reference **************** -API v1.1 -======== +.. tabs:: -.. class:: tweepy.models.BoundingBox + .. group-tab:: API v1.1 - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/geo#bounding-box + .. class:: tweepy.models.BoundingBox -.. class:: tweepy.models.DirectMessage + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/geo#bounding-box - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/guides/message-create-object + .. class:: tweepy.models.DirectMessage -.. class:: tweepy.models.Friendship + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/guides/message-create-object - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friendships-show#example-response + .. class:: tweepy.models.Friendship -.. class:: tweepy.models.List + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friendships-show#example-response - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-show#example-response + .. class:: tweepy.models.List -.. class:: tweepy.models.Media + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-show#example-response - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/entities#media + .. class:: tweepy.models.Media -.. class:: tweepy.models.Place + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/entities#media - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/geo#place + .. class:: tweepy.models.Place -.. class:: tweepy.models.Relationship + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/geo#place - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friendships-lookup#example-response + .. class:: tweepy.models.Relationship -.. class:: tweepy.models.SavedSearch + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friendships-lookup#example-response - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-show-id#example-response + .. class:: tweepy.models.SavedSearch -.. class:: tweepy.models.SearchResults + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-show-id#example-response - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets#example-response + .. class:: tweepy.models.SearchResults -.. class:: tweepy.models.Status + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets#example-response - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/tweet + .. class:: tweepy.models.Status -.. class:: tweepy.models.User + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/tweet - :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/user + .. class:: tweepy.models.User -API v2 -====== + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/user -.. class:: tweepy.Media + .. group-tab:: API v2 - :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/media + .. class:: tweepy.Media -.. class:: tweepy.Place + :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/media - :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/place + .. class:: tweepy.Place -.. class:: tweepy.Poll + :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/place - :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/poll + .. class:: tweepy.Poll -.. class:: tweepy.ReferencedTweet + :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/poll - :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet + .. class:: tweepy.ReferencedTweet -.. class:: tweepy.Tweet + :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet - :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet + .. class:: tweepy.Tweet -.. class:: tweepy.User + :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet - :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/user + .. class:: tweepy.User + + :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/user diff --git a/docs/pagination.rst b/docs/pagination.rst index 936f974..a96f36a 100644 --- a/docs/pagination.rst +++ b/docs/pagination.rst @@ -6,49 +6,52 @@ Pagination ********** -API v1.1 -======== +.. tabs:: -.. autoclass:: Cursor - :members: + .. group-tab:: API v1.1 + + .. autoclass:: Cursor + :members: + + .. group-tab:: API v2 + + .. autoclass:: Paginator + :members: Example ------- -:: +.. tabs:: - import tweepy + .. group-tab:: API v1.1 - auth = tweepy.AppAuthHandler("Consumer Key here", "Consumer Secret here") - api = tweepy.API(auth) + :: - for status in tweepy.Cursor(api.search_tweets, "Tweepy", - count=100).items(250): - print(status.id) + import tweepy - for page in tweepy.Cursor(api.get_followers, screen_name="TwitterDev", - count=200).pages(5): - print(len(page)) + auth = tweepy.AppAuthHandler("Consumer Key here", "Consumer Secret here") + api = tweepy.API(auth) -API v2 -====== + for status in tweepy.Cursor(api.search_tweets, "Tweepy", + count=100).items(250): + print(status.id) -.. autoclass:: Paginator - :members: + for page in tweepy.Cursor(api.get_followers, screen_name="TwitterDev", + count=200).pages(5): + print(len(page)) -Example -------- + .. group-tab:: API v2 -:: + :: - import tweepy + import tweepy - client = tweepy.Client("Bearer Token here") + client = tweepy.Client("Bearer Token here") - for response in tweepy.Paginator(client.get_users_followers, 2244994945, - max_results=1000, limit=5): - print(response.meta) + for response in tweepy.Paginator(client.get_users_followers, 2244994945, + max_results=1000, limit=5): + print(response.meta) - for tweet in tweepy.Paginator(client.search_recent_tweets, "Tweepy", - max_results=100).flatten(limit=250): - print(tweet.id) + for tweet in tweepy.Paginator(client.search_recent_tweets, "Tweepy", + max_results=100).flatten(limit=250): + print(tweet.id) diff --git a/docs/requirements.txt b/docs/requirements.txt index c1935e0..23a89d4 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,5 @@ myst-parser==0.15.2 sphinx==4.2.0 sphinx-hoverxref==0.7b1 +sphinx-tabs==3.2.0 sphinx_rtd_theme==1.0.0