Skip to content

Commit e6e9bba

Browse files
committed
Add a little documentation
1 parent 368da51 commit e6e9bba

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

scuttle/versions/v1.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,21 @@
1010

1111
class NoNonPaginatedVersionError(Exception):
1212
"""Raised when a non-paginated of a paginated-only method is called."""
13-
pass
14-
15-
@wrapt.decorator
16-
def has_paginated_version(method, instance, args, kwargs):
17-
def paginated(*args, limit=None, offset=None, direction=None):
18-
print("PAGINATED METHOD", method)
19-
print("PAGINATED ARGS", args)
20-
data = {
21-
'limit': 20 if limit is None else limit,
22-
'offset': 0 if offset is None else offset,
23-
'direction': 'asc' if direction is None else direction,
24-
}
25-
return method(*args, data=data)
26-
setattr(instance.verbose, method.__name__, paginated)
27-
return method
2813

2914
def endpoint(endpoint_url):
15+
"""Decorator for API methods. Denotes the URL endpoint."""
3016
@wrapt.decorator
3117
def wrapper(method, instance, args, kwargs):
3218
return instance.request(endpoint_url, *method(*args, **kwargs))
3319
return wrapper
3420

3521
class PaginatedMethod:
22+
"""Object representing a method that has a POST paginated version (with
23+
args like limit, offset, direction) as well as optionally a GET
24+
non-paginated version. The GET version is accessed by calling the object as
25+
if it were a method. The POST version is accessed by calling the `verbose`
26+
attribute.
27+
"""
3628
def __init__(self, method: Callable, verbose_only: bool = False):
3729
self._method = method
3830
self._verbose_only = verbose_only
@@ -219,12 +211,9 @@ def tag_pages(self, tag: str):
219211
@endpoint("tag/pages")
220212
def _tags_pages(self, tags: Union[List[int], List[str]], operator: str = 'and', *, data):
221213
"""
222-
str[] `tags`: A list of tag names, finds all page IDs that match the
223-
condition.
224-
int[] `tags`: A list of SCUTTLE tag IDs, finds all page IDs that match
225-
the condition.
226-
str `operator`: 'and' or 'or'; defines the condition when specifying
227-
multiple tags.
214+
str[] `tags`: A list of tag names.
215+
int[] `tags`: A list of SCUTTLE tag IDs.
216+
str `operator`: 'and' or 'or'; defines how tags are combined.
228217
"""
229218
if isinstance(tags, str):
230219
raise TypeError("`tags` must be a list of at least one tag; use tag_pages() for a single tag name")

0 commit comments

Comments
 (0)