Skip to content

Commit 4d21d94

Browse files
committed
Fix documentation mistakes
This commit does two things: it fixes some bad documentation mistakes in the example sections of each cue and it swaps certain images for better ones.
1 parent d836458 commit 4d21d94

File tree

12 files changed

+131
-10
lines changed

12 files changed

+131
-10
lines changed

docs/source/_static/confirm.png

35.2 KB
Loading

docs/source/_static/form.png

35.4 KB
Loading

docs/source/_static/password.png

87.8 KB
Loading
62.3 KB
Loading

docs/source/_static/select.png

38.4 KB
Loading

docs/source/_static/survey.png

49.5 KB
Loading

docs/source/pages/cues.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ List of cues
2525
cues/checkbox
2626
cues/confirm
2727
cues/form
28+
cues/password
2829
cues/select
2930
cues/survey

docs/source/pages/cues/checkbox.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ In the previous example, we initialized separte variables for the ``__init__`` m
8686

8787

8888
checkbox_dict = {
89-
name = 'guitars'
90-
message = 'Pick your favorite guitars:'
91-
options = [
89+
'name': 'guitars'
90+
'message': 'Pick your favorite guitars:'
91+
'options': [
9292
'Les Paul',
9393
'Stratocaster',
9494
'Telecaster',

docs/source/pages/cues/form.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ When you "send" the cue to the user, they will be presented with something that
7676

7777
*The Form cue*
7878

79-
The user will not be expected to answer these prompts by typing their responses. Once the user has finished, a ``dict`` containing another ``dict`` will be returned. The inner-``dict`` will consist of key-value pairs of your ``fields`` and the user's responses respectively. The result will resemble the following:
79+
The user will then be able to answer these prompts by typing their responses. Once the user has finished, a ``dict`` containing another ``dict`` will be returned. The inner-``dict`` will consist of key-value pairs of your ``fields`` and the user's responses respectively. The result will resemble the following:
8080
::
8181

8282
{
@@ -126,9 +126,9 @@ In the previous example, we initialized separte variables for the ``__init__`` m
126126

127127

128128
form_dict = {
129-
name = 'basic_info'
130-
message = 'Please fill out the following form:'
131-
fields = [
129+
'name': 'basic_info'
130+
'message': 'Please fill out the following form:'
131+
'fields': [
132132
{
133133
'name': 'first_name',
134134
'message': 'First name'
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
Password
2+
========
3+
4+
This page will explain how to use the ``Password`` cue of the `Cues` library.
5+
6+
``Password`` objects are useful when you need input from the user but would prefer their input be hidden while they type as it may contain sensitive information. The expected input is a ``str`` object. The result is a ``dict`` containing a ``str``.
7+
8+
Before we start, make sure you have `Cues` `installed <../install.html>`_.
9+
10+
Setting up
11+
----------
12+
13+
``Password`` objects have three required parameters:
14+
15+
+------------+------------+------------+------------+
16+
| Parameters | Type | Optional | Default |
17+
+============+============+============+============+
18+
| name | str | No | |
19+
+------------+------------+------------+------------+
20+
| message | str | No | |
21+
+------------+------------+------------+------------+
22+
23+
The signature for the ``__init__`` method of a ``Password`` object:
24+
::
25+
26+
def __init__(self, name, message):
27+
# ...
28+
29+
With that out of the way, we first need to start by importing ``Password`` from the `Cues` library:
30+
::
31+
32+
from cues import Password
33+
34+
Now, we need to instantiate a ``Password`` object. We can do this with a little bit of setup by initializing some variables:
35+
::
36+
37+
name = 'password'
38+
message = 'Password:'
39+
40+
In the code above, we created the variables ``name`` and ``message``:
41+
42+
- ``name`` will be used to retrieve the results from a ``Password`` object
43+
- ``message`` is the text that will be displayed to the user
44+
45+
That's it! Our setup is complete. We can now go ahead and initialize a ``Password`` object to ask the user to enter a password by invoking the object's ``send`` method:
46+
::
47+
48+
cue = Password(name, message)
49+
answer = cue.send()
50+
51+
When you "send" the cue to the user, they will be presented with something that looks like the following:
52+
53+
.. figure:: ../../_static/password.png
54+
:width: 600px
55+
:align: center
56+
:alt: password snapshot
57+
:figclass: align-center
58+
59+
*The Password cue*
60+
61+
As the user types, asterisks will appear where their input normally would if you were to use Python's built-in ``input`` function. The user can use the Backspace/Delete key to undo any mistakes or reset their input. Once they're done, they can hit the Enter key and a ``dict`` will be returned with a ``str`` object:
62+
::
63+
64+
{'password': '1234'}
65+
66+
Two formats
67+
-----------
68+
69+
There are two possible formats that can be used for displaying the `message` to the user: one that ends with a bullet point and one that doesn't.
70+
71+
If your message ends with an alphanumerical character (A-Z | 0-9), then a bullet point will separate the message you provide and the user's input:
72+
73+
.. figure:: ../../_static/password_endswith_alnum.png
74+
:width: 600px
75+
:align: center
76+
:alt: password snapshot
77+
:figclass: align-center
78+
79+
*The Password cue*
80+
81+
Otherwise, if your message ends with a colon or a question mark, the only thing separating your message and the user's input will be one whitespace character:
82+
83+
.. figure:: ../../_static/password.png
84+
:width: 600px
85+
:align: center
86+
:alt: password snapshot
87+
:figclass: align-center
88+
89+
*The Password cue*
90+
91+
92+
Instantiating from a dict
93+
-------------------------
94+
95+
In the previous example, we initialized separte variables for the ``__init__`` method of a ``Password`` object. *However*, we could also make use of the class's ``from_dict`` classmethod and instantiate by using a ``dict`` instead:
96+
::
97+
98+
from cues import Password
99+
100+
101+
password_dict = {
102+
'name': 'password',
103+
'message': 'Password:'
104+
}
105+
106+
cue = Password.from_dict(password_dict)
107+
answer = cue.send()
108+
109+
The names for the *values* in this ``dict`` must be the same as the names of the parameters in the ``__init__`` method.

0 commit comments

Comments
 (0)