From 7d2f2441269fda71b72322825b5813a2aec4c7bd Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Wed, 13 Dec 2017 18:40:17 +0100 Subject: [PATCH] Add internal links in docs --- docs/index.rst | 34 ++++++- mastodon/Mastodon.py | 209 +++++++++++++++++++++---------------------- 2 files changed, 137 insertions(+), 106 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index da670b1..0c05321 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -156,6 +156,8 @@ and are parsed into python datetime objects. User dicts ~~~~~~~~~~ +.. _user dict: + .. code-block:: python mastodon.account() @@ -189,6 +191,8 @@ User dicts Toot dicts ~~~~~~~~~~ +.. _toot dict: + .. code-block:: python mastodon.toot("Hello from Python") @@ -222,6 +226,8 @@ Toot dicts Mention dicts ~~~~~~~~~~~~~ +.. _mention dict: + .. code-block:: python { @@ -233,6 +239,8 @@ Mention dicts Hashtag dicts ~~~~~~~~~~~~~ +.. _hashtag dict: + .. code-block:: python { @@ -242,6 +250,8 @@ Hashtag dicts Emoji dicts ~~~~~~~~~~~ +.. _emoji dict: + .. code-block:: python { @@ -252,6 +262,8 @@ Emoji dicts Relationship dicts ~~~~~~~~~~~~~~~~~~ +.. _relationship dict: + .. code-block:: python mastodon.account_follow() @@ -268,6 +280,8 @@ Relationship dicts Notification dicts ~~~~~~~~~~~~~~~~~~ +.. _notification dict: + .. code-block:: python mastodon.notifications()[0] @@ -283,6 +297,8 @@ Notification dicts Context dicts ~~~~~~~~~~~~~ +.. _context dict: + .. code-block:: python mastodon.status_context() @@ -294,6 +310,8 @@ Context dicts Media dicts ~~~~~~~~~~~ +.. _media dict: + .. code-block:: python mastodon.media_post("image.jpg", "image/jpeg") @@ -318,6 +336,8 @@ Media dicts Card dicts ~~~~~~~~~~ +.. _card dict: + .. code-block:: python mastodon.status_card(): @@ -342,9 +362,11 @@ Card dicts Search result dicts ~~~~~~~~~~~~~~~~~~~ +.. _search result dict: + .. code-block:: python - mastodon.search(...) + mastodon.search("") # Returns the folowing dictionary { 'accounts': # List of account dicts resulting from the query @@ -354,6 +376,8 @@ Search result dicts Instance dicts ~~~~~~~~~~~~~~ +.. _instance dict: + .. code-block:: python mastodon.instance() @@ -369,6 +393,8 @@ Instance dicts Report dicts ~~~~~~~~~~~~ +.. _report dict: + .. code-block:: python mastodon.reports()[0] @@ -404,6 +430,7 @@ is specified, Mastodon.py defaults to https. .. automethod:: Mastodon.create_app .. automethod:: Mastodon.__init__ +.. _log_in(): .. automethod:: Mastodon.log_in .. automethod:: Mastodon.auth_request_url @@ -434,10 +461,12 @@ Reading data: Timelines This function allows you to access the timelines a logged in user could see, as well as hashtag timelines and the public timeline. +.. _timeline(): .. automethod:: Mastodon.timeline .. automethod:: Mastodon.timeline_home .. automethod:: Mastodon.timeline_local .. automethod:: Mastodon.timeline_public +.. _timeline_hashtag(): .. automethod:: Mastodon.timeline_hashtag Reading data: Statuses @@ -518,6 +547,7 @@ Writing data: Statuses These functions allow you to post statuses to Mastodon and to interact with already posted statuses. +.. _status_post(): .. automethod:: Mastodon.status_post .. automethod:: Mastodon.toot .. automethod:: Mastodon.status_reblog @@ -562,6 +592,8 @@ This function allows you to upload media to Mastodon. The returned media IDs (Up to 4 at the same time) can then be used with post_status to attach media to statuses. +.. _media_post(): + .. automethod:: Mastodon.media_post Writing data: Reports diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 2e3935c..af450ec 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -72,16 +72,16 @@ class Mastodon: def create_app(client_name, scopes=['read', 'write', 'follow'], redirect_uris=None, website=None, to_file=None, api_base_url=__DEFAULT_BASE_URL, request_timeout=__DEFAULT_TIMEOUT): """ - Create a new app with given client_name and scopes (read, write, follow) + Create a new app with given `client_name` and `scopes` (read, write, follow) - Specify redirect_uris if you want users to be redirected to a certain page after authenticating. - Specify to_file to persist your apps info to a file so you can use them in the constructor. - Specify api_base_url if you want to register an app on an instance different from the flagship one. + Specify `redirect_uris` if you want users to be redirected to a certain page after authenticating. + Specify `to_file` to persist your apps info to a file so you can use them in the constructor. + Specify `api_base_url` if you want to register an app on an instance different from the flagship one. Presently, app registration is open by default, but this is not guaranteed to be the case for all future mastodon instances or even the flagship instance in the future. - Returns client_id and client_secret. + Returns `client_id` and `client_secret`, both as strings. """ api_base_url = Mastodon.__protocolize(api_base_url) @@ -118,13 +118,13 @@ class Mastodon: ratelimit_method="wait", ratelimit_pacefactor=1.1, request_timeout=__DEFAULT_TIMEOUT, mastodon_version=None): """ - Create a new API wrapper instance based on the given client_secret and client_id. If you - give a client_id and it is not a file, you must also give a secret. + Create a new API wrapper instance based on the given `client_secret` and `client_id`. If you + give a `client_id` and it is not a file, you must also give a secret. - You can also specify an access_token, directly or as a file (as written by log_in). + You can also specify an `access_token`, directly or as a file (as written by `log_in()`_). - Mastodon.py can try to respect rate limits in several ways, controlled by ratelimit_method. - "throw" makes functions throw a MastodonRatelimitError when the rate + Mastodon.py can try to respect rate limits in several ways, controlled by `ratelimit_method`. + "throw" makes functions throw a `MastodonRatelimitError` when the rate limit is hit. "wait" mode will, once the limit is hit, wait and retry the request as soon as the rate limit resets, until it succeeds. "pace" works like throw, but tries to wait in between calls so that the limit is generally not hit (How hard it tries to not hit the rate @@ -132,15 +132,15 @@ class Mastodon: even in "wait" and "pace" mode, requests can still fail due to network or other problems! Also note that "pace" and "wait" are NOT thread safe. - Specify api_base_url if you wish to talk to an instance other than the flagship one. - If a file is given as client_id, read client ID and secret from that file. + Specify `api_base_url` if you wish to talk to an instance other than the flagship one. + If a file is given as `client_id`, client ID and secret are read from that file. By default, a timeout of 300 seconds is used for all requests. If you wish to change this, - pass the desired timeout (in seconds) as request_timeout. + pass the desired timeout (in seconds) as `request_timeout`. - The mastodon_version parameter can be used to specify the version of Mastodon that Mastodon.py will + The `mastodon_version` parameter can be used to specify the version of Mastodon that Mastodon.py will expect to be installed on the server. The function will throw an error if an unparseable - Version is specified. If no version is specified, Mastodon.py will set mastodon_version to the + Version is specified. If no version is specified, Mastodon.py will set `mastodon_version` to the detected version. """ self.api_base_url = Mastodon.__protocolize(api_base_url) @@ -240,21 +240,21 @@ class Mastodon: code=None, redirect_uri="urn:ietf:wg:oauth:2.0:oob", refresh_token=None, scopes=['read', 'write', 'follow'], to_file=None): """ - Your username is the e-mail you use to log in into mastodon. + Get the access token for a user. + + The username is the e-mail used to log in into mastodon. - Can persist access token to file, to be used in the constructor. + Can persist access token to file `to_file`, to be used in the constructor. - Supports refresh_token but Mastodon.social doesn't implement it at the moment. - - Handles password, authorization_code, and refresh_token authentication. - - Will throw a MastodonIllegalArgumentError if username / password + Handles password and OAuth-based authorization. + + Will throw a `MastodonIllegalArgumentError` if username / password are wrong, scopes are not valid or granted scopes differ from requested. For OAuth2 documentation, compare https://github.com/doorkeeper-gem/doorkeeper/wiki/Interacting-as-an-OAuth-client-with-Doorkeeper - Returns the access token. + Returns the access token as a string. """ if username is not None and password is not None: params = self.__generate_params(locals(), ['scopes', 'to_file', 'code', 'refresh_token']) @@ -306,7 +306,7 @@ class Mastodon: """ Retrieve basic information about the instance, including the URI and administrative contact email. - Returns an instance dict. + Returns an `instance dict`_. """ return self.__instance() @@ -322,13 +322,13 @@ class Mastodon: @api_version("1.0.0") def timeline(self, timeline="home", max_id=None, since_id=None, limit=None): """ - Fetch statuses, most recent ones first. Timeline can be 'home', 'local', 'public', + Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public', or 'tag/hashtag'. See the following functions documentation for what those do. - Local hashtag timelines are supported via the timeline_hashtag() function. + Local hashtag timelines are supported via the `timeline_hashtag()`_ function. The default timeline is the "home" timeline. - Returns a list of toot dicts. + Returns a list of `toot dicts`_. """ if max_id != None: max_id = self.__unpack_id(max_id) @@ -349,9 +349,9 @@ class Mastodon: @api_version("1.0.0") def timeline_home(self, max_id=None, since_id=None, limit=None): """ - Fetch the authenticated users home timeline (i.e. followed users and self). + Fetch the logged-in users home timeline (i.e. followed users and self). - Returns a list of toot dicts. + Returns a list of `toot dicts`_. """ return self.timeline('home', max_id=max_id, since_id=since_id, limit=limit) @@ -361,7 +361,7 @@ class Mastodon: """ Fetches the local / instance-wide timeline, not including replies. - Returns a list of toot dicts. + Returns a list of `toot dicts`_. """ return self.timeline('local', max_id=max_id, since_id=since_id, limit=limit) @@ -371,7 +371,7 @@ class Mastodon: """ Fetches the public / visible-network timeline, not including replies. - Returns a list of toot dicts. + Returns a list of `toot dicts`_. """ return self.timeline('public', max_id=max_id, since_id=since_id, limit=limit) @@ -382,9 +382,9 @@ class Mastodon: Fetch a timeline of toots with a given hashtag. The hashtag parameter should not contain the leading #. - Set "local" to True to retrieve only instance-local tagged posts. + Set `local` to True to retrieve only instance-local tagged posts. - Returns a list of toot dicts. + Returns a list of `toot dicts`_. """ if hashtag.startswith("#"): raise MastodonIllegalArgumentError("Hashtag parameter should omit leading #") @@ -413,7 +413,7 @@ class Mastodon: """ Fetch information about a single toot. - Returns a toot dict. + Returns a `toot dict`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}'.format(str(id)) @@ -425,7 +425,7 @@ class Mastodon: Fetch a card associated with a status. A card describes an object (such as an external video or link) embedded into a status. - Returns a card dict. + Returns a `card dict`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/card'.format(str(id)) @@ -436,7 +436,7 @@ class Mastodon: """ Fetch information about ancestors and descendants of a toot. - Returns a context dict. + Returns a `context dict`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/context'.format(str(id)) @@ -447,7 +447,7 @@ class Mastodon: """ Fetch a list of users that have reblogged a status. - Returns a list of user dicts. + Returns a list of `user dicts`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/reblogged_by'.format(str(id)) @@ -458,7 +458,7 @@ class Mastodon: """ Fetch a list of users that have favourited a status. - Returns a list of user dicts. + Returns a list of `user dicts`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/favourited_by'.format(str(id)) @@ -470,12 +470,12 @@ class Mastodon: @api_version("1.0.0") def notifications(self, id=None, max_id=None, since_id=None, limit=None): """ - Fetch notifications (mentions, favourites, reblogs, follows) for the authenticated + Fetch notifications (mentions, favourites, reblogs, follows) for the logged-in user. - Can be passed an id to fetch a single notification. + Can be passed an `id` to fetch a single notification. - Returns a list of notification dicts. + Returns a list of `notification dicts`_. """ if max_id != None: max_id = self.__unpack_id(max_id) @@ -497,9 +497,9 @@ class Mastodon: @api_version("1.0.0") def account(self, id): """ - Fetch account information by user id. + Fetch account information by user `id`. - Returns a user dict. + Returns a `user dict`_. """ id = self.__unpack_id(id) url = '/api/v1/accounts/{0}'.format(str(id)) @@ -508,18 +508,21 @@ class Mastodon: @api_version("1.0.0") def account_verify_credentials(self): """ - Fetch authenticated user's account information. + Fetch logged-in user's account information. - Returns a user dict (Starting from 2.1.0, with an additional "source" field). + Returns a `user dict`_ (Starting from 2.1.0, with an additional "source" field). """ return self.__api_request('GET', '/api/v1/accounts/verify_credentials') @api_version("1.0.0") def account_statuses(self, id, max_id=None, since_id=None, limit=None): """ - Fetch statuses by user id. Same options as timeline are permitted. + Fetch statuses by user `id`. Same options as `timeline()`_ are permitted. + Returned toots are from the perspective of the logged-in user, i.e. + all statuses visible to the logged-in user (including DMs) are + included. - Returns a list of toot dicts. + Returns a list of `toot dicts`_. """ id = self.__unpack_id(id) if max_id != None: @@ -537,7 +540,7 @@ class Mastodon: """ Fetch users the given user is following. - Returns a list of user dicts. + Returns a list of `user dicts`_. """ id = self.__unpack_id(id) if max_id != None: @@ -555,7 +558,7 @@ class Mastodon: """ Fetch users the given user is followed by. - Returns a list of user dicts. + Returns a list of `user dicts`_. """ id = self.__unpack_id(id) if max_id != None: @@ -572,9 +575,9 @@ class Mastodon: def account_relationships(self, id): """ Fetch relationship (following, followed_by, blocking, follow requested) of - the logged in user to a given account. id can be a list. + the logged in user to a given account. `id` can be a list. - Returns a list of relationship dicts. + Returns a list of `relationship dicts`_. """ id = self.__unpack_id(id) params = self.__generate_params(locals()) @@ -587,7 +590,7 @@ class Mastodon: Fetch matching accounts. Will lookup an account remotely if the search term is in the username@domain format and not yet in the database. - Returns a list of user dicts. + Returns a list of `user dicts`_. """ params = self.__generate_params(locals()) return self.__api_request('GET', '/api/v1/accounts/search', params) @@ -601,7 +604,7 @@ class Mastodon: Fetch matching hashtags, accounts and statuses. Will search federated instances if resolve is True. - Returns a search result dict. + Returns a `search result dict`_. """ params = self.__generate_params(locals()) return self.__api_request('GET', '/api/v1/search', params) @@ -614,7 +617,7 @@ class Mastodon: """ Fetch a list of all the Lists by the logged-in user. - Returns a list of list dicts. + Returns a list of `list dicts`_. """ return self.__api_request('GET', '/api/v1/lists') @@ -624,9 +627,9 @@ class Mastodon: @api_version("1.1.0") def mutes(self, max_id=None, since_id=None, limit=None): """ - Fetch a list of users muted by the authenticated user. + Fetch a list of users muted by the logged-in user. - Returns a list of user dicts. + Returns a list of `user dicts`_. """ if max_id != None: max_id = self.__unpack_id(max_id) @@ -640,9 +643,9 @@ class Mastodon: @api_version("1.0.0") def blocks(self, max_id=None, since_id=None, limit=None): """ - Fetch a list of users blocked by the authenticated user. + Fetch a list of users blocked by the logged-in user. - Returns a list of user dicts. + Returns a list of `user dicts`_. """ if max_id != None: max_id = self.__unpack_id(max_id) @@ -659,12 +662,12 @@ class Mastodon: @api_version("1.1.0") def reports(self): """ - Fetch a list of reports made by the authenticated user. + Fetch a list of reports made by the logged-in user. - Returns a list of report dicts. + Returns a list of `report dicts`_. Warning: According to the official API documentation, this - method is to be treated as not finalized as of Mastodon 2.0.0. + method is to be treated as not finalized as of Mastodon 2.1.0. """ return self.__api_request('GET', '/api/v1/reports') @@ -674,9 +677,9 @@ class Mastodon: @api_version("1.0.0") def favourites(self, max_id=None, since_id=None, limit=None): """ - Fetch the authenticated user's favourited statuses. + Fetch the logged-in user's favourited statuses. - Returns a list of toot dicts. + Returns a list of `toot dicts`_. """ if max_id != None: max_id = self.__unpack_id(max_id) @@ -693,9 +696,9 @@ class Mastodon: @api_version("1.0.0") def follow_requests(self, max_id=None, since_id=None, limit=None): """ - Fetch the authenticated user's incoming follow requests. + Fetch the logged-in user's incoming follow requests. - Returns a list of user dicts. + Returns a list of `user dicts`_. """ if max_id != None: max_id = self.__unpack_id(max_id) @@ -712,7 +715,7 @@ class Mastodon: @api_version("1.4.0") def domain_blocks(self, max_id=None, since_id=None, limit=None): """ - Fetch the authenticated user's blocked domains. + Fetch the logged-in user's blocked domains. Returns a list of blocked domain URLs (as strings, without protocol specifier). """ @@ -733,7 +736,7 @@ class Mastodon: """ Fetch the list of custom emoji the instance has installed. - Returns a list of emoji dicts. + Returns a list of `emoji dicts`_. """ return self.__api_request('GET', '/api/v1/custom_emojis') @@ -746,11 +749,11 @@ class Mastodon: sensitive=False, visibility='', spoiler_text=None): """ Post a status. Can optionally be in reply to another status and contain - up to four pieces of media (Uploaded via media_post()). media_ids can - also be the media dicts returned by media_post - they are unpacked + up to four pieces of media (Uploaded via `media_post()`_). media_ids can + also be the `media dicts`_ returned by `media_post()`_ - they are unpacked automatically. - The 'sensitive' boolean decides whether or not media attached to the post + The `sensitive` boolean decides whether or not media attached to the post should be marked as sensitive, which hides it by default on the Mastodon web front-end. @@ -766,11 +769,11 @@ class Mastodon: locked setting - private if the account is locked, public otherwise (for Mastodon versions lower than 1.6). - The spoiler_text parameter is a string to be shown as a warning before + The `spoiler_text` parameter is a string to be shown as a warning before the text of the status. If no text is passed in, no warning will be displayed. - Returns a toot dict with the new status. + Returns a `toot dict`_ with the new status. """ if in_reply_to_id != None: in_reply_to_id = self.__unpack_id(in_reply_to_id) @@ -806,11 +809,11 @@ class Mastodon: @api_version("1.0.0") def toot(self, status): """ - Synonym for status_post that only takes the status text as input. + Synonym for `status_post()`_ that only takes the status text as input. Usage in production code is not recommended. - Returns a toot dict with the new status. + Returns a `toot dict`_ with the new status. """ return self.status_post(status) @@ -818,19 +821,17 @@ class Mastodon: def status_delete(self, id): """ Delete a status - - Returns an empty dict for good measure. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}'.format(str(id)) - return self.__api_request('DELETE', url) + self.__api_request('DELETE', url) @api_version("1.0.0") def status_reblog(self, id): """ Reblog a status. - Returns a toot dict with a new status that wraps around the reblogged one. + Returns a `toot dict`_ with a new status that wraps around the reblogged one. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/reblog'.format(str(id)) @@ -841,7 +842,7 @@ class Mastodon: """ Un-reblog a status. - Returns a toot dict with the status that used to be reblogged. + Returns a `toot dict`_ with the status that used to be reblogged. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/unreblog'.format(str(id)) @@ -852,7 +853,7 @@ class Mastodon: """ Favourite a status. - Returns a toot dict with the favourited status. + Returns a `toot dict`_ with the favourited status. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/favourite'.format(str(id)) @@ -863,7 +864,7 @@ class Mastodon: """ Un-favourite a status. - Returns a toot dict with the un-favourited status. + Returns a `toot dict`_ with the un-favourited status. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/unfavourite'.format(str(id)) @@ -874,7 +875,7 @@ class Mastodon: """ Mute notifications for a status. - Returns a toot dict with the now muted status + Returns a `toot dict`_ with the now muted status """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/mute'.format(str(id)) @@ -885,7 +886,7 @@ class Mastodon: """ Unmute notifications for a status. - Returns a toot dict with the status that used to be muted. + Returns a `toot dict`_ with the status that used to be muted. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/unmute'.format(str(id)) @@ -899,7 +900,7 @@ class Mastodon: """ Clear out a users notifications """ - return self.__api_request('POST', '/api/v1/notifications/clear') + self.__api_request('POST', '/api/v1/notifications/clear') @api_version("1.3.0") @@ -909,7 +910,7 @@ class Mastodon: """ id = self.__unpack_id(id) params = self.__generate_params(locals()) - return self.__api_request('POST', '/api/v1/notifications/dismiss', params) + self.__api_request('POST', '/api/v1/notifications/dismiss', params) ### # Writing data: Accounts @@ -919,7 +920,7 @@ class Mastodon: """ Follow a user. - Returns a relationship dict containing the updated relationship to the user. + Returns a `relationship dict`_ containing the updated relationship to the user. """ id = self.__unpack_id(id) url = '/api/v1/accounts/{0}/follow'.format(str(id)) @@ -930,7 +931,7 @@ class Mastodon: """ Follow a remote user by uri (username@domain). - Returns a user dict. + Returns a `user dict`_. """ params = self.__generate_params(locals()) return self.__api_request('POST', '/api/v1/follows', params) @@ -940,7 +941,7 @@ class Mastodon: """ Unfollow a user. - Returns a relationship dict containing the updated relationship to the user. + Returns a `relationship dict`_ containing the updated relationship to the user. """ id = self.__unpack_id(id) url = '/api/v1/accounts/{0}/unfollow'.format(str(id)) @@ -951,7 +952,7 @@ class Mastodon: """ Block a user. - Returns a relationship dict containing the updated relationship to the user. + Returns a `relationship dict`_ containing the updated relationship to the user. """ id = self.__unpack_id(id) url = '/api/v1/accounts/{0}/block'.format(str(id)) @@ -962,7 +963,7 @@ class Mastodon: """ Unblock a user. - Returns a relationship dict containing the updated relationship to the user. + Returns a `relationship dict`_ containing the updated relationship to the user. """ id = self.__unpack_id(id) url = '/api/v1/accounts/{0}/unblock'.format(str(id)) @@ -973,7 +974,7 @@ class Mastodon: """ Mute a user. - Returns a relationship dict containing the updated relationship to the user. + Returns a `relationship dict`_ containing the updated relationship to the user. """ id = self.__unpack_id(id) url = '/api/v1/accounts/{0}/mute'.format(str(id)) @@ -984,7 +985,7 @@ class Mastodon: """ Unmute a user. - Returns a relationship dict containing the updated relationship to the user. + Returns a `relationship dict`_ containing the updated relationship to the user. """ id = self.__unpack_id(id) url = '/api/v1/accounts/{0}/unmute'.format(str(id)) @@ -994,12 +995,14 @@ class Mastodon: def account_update_credentials(self, display_name=None, note=None, avatar=None, header=None): """ - Update the profile for the currently authenticated user. + Update the profile for the currently logged-in user. 'note' is the user's bio. 'avatar' and 'header' are images encoded in base64, prepended by a content-type (for example: 'data:image/png;base64,iVBORw0KGgoAAAA[...]') + + Returns the updated `user dict` of the logged-in user. """ params = self.__generate_params(locals()) return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params) @@ -1014,7 +1017,7 @@ class Mastodon: Accepts a list of toot IDs associated with the report, and a comment. - Returns a report dict. + Returns a `report dict`_. """ account_id = self.__unpack_id(account_id) status_ids = map(lambda x: self.__unpack_id(x), status_ids) @@ -1028,23 +1031,19 @@ class Mastodon: def follow_request_authorize(self, id): """ Accept an incoming follow request. - - Returns an empty dict. """ id = self.__unpack_id(id) url = '/api/v1/follow_requests/{0}/authorize'.format(str(id)) - return self.__api_request('POST', url) + self.__api_request('POST', url) @api_version("1.0.0") def follow_request_reject(self, id): """ Reject an incoming follow request. - - Returns an empty dict. """ id = self.__unpack_id(id) url = '/api/v1/follow_requests/{0}/reject'.format(str(id)) - return self.__api_request('POST', url) + self.__api_request('POST', url) ### # Writing data: Media @@ -1052,15 +1051,15 @@ class Mastodon: @api_version("1.0.0") def media_post(self, media_file, mime_type=None, description=None): """ - Post an image. media_file can either be image data or + Post an image. `media_file` can either be image data or a file name. If image data is passed directly, the mime type has to be specified manually, otherwise, it is determined from the file name. - Throws a MastodonIllegalArgumentError if the mime type of the + Throws a `MastodonIllegalArgumentError` if the mime type of the passed data or file can not be determined properly. - Returns a media dict. This contains the id that can be used in + Returns a `media dict`_. This contains the id that can be used in status_post to attach the media file to a toot. """ if mime_type is None and os.path.isfile(media_file): @@ -1090,7 +1089,7 @@ class Mastodon: Add a block for all statuses originating from the specified domain for the logged-in user. """ params = self.__generate_params(locals()) - return self.__api_request('POST', '/api/v1/domain_blocks', params) + self.__api_request('POST', '/api/v1/domain_blocks', params) @api_version("1.4.0") def domain_unblock(self, domain=None): @@ -1098,7 +1097,7 @@ class Mastodon: Remove a domain block for the logged-in user. """ params = self.__generate_params(locals()) - return self.__api_request('DELETE', '/api/v1/domain_blocks', params) + self.__api_request('DELETE', '/api/v1/domain_blocks', params) ### # Pagination