@@ -47,15 +47,14 @@ def _list_quairkit_files(
47
47
relative_path = os .path .join (base_path , child ).replace (os .path .sep , "." )
48
48
49
49
if os .path .isdir (child_path ):
50
- sub_list = _list_quairkit_files (child_path , relative_path , [])
51
- if sub_list : # 仅当子目录非空时才添加
50
+ if sub_list := _list_quairkit_files (child_path , relative_path , []):
52
51
file_name_attr_list .append ((f"quairkit.{ relative_path } " , "folder" ))
53
52
file_name_attr_list .extend (sub_list )
54
53
elif child .endswith (".py" ):
55
54
file_name_attr_list .append (
56
55
(f"quairkit.{ relative_path .replace ('.py' , '' )} " , "python" )
57
56
)
58
-
57
+
59
58
file_name_attr_list = [
60
59
sub_array
61
60
for sub_array in file_name_attr_list
@@ -126,7 +125,7 @@ def _update_index_rst(
126
125
Welcome to { _platform_name } 's documentation!
127
126
====================================
128
127
129
- |quairkit| `Go to { _platform_name } Home <https://quair.github.io/ quairkit/>`_
128
+ |quairkit| `Go to QuAIR-Platform Home <https://www. quairkit.com />`_
130
129
131
130
"""
132
131
@@ -145,11 +144,11 @@ def _get_modules_rst(
145
144
file_list : List [Tuple [str , str ]], source_directory : str = _sphinx_source_dir
146
145
):
147
146
file_list_copy = file_list .copy ()
148
- rst_content = ""
149
- for item in file_list_copy :
150
- if item [ 0 ]. count ( "." ) == 1 :
151
- rst_content += f" \n { item [0 ]} "
152
- return rst_content
147
+ return "" . join (
148
+ f" \n { item [ 0 ] } "
149
+ for item in file_list_copy
150
+ if item [0 ]. count ( "." ) == 1
151
+ )
153
152
154
153
155
154
def _update_conf_py (source_directory : str = _sphinx_source_dir ):
@@ -274,11 +273,10 @@ def _update_conf_py(source_directory: str = _sphinx_source_dir):
274
273
_platform_dir_path = os .path .dirname (os .path .dirname (_current_script_path ))
275
274
276
275
_current_working_dir = os .getcwd ()
277
- if _current_working_dir == _platform_dir_path :
278
- result = _list_quairkit_files ()
279
- os .makedirs (_sphinx_source_dir , exist_ok = True )
280
- _update_index_rst (result )
281
- _update_function_rst (result )
282
- _update_conf_py ()
283
- else :
276
+ if _current_working_dir != _platform_dir_path :
284
277
raise SystemExit (f"The current working directory is not { _platform_dir_path } ." )
278
+ result = _list_quairkit_files ()
279
+ os .makedirs (_sphinx_source_dir , exist_ok = True )
280
+ _update_index_rst (result )
281
+ _update_function_rst (result )
282
+ _update_conf_py ()
0 commit comments