From 00466bf22d35b1d95306cdc40ec30ebfddca6126 Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 6 Apr 2021 13:56:06 -0500 Subject: [PATCH] Update and improve documentation for API.mentions_timeline Automatically use docstring for documentation Improve method and documentation order Add documentation for trim_user and include_entities parameters Improve parameter order in documentation --- docs/api.rst | 12 ++---------- tweepy/api.py | 35 ++++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 440648e..00d7081 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -21,6 +21,8 @@ Timeline methods .. automethod:: API.home_timeline +.. automethod:: API.mentions_timeline + .. method:: API.statuses_lookup(id_, [include_entities], [trim_user], [map_], \ [include_ext_alt_text], [include_card_uri]) @@ -72,16 +74,6 @@ Timeline methods :rtype: list of :class:`Status` objects -.. method:: API.mentions_timeline([since_id], [max_id], [count]) - - Returns the 20 most recent mentions, including retweets. - - :param since_id: |since_id| - :param max_id: |max_id| - :param count: |count| - :rtype: list of :class:`Status` objects - - Status methods -------------- diff --git a/tweepy/api.py b/tweepy/api.py index f065276..012bc1c 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -279,6 +279,30 @@ class API: ), **kwargs ) + @pagination(mode='id') + @payload('status', list=True) + def mentions_timeline(self, **kwargs): + """mentions_timeline(*, count, since_id, max_id, trim_user, \ + include_entities) + + Returns the 20 most recent mentions, including retweets. + + :param count: |count| + :param since_id: |since_id| + :param max_id: |max_id| + :param trim_user: |trim_user| + :param include_entities: |include_entities| + + :rtype: list of :class:`Status` objects + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-mentions_timeline + """ + return self.request( + 'GET', 'statuses/mentions_timeline', endpoint_parameters=( + 'count', 'since_id', 'max_id', 'trim_user', 'include_entities' + ), **kwargs + ) + @payload('status', list=True) def statuses_lookup(self, id, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-lookup @@ -302,17 +326,6 @@ class API: ), **kwargs ) - @pagination(mode='id') - @payload('status', list=True) - def mentions_timeline(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-mentions_timeline - """ - return self.request( - 'GET', 'statuses/mentions_timeline', endpoint_parameters=( - 'count', 'since_id', 'max_id', 'trim_user', 'include_entities' - ), **kwargs - ) - @pagination(mode='id') @payload('status', list=True) def retweets_of_me(self, **kwargs): -- 2.25.1