Skip to content

Commit d0ecdb7

Browse files
renxinxfinger92
authored andcommitted
Feature/revise docs ci (sgl-project#5056)
1 parent fffeec5 commit d0ecdb7

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

docs/wrap_run_llm.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,34 @@ def insert_runllm_widget(html_content):
1313
return re.sub(r"</body>", f"{widget_script}\n</body>", html_content)
1414

1515

16+
def process_html_files(build_dir):
17+
for root, dirs, files in os.walk(build_dir):
18+
for file in files:
19+
if file.endswith(".html"):
20+
file_path = os.path.join(root, file)
21+
22+
# Read the HTML file
23+
with open(file_path, "r", encoding="utf-8") as f:
24+
content = f.read()
25+
26+
# Insert the RunLLM widget
27+
modified_content = insert_runllm_widget(content)
28+
29+
# Write back the modified content
30+
with open(file_path, "w", encoding="utf-8") as f:
31+
f.write(modified_content)
32+
33+
1634
def main():
1735
# Get the build directory path
1836
build_dir = os.path.join(
1937
os.path.dirname(os.path.abspath(__file__)), "_build", "html"
2038
)
21-
index_file = os.path.join(build_dir, "index.html")
22-
23-
# Process only index.html
24-
if os.path.exists(index_file):
25-
# Read the HTML file
26-
with open(index_file, "r", encoding="utf-8") as f:
27-
content = f.read()
28-
29-
# Insert the RunLLM widget
30-
modified_content = insert_runllm_widget(content)
31-
32-
# Write back the modified content
33-
with open(index_file, "w", encoding="utf-8") as f:
34-
f.write(modified_content)
39+
# Process all HTML files
40+
if os.path.exists(build_dir):
41+
process_html_files(build_dir)
3542
else:
36-
print(f"Index file not found: {index_file}")
43+
print(f"Build directory not found: {build_dir}")
3744

3845

3946
if __name__ == "__main__":

0 commit comments

Comments
 (0)