Update and improve documentation for API.add_list_members
authorHarmon <Harmon758@gmail.com>
Wed, 7 Apr 2021 15:43:04 +0000 (10:43 -0500)
committerHarmon <Harmon758@gmail.com>
Wed, 7 Apr 2021 15:43:04 +0000 (10:43 -0500)
Automatically use docstring for documentation
Improve method and documentation order
Improve parameter order in documentation

docs/api.rst
tweepy/api.py

index 96317e512235d9b1b4cbd3e38009d905d6c506bb..8293e2ac9e7dcf5adda29126b6782e1bb09eb4dd 100644 (file)
@@ -96,6 +96,8 @@ Create and manage lists
 
 .. automethod:: API.add_list_member
 
+.. automethod:: API.add_list_members
+
 
 User methods
 ------------
@@ -617,23 +619,6 @@ List Methods
    :rtype: :class:`List` object
 
 
-.. method:: API.add_list_members(list_id/slug, screen_name/user_id, \
-                                 [owner_id/owner_screen_name])
-
-   Add up to 100 members to a list. The authenticated user must own the list to
-   be able to add members to it. Lists are limited to 5,000 members.
-
-   :param list_id: |list_id|
-   :param slug: |slug|
-   :param screen_name: A comma separated list of screen names, up to 100 are
-                       allowed in a single request
-   :param user_id: A comma separated list of user IDs, up to 100 are allowed in
-                   a single request
-   :param owner_id: |owner_id|
-   :param owner_screen_name: |owner_screen_name|
-   :rtype: :class:`List` object
-
-
 .. method:: API.remove_list_member(list_id/slug, screen_name/user_id, \
                                    [owner_id/owner_screen_name])
 
index 58972060ef4d39fe14069dff8f163bf5b354e163..de18b2d8b42048007831a9104c4634bebaba600d 100644 (file)
@@ -1220,6 +1220,39 @@ class API:
             ), **kwargs
         )
 
+    @payload('list')
+    def add_list_members(self, **kwargs):
+        """add_list_members(*, list_id, slug, user_id, screen_name, \
+                            owner_screen_name, owner_id)
+
+        Add up to 100 members to a list. The authenticated user must own the
+        list to be able to add members to it. Lists are limited to 5,000
+        members.
+
+        :param list_id: |list_id|
+        :param slug: |slug|
+        :param user_id: A comma separated list of user IDs, up to 100 are
+                        allowed in a single request
+        :param screen_name: A comma separated list of screen names, up to 100
+                            are allowed in a single request
+        :param owner_screen_name: |owner_screen_name|
+        :param owner_id: |owner_id|
+
+        :rtype: :class:`List` object
+
+        :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-create_all
+        """
+        if 'user_id' in kwargs:
+            kwargs['user_id'] = list_to_csv(kwargs['user_id'])
+        if 'screen_name' in kwargs:
+            kwargs['screen_name'] = list_to_csv(kwargs['screen_name'])
+        return self.request(
+            'POST', 'lists/members/create_all', endpoint_parameters=(
+                'list_id', 'slug', 'user_id', 'screen_name',
+                'owner_screen_name', 'owner_id'
+            ), **kwargs
+        )
+
     def media_upload(self, filename, *, file=None, chunked=False,
                      media_category=None, additional_owners=None, **kwargs):
         """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/overview
@@ -1818,21 +1851,6 @@ class API:
             ), **kwargs
         )
 
-    @payload('list')
-    def add_list_members(self, **kwargs):
-        """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-create_all
-        """
-        if 'user_id' in kwargs:
-            kwargs['user_id'] = list_to_csv(kwargs['user_id'])
-        if 'screen_name' in kwargs:
-            kwargs['screen_name'] = list_to_csv(kwargs['screen_name'])
-        return self.request(
-            'POST', 'lists/members/create_all', endpoint_parameters=(
-                'list_id', 'slug', 'user_id', 'screen_name',
-                'owner_screen_name', 'owner_id'
-            ), **kwargs
-        )
-
     @payload('list')
     def remove_list_members(self, **kwargs):
         """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy_all