11
22def show_ports ():
3- """
4- List all available serial ports with descriptions.
3+ """List all available serial ports.
4+
5+ The function prints a numbered list of connected serial ports with a short
6+ description. It is mainly intended for quick troubleshooting when choosing
7+ a port for trigger boxes or external devices.
8+
9+ Returns
10+ -------
11+ None
12+ This function is executed for its side effect of printing to ``stdout``.
513 """
614 import serial .tools .list_ports
715 ports = list (serial .tools .list_ports .comports ())
@@ -17,14 +25,36 @@ def show_ports():
1725
1826from cookiecutter .main import cookiecutter
1927import importlib .resources as pkg_res
28+
29+
2030def taps (task_name : str , template : str = "cookiecutter-psyflow" ):
21- # locate the template folder inside the installed package
31+ """Generate a task skeleton using the bundled template.
32+
33+ Parameters
34+ ----------
35+ task_name : str
36+ Name of the new task directory to create.
37+ template : str, optional
38+ Name of the template folder inside the package. Defaults to
39+ ``"cookiecutter-psyflow"``.
40+
41+ Returns
42+ -------
43+ str
44+ Path to the newly created project directory.
45+
46+ Examples
47+ --------
48+ >>> taps("mytask")
49+ "mytask"
50+ """
2251 tmpl_dir = pkg_res .files ("psyflow" ) / template
2352 cookiecutter (
2453 str (tmpl_dir ),
2554 no_input = True ,
2655 extra_context = {"project_name" : task_name }
2756 )
57+ return task_name
2858
2959
3060from psychopy import visual , core
@@ -40,6 +70,11 @@ def count_down(win, seconds=3, **stim_kwargs):
4070 How many seconds to count down from.
4171 **stim_kwargs : dict
4272 Additional keyword arguments for TextStim (e.g., font, height, color).
73+
74+ Returns
75+ -------
76+ None
77+ The countdown is shown on ``win`` for its side effect.
4378 """
4479 cd_clock = core .Clock ()
4580 for i in reversed (range (1 , seconds + 1 )):
@@ -68,6 +103,11 @@ def load_config(config_file: str = 'config/config.yaml',
68103 -------
69104 dict
70105 Dictionary with structured configs.
106+
107+ Examples
108+ --------
109+ >>> cfg = load_config('config/config.yaml')
110+ >>> cfg['task_config']['screen_width']
71111 """
72112 with open (config_file , encoding = 'utf-8' ) as f :
73113 config = yaml .safe_load (f )
@@ -103,15 +143,24 @@ def load_config(config_file: str = 'config/config.yaml',
103143
104144
105145def initialize_exp (settings , screen_id : int = 1 ) -> Tuple [Window , keyboard .Keyboard ]:
106- """
107- Initialize the experiment environment including window, keyboard, logging, and global quit key.
146+ """Set up the PsychoPy window, keyboard and logging.
108147
109- Parameters:
110- settings: Configuration object with display, logging, and task settings.
111- screen_id (int): ID of the screen to display the experiment window on.
148+ Parameters
149+ ----------
150+ settings : Any
151+ Configuration object with attributes describing window and logging
152+ settings.
153+ screen_id : int, optional
154+ Monitor index to open the window on. Defaults to ``1``.
155+
156+ Returns
157+ -------
158+ tuple of (Window, Keyboard)
159+ The created PsychoPy ``Window`` and ``Keyboard`` objects.
112160
113- Returns:
114- Tuple[Window, Keyboard]: The initialized PsychoPy window and keyboard objects.
161+ Examples
162+ --------
163+ >>> win, kb = initialize_exp(my_settings)
115164 """
116165 # === Window Setup ===
117166 mon = monitors .Monitor ('tempMonitor' )
@@ -178,9 +227,20 @@ def list_supported_voices(
178227 filter_lang : Optional [str ] = None ,
179228 human_readable : bool = False
180229):
181- """
182- – Returns raw voice dicts if human_readable=False.
183- – Prints a formatted table (including VoicePersonalities) if human_readable=True.
230+ """Query available edge-tts voices.
231+
232+ Parameters
233+ ----------
234+ filter_lang : str, optional
235+ Return only voices whose locale starts with this prefix.
236+ human_readable : bool, optional
237+ If ``True`` print a formatted table; otherwise return the raw list.
238+
239+ Returns
240+ -------
241+ list of dict or None
242+ The raw voice dictionaries if ``human_readable`` is ``False``,
243+ otherwise ``None``.
184244 """
185245 voices = asyncio .run (_list_supported_voices_async (filter_lang ))
186246 if not human_readable :
0 commit comments