Skip to content

Commit 4b4be34

Browse files
committed
Update documentation
1 parent 8bc2dd1 commit 4b4be34

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

cli_ui/__init__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,17 +501,21 @@ def ask_choice(
501501
) -> Any:
502502
"""Ask the user to choose from a list of choices.
503503
504-
:return: the selected choice
505-
506-
``func_desc`` will be called on every list item for displaying
507-
and sorting the list. If not given, will default to
508-
the identity function.
509-
510504
Will loop until:
511505
* the user enters a valid index
512506
* or leaves the prompt empty
513507
514-
In the last case, None will be returned
508+
In the last case, `None` will be returned
509+
510+
:param prompt: a list of tokens suitable for :func:`info`
511+
:param choices: a list of arbitrary elements
512+
:func_desc: a callable. It will be used to display and
513+
sort the list of choices (unless ``sort`` is False)
514+
Defaults to the identity function.
515+
:sort: whether to sort the list of choices.
516+
517+
:return: the selected choice.
518+
515519
"""
516520
if func_desc is None:
517521
func_desc = lambda x: str(x)

docs/index.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@ Asking for user input
293293
>>> fruit
294294
'banana'
295295

296+
297+
.. versionchanged:: 0.10
298+
299+
Add ``sort`` paramater to disable sorting the list of choices
300+
296301
.. versionchanged:: 0.8
297302

298303
``choices`` is now a named keyword argument
@@ -320,7 +325,6 @@ Asking for user input
320325
>>> fav_food = cli_ui.ask_password("Guilty pleasure?")
321326
:: Guilty pleasure?
322327
****
323-
324328
>>> fav_food
325329
'chocolate'
326330

0 commit comments

Comments
 (0)