Skip to content

Commit eb23a17

Browse files
committed
Doc update
1 parent fb5c856 commit eb23a17

File tree

3 files changed

+46
-40
lines changed

3 files changed

+46
-40
lines changed

README.rst

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Introduction
2121
:target: https://github.com/psf/black
2222
:alt: Code Style: Black
2323

24-
Slimmed down implementation of prompt_toolkit for CircuitPython
24+
Slimmed down implementation of `prompt_toolkit <https://github.com/prompt-toolkit/python-prompt-toolkit>`_ for CircuitPython
2525

2626

2727
Dependencies
@@ -36,39 +36,13 @@ This is easily achieved by downloading
3636
or individual libraries can be installed using
3737
`circup <https://github.com/adafruit/circup>`_.
3838

39-
.. todo:: Describe the Adafruit product this library works with. For PCBs, you can also add the
40-
image from the assets folder in the PCB's GitHub repo.
41-
42-
`Purchase one from the Adafruit shop <http://www.adafruit.com/products/>`_
4339
Installing from PyPI
4440
=====================
45-
.. note:: This library is not available on PyPI yet. Install documentation is included
46-
as a standard element. Stay tuned for PyPI availability!
47-
48-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
49-
50-
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
51-
PyPI <https://pypi.org/project/adafruit-circuitpython-prompt-toolkit/>`_.
52-
To install for current user:
53-
54-
.. code-block:: shell
55-
56-
pip3 install adafruit-circuitpython-prompt-toolkit
57-
58-
To install system-wide (this may be required in some cases):
59-
60-
.. code-block:: shell
61-
62-
sudo pip3 install adafruit-circuitpython-prompt-toolkit
6341

64-
To install in a virtual environment in your current project:
65-
66-
.. code-block:: shell
67-
68-
mkdir project-name && cd project-name
69-
python3 -m venv .venv
70-
source .env/bin/activate
71-
pip3 install adafruit-circuitpython-prompt-toolkit
42+
This library is available in PyPI for CircuitPython tools that need it. If you
43+
actually want to use it on CPython (not CircuitPython), then we recommend the
44+
full `prompt_toolkit <https://github.com/prompt-toolkit/python-prompt-toolkit>`_
45+
library that is also on PyPI.
7246

7347
Installing to a Connected CircuitPython Device with Circup
7448
==========================================================
@@ -96,8 +70,25 @@ Or the following command to update an existing version:
9670
Usage Example
9771
=============
9872

99-
.. todo:: Add a quick, simple example. It and other examples should live in the
100-
examples folder and be included in docs/examples.rst.
73+
.. code-block:: python
74+
75+
# This example works over the second CDC and supports history.
76+
77+
import usb_cdc
78+
79+
# Rename import to make the rest of the code compatible with CPython's prompt_toolkit library.
80+
import adafruit_prompt_toolkit as prompt_toolkit
81+
82+
# If the second CDC is available, then use it instead.
83+
serial = usb_cdc.console
84+
if usb_cdc.data:
85+
serial = usb_cdc.data
86+
87+
session = prompt_toolkit.PromptSession(input=serial, output=serial)
88+
89+
while True:
90+
response = prompt_toolkit.prompt("$ ")
91+
print("->", response, file=serial)
10192
10293
Documentation
10394
=============

docs/examples.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
Simple test
22
------------
33

4-
Ensure your device works with this simple test.
4+
Ensure the library works with this simple test.
55

66
.. literalinclude:: ../examples/prompt_toolkit_simpletest.py
77
:caption: examples/prompt_toolkit_simpletest.py
88
:linenos:
9+
10+
Second USB
11+
----------
12+
13+
Use the library over a second USB CDC serial connection. `boot.py` must include
14+
`usb_cdc.enable(console=True, data=True)`. `console` can be `False`.
15+
16+
Example "boot.py":
17+
18+
.. code-block:: python
19+
20+
import usb_cdc
21+
22+
# Enable console and data
23+
usb_cdc.enable(console=True, data=True)
24+
25+
Example "code.py":
26+
27+
.. literalinclude:: ../examples/prompt_toolkit_second_cdc.py
28+
:caption: examples/prompt_toolkit_second_cdc.py
29+
:linenos:

docs/index.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@ Table of Contents
2424
.. toctree::
2525
:caption: Tutorials
2626

27-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
28-
the toctree above for use later.
29-
3027
.. toctree::
3128
:caption: Related Products
3229

33-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
34-
the toctree above for use later.
35-
3630
.. toctree::
3731
:caption: Other Links
3832

0 commit comments

Comments
 (0)