Skip to content

Commit 4b78b72

Browse files
committed
Enhance build script with timing and docstrings
1 parent 7cfaf29 commit 4b78b72

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

builder/build_cli.py

+31-1
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,39 @@
1313
import sys
1414
import requests
1515
import json
16+
import time
1617

1718
# Automatically watch the following extra directories when --serve is used.
1819
EXTRA_WATCH_DIRS = ["exts", "themes"]
1920

2021
SPEC_CHECKSUM_URL = "https://spec.ferrocene.dev/paragraph-ids.json"
2122
SPEC_LOCKFILE = "spec.lock"
2223

23-
def build_docs(root, builder, clear, serve, debug, offline, spec_lock_consistency_check):
24+
def build_docs(
25+
root: Path,
26+
builder: str,
27+
clear: bool,
28+
serve: bool,
29+
debug: bool,
30+
offline: bool,
31+
spec_lock_consistency_check: bool
32+
) -> Path:
33+
"""
34+
Builds the Sphinx documentation with the specified options.
35+
36+
Args:
37+
root: The root directory of the documentation.
38+
builder: The builder to use (e.g., 'html', 'xml').
39+
clear: Whether to disable incremental builds.
40+
serve: Whether to start a local server with live reload.
41+
debug: Whether to enable debug mode.
42+
offline: Whether to build in offline mode.
43+
spec_lock_consistency_check: Whether to check spec lock consistency.
44+
45+
Returns:
46+
Path: The path to the generated documentation.
47+
"""
48+
2449
dest = root / "build"
2550

2651
args = ["-b", builder, "-d", dest / "doctrees"]
@@ -61,6 +86,9 @@ def build_docs(root, builder, clear, serve, debug, offline, spec_lock_consistenc
6186
args += ["-W", "--keep-going"]
6287

6388
try:
89+
90+
# Tracking build time
91+
timer_start = time.perf_counter()
6492
subprocess.run(
6593
[
6694
"sphinx-autobuild" if serve else "sphinx-build",
@@ -76,6 +104,8 @@ def build_docs(root, builder, clear, serve, debug, offline, spec_lock_consistenc
76104
print("\nhint: if you see an exception, pass --debug to see the full traceback")
77105
exit(1)
78106

107+
timer_end = time.perf_counter()
108+
print(f"\nBuild finished in {timer_end - timer_start:.2f} seconds.")
79109
return dest / builder
80110

81111
def update_spec_lockfile(spec_checksum_location, lockfile_location):

0 commit comments

Comments
 (0)