1111
1212ZEPHYR_BASE = Path (__file__ ).parents [3 ]
1313
14+
1415# TODO: extend and modify this for Windows.
1516#
1617# This could be as simple as generating a couple of sets of instructions, one
@@ -20,6 +21,7 @@ class ZephyrAppCommandsDirective(Directive):
2021 This is a Zephyr directive for generating consistent documentation
2122 of the shell commands needed to manage (build, flash, etc.) an application.
2223 '''
24+
2325 has_content = False
2426 required_arguments = 0
2527 optional_arguments = 0
@@ -119,10 +121,8 @@ def run(self):
119121 build_dir = ('build' + '/' + build_dir_append ).rstrip ('/' )
120122
121123 # Prepare repeatable arguments
122- host_os = [host_os ] if host_os != "all" else [v for v in self .HOST_OS
123- if v != 'all' ]
124- tools = [tool ] if tool != "all" else [v for v in self .TOOLS
125- if v != 'all' ]
124+ host_os = [host_os ] if host_os != "all" else [v for v in self .HOST_OS if v != 'all' ]
125+ tools = [tool ] if tool != "all" else [v for v in self .TOOLS if v != 'all' ]
126126 build_args_list = build_args .split (' ' ) if build_args is not None else None
127127 snippet_list = snippets .split (',' ) if snippets is not None else None
128128 shield_list = shield .split (',' ) if shield is not None else None
@@ -155,7 +155,7 @@ def run(self):
155155 'debug_args' : debug_args ,
156156 'debugserver_args' : debugserver_args ,
157157 'attach_args' : attach_args ,
158- }
158+ }
159159
160160 if 'west' in tools :
161161 w = self ._generate_west (** run_config )
@@ -171,8 +171,7 @@ def run(self):
171171 c = self ._generate_cmake (** run_config )
172172 if tool_comment :
173173 paragraph = nodes .paragraph ()
174- paragraph += nodes .Text (tool_comment .format (
175- f'CMake and { generator } ' ))
174+ paragraph += nodes .Text (tool_comment .format (f'CMake and { generator } ' ))
176175 content .append (paragraph )
177176 content .append (self ._lit_block (c ))
178177 else :
@@ -284,8 +283,10 @@ def _generate_west(self, **kwargs):
284283 def _mkdir (mkdir , build_dir , host_os , skip_config ):
285284 content = []
286285 if skip_config :
287- content .append (f"# If you already made a build directory ({ build_dir } ) and ran cmake, "
288- f"just 'cd { build_dir } ' instead." )
286+ content .append (
287+ f"# If you already made a build directory ({ build_dir } ) and ran cmake, "
288+ f"just 'cd { build_dir } ' instead."
289+ )
289290 if host_os == 'all' :
290291 content .append (f'mkdir { build_dir } && cd { build_dir } ' )
291292 if host_os == "unix" :
@@ -320,8 +321,7 @@ def _cd_into(self, mkdir, **kwargs):
320321 if not app and mkdir and num_slashes == 0 :
321322 # When there's no app and a single level deep build dir,
322323 # simplify output
323- content .extend (self ._mkdir (mkdir , build_dir , 'all' ,
324- skip_config ))
324+ content .extend (self ._mkdir (mkdir , build_dir , 'all' , skip_config ))
325325 if not compact :
326326 content .append ('' )
327327 return content
@@ -383,16 +383,20 @@ def _generate_cmake(self, **kwargs):
383383
384384 if not compact :
385385 if not cd_into and skip_config :
386- content .append (f'# If you already ran cmake with -B{ build_dir } , you '
387- f'can skip this step and run { generator } directly.' )
386+ content .append (
387+ f'# If you already ran cmake with -B{ build_dir } , you '
388+ f'can skip this step and run { generator } directly.'
389+ )
388390 else :
389- content .append (f'# Use cmake to configure a { generator .capitalize ()} -based build'
390- 'system:' )
391+ content .append (
392+ f'# Use cmake to configure a { generator .capitalize ()} -based buildsystem:'
393+ )
391394
392- content .append (f'cmake{ cmake_build_dir } { gen_arg } { cmake_args } { snippet_args } { shield_args } { source_dir } ' )
395+ content .append (
396+ f'cmake{ cmake_build_dir } { gen_arg } { cmake_args } { snippet_args } { shield_args } { source_dir } '
397+ )
393398 if not compact :
394- content .extend (['' ,
395- '# Now run the build tool on the generated build system:' ])
399+ content .extend (['' , '# Now run the build tool on the generated build system:' ])
396400
397401 if 'build' in goals :
398402 content .append (f'{ generator } { tool_build_dir } { build_args } ' )
@@ -407,8 +411,4 @@ def _generate_cmake(self, **kwargs):
407411def setup (app ):
408412 app .add_directive ('zephyr-app-commands' , ZephyrAppCommandsDirective )
409413
410- return {
411- 'version' : '1.0' ,
412- 'parallel_read_safe' : True ,
413- 'parallel_write_safe' : True
414- }
414+ return {'version' : '1.0' , 'parallel_read_safe' : True , 'parallel_write_safe' : True }
0 commit comments