Skip to content

Commit 450f647

Browse files
committed
Update update_quairkit_rst.py
1 parent 5d3aace commit 450f647

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

docs/update_quairkit_rst.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@ def _list_quairkit_files(
4747
relative_path = os.path.join(base_path, child).replace(os.path.sep, ".")
4848

4949
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, []):
5251
file_name_attr_list.append((f"quairkit.{relative_path}", "folder"))
5352
file_name_attr_list.extend(sub_list)
5453
elif child.endswith(".py"):
5554
file_name_attr_list.append(
5655
(f"quairkit.{relative_path.replace('.py', '')}", "python")
5756
)
58-
57+
5958
file_name_attr_list = [
6059
sub_array
6160
for sub_array in file_name_attr_list
@@ -126,7 +125,7 @@ def _update_index_rst(
126125
Welcome to {_platform_name}'s documentation!
127126
====================================
128127
129-
|quairkit| `Go to {_platform_name} Home <https://quair.github.io/quairkit/>`_
128+
|quairkit| `Go to QuAIR-Platform Home <https://www.quairkit.com/>`_
130129
131130
"""
132131

@@ -145,11 +144,11 @@ def _get_modules_rst(
145144
file_list: List[Tuple[str, str]], source_directory: str = _sphinx_source_dir
146145
):
147146
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+
)
153152

154153

155154
def _update_conf_py(source_directory: str = _sphinx_source_dir):
@@ -274,11 +273,10 @@ def _update_conf_py(source_directory: str = _sphinx_source_dir):
274273
_platform_dir_path = os.path.dirname(os.path.dirname(_current_script_path))
275274

276275
_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:
284277
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

Comments
 (0)