@@ -359,6 +359,18 @@ def add_frequency_control(self, code):
359359 return code
360360
361361 def on_style_check_application (self , event ):
362+ """
363+ Handles the 'style_check' event, does not change the state and returns the current state.
364+
365+ It uses the linter to check if the style of the code is correct, if there
366+ are errors it writes them in all the consoles and raises the errors.
367+
368+ Parameters:
369+ event (Event): Has the fields code (user code), exercise_id and type (bt-studio or robotics-academy) .
370+
371+ Raises:
372+ Exception: with the errors found in the linter
373+ """
362374 def find_docker_console ():
363375 """Search console in docker different of /dev/pts/0"""
364376 pts_consoles = [f"/dev/pts/{ dev } " for dev in os .listdir ('/dev/pts/' ) if dev .isdigit ()]
@@ -405,7 +417,19 @@ def find_docker_console():
405417
406418 raise Exception (errors )
407419
408- def on_code_analysis (self , event ):
420+ def on_code_analysis (self , event ):
421+ """
422+ Handles the 'code_analysis' event, does not change the state and returns the current state.
423+
424+ It uses pylint to check for the errors and warnings in the code.
425+
426+ Parameters:
427+ event (Event): Has the fields code (user code) and disable_errors (disable errors id for pylint) .
428+
429+ Returns:
430+ Sends the output of the pylint command in the code-analysis event for the frontend.
431+ """
432+
409433 # Extract app config
410434 app_cfg = event .kwargs .get ("data" , {})
411435 code_string = app_cfg ["code" ]
@@ -462,6 +486,18 @@ def on_code_analysis(self, event):
462486 )
463487
464488 def on_code_format (self , event ):
489+ """
490+ Handles the 'code_format' event, does not change the state and returns the current state.
491+
492+ It uses the black formatter to format the user code.
493+
494+ Parameters:
495+ event (Event): Has the fields code (user code).
496+
497+ Returns:
498+ Sends the output of the black format in the code-format event for the frontend.
499+ """
500+
465501 # Extract app config
466502 app_cfg = event .kwargs .get ("data" , {})
467503 code = app_cfg ["code" ]
@@ -484,6 +520,18 @@ def on_code_format(self, event):
484520 LogManager .logger .info ('Error formating code' + str (e ))
485521
486522 def on_code_autocomplete (self , event ):
523+ """
524+ Handles the 'code_autocomplete' event, does not change the state and returns the current state.
525+
526+ It uses jedi to find the possible autocompletions in the user code give the cursor position.
527+
528+ Parameters:
529+ event (Event): Has the fields code (user code), line and col .
530+
531+ Returns:
532+ Sends the possible completions in the code-autocomplete event for the frontend.
533+ """
534+
487535 # Extract app config
488536 app_cfg = event .kwargs .get ("data" , {})
489537 code = app_cfg ["code" ]
0 commit comments