Skip to content

Commit 6970b40

Browse files
add documentation check command and time tracking (#218)
1 parent 866f2bb commit 6970b40

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

docs.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ def docs(source_dir = "docs", data = [], deps = []):
8585
},
8686
)
8787

88+
py_binary(
89+
name = "docs_check",
90+
tags = ["cli_help=Verify documentation [run]"],
91+
srcs = ["@score_docs_as_code//src:incremental.py"],
92+
data = data,
93+
deps = deps,
94+
env = {
95+
"SOURCE_DIRECTORY": source_dir,
96+
"DATA": str(data),
97+
"ACTION": "check",
98+
},
99+
)
100+
88101
py_binary(
89102
name = "live_preview",
90103
tags = ["cli_help=Live preview documentation in the browser [run]"],

src/incremental.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import logging
1616
import os
1717
import sys
18+
import time
1819
from pathlib import Path
1920

2021
import debugpy
@@ -102,4 +103,24 @@ def get_env(name: str) -> str:
102103
]
103104
)
104105
else:
105-
sys.exit(sphinx_main(base_arguments))
106+
if action == "incremental":
107+
builder = "html"
108+
elif action == "check":
109+
builder = "needs"
110+
else:
111+
raise ValueError(f"Unknown action: {action}")
112+
113+
base_arguments.extend(
114+
[
115+
"-b",
116+
builder,
117+
]
118+
)
119+
120+
start_time = time.perf_counter()
121+
exit_code = sphinx_main(base_arguments)
122+
end_time = time.perf_counter()
123+
duration = end_time - start_time
124+
print(f"docs ({action}) finished in {duration:.1f} seconds")
125+
126+
sys.exit(exit_code)

0 commit comments

Comments
 (0)