Move order docstring back into find_cards()

This commit is contained in:
RumovZ 2021-03-29 12:03:31 +02:00
parent b1a06fb807
commit 7b316a7151

View file

@ -497,8 +497,22 @@ class Collection:
reverse: bool = False,
) -> Sequence[CardId]:
"""Return card ids matching the provided search.
To programmatically construct a search string, see .build_search_string().
To define a sort order, see _build_sort_mode().
If order=True, use the sort order stored in the collection config
If order=False, do no ordering
If order is a string, that text is added after 'order by' in the sql statement.
You must add ' asc' or ' desc' to the order, as Anki will replace asc with
desc and vice versa when reverse is set in the collection config, eg
order="c.ivl asc, c.due desc".
If order is a BuiltinSort.Kind value, sort using that builtin sort, eg
col.find_cards("", order=BuiltinSort.Kind.CARD_DUE)
The reverse argument only applies when a BuiltinSort.Kind is provided;
otherwise the collection config defines whether reverse is set or not.
"""
mode = _build_sort_mode(order, reverse)
return cast(
@ -512,8 +526,9 @@ class Collection:
reverse: bool = False,
) -> Sequence[NoteId]:
"""Return note ids matching the provided search.
To programmatically construct a search string, see .build_search_string().
To define a sort order, see _build_sort_mode().
The order parameter is documented in .find_cards().
"""
mode = _build_sort_mode(order, reverse)
return cast(
@ -1072,22 +1087,6 @@ def _build_sort_mode(
order: Union[bool, str, BuiltinSort.Kind.V],
reverse: bool,
) -> _pb.SortOrder:
"""Return a SortOrder object for use in find_cards() or find_notes().
If order=True, use the sort order stored in the collection config
If order=False, do no ordering
If order is a string, that text is added after 'order by' in the sql statement.
You must add ' asc' or ' desc' to the order, as Anki will replace asc with
desc and vice versa when reverse is set in the collection config, eg
order="c.ivl asc, c.due desc".
If order is a BuiltinSort.Kind value, sort using that builtin sort, eg
col.find_cards("", order=BuiltinSort.Kind.CARD_DUE)
The reverse argument only applies when a BuiltinSort.Kind is provided;
otherwise the collection config defines whether reverse is set or not.
"""
if isinstance(order, str):
return _pb.SortOrder(custom=order)
elif isinstance(order, bool):