@@ -42,12 +42,13 @@ def _log(text, *, colour):
4242
4343
4444def show (* , context = None , command = None ):
45- """Show context and command-to-be-executed, with nice formatting and colors ."""
45+ """Show context and command-to-be-executed, with nice formatting and colours ."""
4646 if context is not None :
4747 _log (context , colour = Fore .CYAN )
4848 if command is not None :
4949 assert isinstance (command , (list , tuple ))
50- _log ("> " + shlex .join (command ), colour = Fore .BLUE )
50+ msg = f"> { shlex .join (command )} "
51+ _log (msg , colour = Fore .BLUE )
5152
5253
5354def get_builder (watcher , sphinx_args , * , host , port , pre_build_commands ):
@@ -67,13 +68,7 @@ def build():
6768 show (command = ["sphinx-build" ] + sphinx_args )
6869 subprocess .run (sphinx_command , check = True )
6970 except subprocess .CalledProcessError as e :
70- print (f"Command exited with exit code: { e .returncode } " )
71- print (
72- "The server will continue serving the build folder, but the contents "
73- "being served are no longer in sync with the documentation sources. "
74- "Please fix the cause of the error above or press Ctrl+C to stop the "
75- "server."
76- )
71+ cmd_exit (e .returncode )
7772 finally :
7873 # We present this information, so that the user does not need to keep track
7974 # of the port being used. It is presented by livereload when starting the
@@ -82,3 +77,13 @@ def build():
8277 show (context = f"Serving on http://{ host } :{ port } " )
8378
8479 return build
80+
81+
82+ def cmd_exit (return_code ):
83+ print (f"Command exited with exit code: { return_code } " )
84+ print (
85+ "The server will continue serving the build folder, but the contents "
86+ "being served are no longer in sync with the documentation sources. "
87+ "Please fix the cause of the error above or press Ctrl+C to stop the "
88+ "server."
89+ )
0 commit comments