Skip to content

Commit 37d57e4

Browse files
committed
Do not create HTML docs of Litani man pages if a flag is specified
Running `doc/configure` with `--no-html` allows one to ultimately build only the man equivalent of the Litani documentation.
1 parent 1960b0c commit 37d57e4

File tree

1 file changed

+42
-22
lines changed

1 file changed

+42
-22
lines changed

doc/configure

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
# permissions and limitations under the License.
1515

1616

17-
import sys
17+
import argparse
1818
import pathlib
19+
import sys
1920

2021

2122
DOC_DIR = pathlib.Path(sys.path[0]).resolve()
@@ -89,6 +90,19 @@ RULES = [{
8990
}]
9091

9192

93+
def get_args():
94+
pars = argparse.ArgumentParser(description="Build documentation for Litani")
95+
for arg in [{
96+
"flags": ["--no-html"],
97+
"action": "store_false",
98+
"help": "Do not build a version of the documentation in HTML",
99+
"dest": "gen_html",
100+
}]:
101+
flags = arg.pop("flags")
102+
pars.add_argument(*flags, **arg)
103+
return pars.parse_args()
104+
105+
92106
def make_html_unique(man_name, html_man, html_mans, builds):
93107
html_unique = HTML_UNIQUE_DIR / f"{man_name}.html"
94108
builds.append({
@@ -118,7 +132,7 @@ def man_to_html(man_name, man_out, builds):
118132

119133

120134
def convert_man_dir_to_man(
121-
src_dir, dst_dir, rule, html_mans, builds, extra_inputs=None):
135+
src_dir, dst_dir, rule, html_mans, builds, gen_html, extra_inputs=None):
122136
for man in (src_dir).iterdir():
123137
man_name = str(man.name).split(".", 1)[0]
124138
if man.suffix == ".scdoc":
@@ -140,11 +154,12 @@ def convert_man_dir_to_man(
140154
"data-path": man.resolve(),
141155
}
142156
})
143-
html_man = man_to_html(man_name, man_out, builds)
144-
make_html_unique(man_name, html_man, html_mans, builds)
157+
if gen_html:
158+
html_man = man_to_html(man_name, man_out, builds)
159+
make_html_unique(man_name, html_man, html_mans, builds)
145160

146161

147-
def add_litani_7(builds, html_mans):
162+
def add_litani_7(builds, html_mans, gen_html):
148163
"""The litani(7) man page is special because it contains a table of contents
149164
of the other pages, so it depends on the others."""
150165

@@ -171,34 +186,39 @@ def add_litani_7(builds, html_mans):
171186
"outputs": [man_out],
172187
"rule": "sc_to_man",
173188
}])
174-
html_man = man_to_html("litani.7", man_out, builds)
175-
make_html_unique("litani.7", html_man, html_mans, builds)
189+
if gen_html:
190+
html_man = man_to_html("litani.7", man_out, builds)
191+
make_html_unique("litani.7", html_man, html_mans, builds)
176192

177193

178194
def main():
195+
args = get_args()
179196
builds = []
180197
html_mans = []
181198

182199
convert_man_dir_to_man(
183-
SRC_DIR / "man", MAN_DIR, "sc_to_man", html_mans, builds)
200+
SRC_DIR / "man", MAN_DIR, "sc_to_man", html_mans, builds,
201+
args.gen_html)
184202
convert_man_dir_to_man(
185203
SRC_DIR / "voluptuous-man", MAN_DIR, "voluptuous_to_man", html_mans,
186-
builds, extra_inputs=[TEMPLATE_DIR / "voluptuous-man.jinja.scdoc"])
204+
builds, args.gen_html,
205+
extra_inputs=[TEMPLATE_DIR / "voluptuous-man.jinja.scdoc"])
187206

188-
add_litani_7(builds, html_mans)
207+
add_litani_7(builds, html_mans, args.gen_html)
189208

190-
builds.append({
191-
"inputs": html_mans + [
192-
BIN_DIR / "build-html-doc",
193-
TEMPLATE_DIR / "index.jinja.html",
194-
],
195-
"outputs": [DOC_DIR / "out" / "html"/ "index.html"],
196-
"rule": "build_html_doc",
197-
"variables": {
198-
"html-mans": " ".join([str(h) for h in html_mans]),
199-
"man-html-dir": HTML_MAN_SRC_DIR,
200-
}
201-
})
209+
if args.gen_html:
210+
builds.append({
211+
"inputs": html_mans + [
212+
BIN_DIR / "build-html-doc",
213+
TEMPLATE_DIR / "index.jinja.html",
214+
],
215+
"outputs": [DOC_DIR / "out" / "html"/ "index.html"],
216+
"rule": "build_html_doc",
217+
"variables": {
218+
"html-mans": " ".join([str(h) for h in html_mans]),
219+
"man-html-dir": HTML_MAN_SRC_DIR,
220+
}
221+
})
202222

203223
for build in builds:
204224
for k, v in build.items():

0 commit comments

Comments
 (0)