Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
913e38df
Unverified
Commit
913e38df
authored
Apr 03, 2025
by
renxin
Committed by
GitHub
Apr 03, 2025
Browse files
Feature/revise docs ci (#5056)
parent
d95269f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
docs/wrap_run_llm.py
docs/wrap_run_llm.py
+22
-15
No files found.
docs/wrap_run_llm.py
View file @
913e38df
...
...
@@ -13,27 +13,34 @@ def insert_runllm_widget(html_content):
return
re
.
sub
(
r
"</body>"
,
f
"
{
widget_script
}
\n
</body>"
,
html_content
)
def
process_html_files
(
build_dir
):
for
root
,
dirs
,
files
in
os
.
walk
(
build_dir
):
for
file
in
files
:
if
file
.
endswith
(
".html"
):
file_path
=
os
.
path
.
join
(
root
,
file
)
# Read the HTML file
with
open
(
file_path
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
# Insert the RunLLM widget
modified_content
=
insert_runllm_widget
(
content
)
# Write back the modified content
with
open
(
file_path
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
modified_content
)
def
main
():
# Get the build directory path
build_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"_build"
,
"html"
)
index_file
=
os
.
path
.
join
(
build_dir
,
"index.html"
)
# Process only index.html
if
os
.
path
.
exists
(
index_file
):
# Read the HTML file
with
open
(
index_file
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
# Insert the RunLLM widget
modified_content
=
insert_runllm_widget
(
content
)
# Write back the modified content
with
open
(
index_file
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
modified_content
)
# Process all HTML files
if
os
.
path
.
exists
(
build_dir
):
process_html_files
(
build_dir
)
else
:
print
(
f
"
Index file
not found:
{
index_file
}
"
)
print
(
f
"
Build directory
not found:
{
build_dir
}
"
)
if
__name__
==
"__main__"
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment