Skip to content

Commit 69a5e0f

Browse files
committed
Added clarity on SimpleEngine, module docstrings to code examples, and removed >>> from interpreter
1 parent 3fc30d6 commit 69a5e0f

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

docs/engine.rst

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The preferred way to use the API is with an
1919
The examples also show a synchronous wrapper
2020
:class:`~chess.engine.SimpleEngine` that automatically spawns an event loop
2121
in the background.
22+
:class:`~chess.engine.SimpleEngine` methods block until there is a result.
2223

2324
Playing
2425
-------
@@ -27,6 +28,8 @@ Example: Let Stockfish play against itself, 100 milliseconds per move.
2728

2829
.. code:: python
2930
31+
"""Using synchronous engine.SimpleEngine."""
32+
3033
import chess
3134
import chess.engine
3235
@@ -41,6 +44,8 @@ Example: Let Stockfish play against itself, 100 milliseconds per move.
4144
4245
.. code:: python
4346
47+
"""Using async engine."""
48+
4449
import asyncio
4550
import chess
4651
import chess.engine
@@ -74,6 +79,8 @@ Example:
7479

7580
.. code:: python
7681
82+
"""Using synchronous engine.SimpleEngine."""
83+
7784
import chess
7885
import chess.engine
7986
@@ -93,6 +100,8 @@ Example:
93100
94101
.. code:: python
95102
103+
"""Using async engine."""
104+
96105
import asyncio
97106
import chess
98107
import chess.engine
@@ -139,6 +148,8 @@ Example: Stream information from the engine and stop on an arbitrary condition.
139148

140149
.. code:: python
141150
151+
"""Using synchronous engine.SimpleEngine."""
152+
142153
import chess
143154
import chess.engine
144155
@@ -156,6 +167,8 @@ Example: Stream information from the engine and stop on an arbitrary condition.
156167
157168
.. code:: python
158169
170+
"""Using async engine."""
171+
159172
import asyncio
160173
import chess
161174
import chess.engine
@@ -193,21 +206,27 @@ Options
193206
:func:`~chess.Protocol.analyse()` and
194207
:func:`~chess.Protocol.analysis()` accept a dictionary of options.
195208

196-
>>> import chess.engine
197-
>>>
198-
>>> engine = chess.engine.SimpleEngine.popen_uci("/usr/bin/stockfish")
199-
>>>
200-
>>> # Check available options.
201-
>>> engine.options["Hash"]
202-
Option(name='Hash', type='spin', default=16, min=1, max=131072, var=[])
203-
>>>
204-
>>> # Set an option.
205-
>>> engine.configure({"Hash": 32})
206-
>>>
207-
>>> # [...]
209+
.. code:: python
210+
211+
"""Using synchronous engine.SimpleEngine."""
212+
213+
import chess.engine
214+
215+
engine = chess.engine.SimpleEngine.popen_uci("/usr/bin/stockfish")
216+
217+
# Check available options.
218+
engine.options["Hash"]
219+
# Option(name='Hash', type='spin', default=16, min=1, max=131072, var=[])
220+
221+
# Set an option.
222+
engine.configure({"Hash": 32})
223+
224+
# [...]
208225
209226
.. code:: python
210227
228+
"""Using async engine."""
229+
211230
import asyncio
212231
import chess.engine
213232

0 commit comments

Comments
 (0)