Skip to content

Commit

Permalink
build docs in the background
Browse files Browse the repository at this point in the history
  • Loading branch information
RussTedrake committed Jan 24, 2025
1 parent a0e5010 commit f8215c2
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions book/update.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,30 @@ try:

os.chdir("..")

build_output = subprocess.run(
[
"/bin/bash",
"-c",
"source venv/bin/activate && "
"poetry install --only docs && "
"echo 'Contents of /tmp before:' && ls -la /tmp && "
"sphinx-build -M html underactuated /tmp/underactuated_doc && "
"echo 'Contents of /tmp after:' && ls -la /tmp && "
"rm -rf book/python && "
"cp -r /tmp/underactuated_doc/html book/python",
],
capture_output=True,
text=True,
check=True,
).stdout
# Start the build process in background
with open("/tmp/underactuated_build_docs.log", "w") as log_file:
subprocess.Popen(
[
"/bin/bash",
"-c",
"source venv/bin/activate && "
"poetry install --only docs && "
"sphinx-build -M html underactuated /tmp/underactuated_doc && "
"rm -rf book/python && "
"cp -r /tmp/underactuated_doc/html book/python",
],
stdout=log_file,
stderr=subprocess.STDOUT,
start_new_session=True,
)

# Now we can safely print headers and content
print("Content-Type: text/html\n")
print("<html><body>")
print("<p>pulling repo...</p>")
print(f"<pre>{git_output}</pre>")
print("<p>done.</p>")
print("<p>building documentation...</p>")
print(f"<pre>{build_output}</pre>")
print("<p>done.</p>")
print("<p>Documentation build started in the background.</p>")
print("<p>Check /tmp/underactuated_build_docs.log for progress.</p>")
print("</body></html>")

except Exception as e:
Expand Down

0 comments on commit f8215c2

Please sign in to comment.