Skip to content

Commit 3bc0ce0

Browse files
committed
Clean up minor formatting issues with the tutorial
1 parent 98093c1 commit 3bc0ce0

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

docs/tutorial/part-01.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Use the code :python:`for event in tcod.event.wait():` to begin handing events.
9494

9595
In the event loop start with the line :python:`print(event)` so that all events can be viewed from the program output.
9696
Then test if an event is for closing the window with :python:`if isinstance(event, tcod.event.Quit):`.
97-
If this is True then you should exit the function with :python:`raise SystemExit()`. [#why_raise]_
97+
If this is True then you should exit the function with :python:`raise SystemExit`. [#why_raise]_
9898

9999
.. code-block:: python
100100
:emphasize-lines: 3,5,15-23
@@ -121,7 +121,7 @@ If this is True then you should exit the function with :python:`raise SystemExit
121121
for event in tcod.event.wait(): # Event loop, blocks until pending events exist
122122
print(event)
123123
if isinstance(event, tcod.event.Quit):
124-
raise SystemExit()
124+
raise SystemExit
125125
126126
127127
if __name__ == "__main__":
@@ -205,7 +205,7 @@ Modify the drawing routine so that the console is cleared, then passed to :pytho
205205
for event in tcod.event.wait():
206206
print(event)
207207
if isinstance(event, tcod.event.Quit):
208-
raise SystemExit()
208+
raise SystemExit
209209
210210
211211
if __name__ == "__main__":
@@ -259,7 +259,7 @@ The full script so far is:
259259
"""Move the player on events and handle exiting. Movement is hard-coded."""
260260
match event:
261261
case tcod.event.Quit():
262-
raise SystemExit()
262+
raise SystemExit
263263
case tcod.event.KeyDown(sym=tcod.event.KeySym.LEFT):
264264
self.player_x -= 1
265265
case tcod.event.KeyDown(sym=tcod.event.KeySym.RIGHT):
@@ -308,5 +308,5 @@ You can review the part-1 source code `here <https://github.com/HexDecimal/pytho
308308
.. [#init_context] This tutorial follows the setup for a fixed-size console.
309309
The alternatives shown in :ref:`getting-started` are outside the scope of this tutorial.
310310
311-
.. [#why_raise] You could use :python:`return` here to exit the ``main`` function and end the program, but :python:`raise SystemExit()` is used because it will close the program from anywhere.
312-
:python:`raise SystemExit()` is also more useful to teach than :any:`sys.exit`.
311+
.. [#why_raise] You could use :python:`return` here to exit the ``main`` function and end the program, but :python:`raise SystemExit` is used because it will close the program from anywhere.
312+
:python:`raise SystemExit` is also more useful to teach than :any:`sys.exit`.

docs/tutorial/part-02.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ Use :python:`from tcod.event import KeySym` to make ``KeySym`` enums easier to w
327327
328328
"""Global constants are stored here."""
329329
330+
from __future__ import annotations
331+
330332
from typing import Final
331333
332334
from tcod.event import KeySym
@@ -386,7 +388,7 @@ The query to fetch player entities is :python:`g.world.Q.all_of(tags=[IsPlayer])
386388
We expect only one player so the result will be unpacked into a single name: :python:`(player,) = g.world.Q.all_of(tags=[IsPlayer])`.
387389

388390
Next is to handle the event.
389-
Handling :python:`case tcod.event.Quit():` is the same as before: :python:`raise SystemExit()`.
391+
Handling :python:`case tcod.event.Quit():` is the same as before: :python:`raise SystemExit`.
390392

391393
The case for direction keys will now be done in a single case: :python:`case tcod.event.KeyDown(sym=sym) if sym in DIRECTION_KEYS:`.
392394
``sym=sym`` assigns from the event attribute to a local name.
@@ -419,7 +421,7 @@ Then use :python:`gold.clear()` at the end to remove all components and tags fro
419421
(player,) = g.world.Q.all_of(tags=[IsPlayer])
420422
match event:
421423
case tcod.event.Quit():
422-
raise SystemExit()
424+
raise SystemExit
423425
case tcod.event.KeyDown(sym=sym) if sym in DIRECTION_KEYS:
424426
player.components[Position] += DIRECTION_KEYS[sym]
425427
# Auto pickup gold
@@ -499,7 +501,7 @@ It should be at the same level as the ``for`` loop and not inside of it.
499501
(player,) = g.world.Q.all_of(tags=[IsPlayer])
500502
match event:
501503
case tcod.event.Quit():
502-
raise SystemExit()
504+
raise SystemExit
503505
case tcod.event.KeyDown(sym=sym) if sym in DIRECTION_KEYS:
504506
player.components[Position] += DIRECTION_KEYS[sym]
505507
# Auto pickup gold

docs/tutorial/part-03.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Menus
301301
"""Handle events for menus."""
302302
match event:
303303
case tcod.event.Quit():
304-
raise SystemExit()
304+
raise SystemExit
305305
case tcod.event.KeyDown(sym=sym) if sym in DIRECTION_KEYS:
306306
dx, dy = DIRECTION_KEYS[sym]
307307
if dx != 0 or dy == 0:
@@ -379,7 +379,7 @@ Update states
379379
@staticmethod
380380
def quit() -> StateResult:
381381
"""Close the program."""
382-
raise SystemExit()
382+
raise SystemExit
383383
384384
.. code-block:: python
385385
:emphasize-lines: 2,5,19-23
@@ -393,7 +393,7 @@ Update states
393393
(player,) = g.world.Q.all_of(tags=[IsPlayer])
394394
match event:
395395
case tcod.event.Quit():
396-
raise SystemExit()
396+
raise SystemExit
397397
case tcod.event.KeyDown(sym=sym) if sym in DIRECTION_KEYS:
398398
player.components[Position] += DIRECTION_KEYS[sym]
399399
# Auto pickup gold

0 commit comments

Comments
 (0)