@@ -54,6 +54,14 @@ RULES = [{
54
54
" --template"
55
55
f" { TEMPLATE_DIR / 'voluptuous-man.jinja.scdoc' } "
56
56
" | scdoc > ${out}"
57
+ }, {
58
+ "name" : "gen-litani7" ,
59
+ "description" : "generating litani(7).scdoc" ,
60
+ "command" :
61
+ "${script}"
62
+ " --dst ${out}"
63
+ " --src ${src}"
64
+ f" --man-dir { MAN_DIR } "
57
65
}, {
58
66
"name" : "man_to_html" ,
59
67
"description" : "converting ${man-name} HTML" ,
@@ -81,28 +89,28 @@ RULES = [{
81
89
}]
82
90
83
91
84
- def make_html_unique (man , html_man , html_mans , builds ):
85
- html_unique = HTML_UNIQUE_DIR / f"{ man . stem } .html"
92
+ def make_html_unique (man_name , html_man , html_mans , builds ):
93
+ html_unique = HTML_UNIQUE_DIR / f"{ man_name } .html"
86
94
builds .append ({
87
95
"inputs" : [html_man , BIN_DIR / "uniquify-header-ids" ],
88
96
"outputs" : [html_unique ],
89
97
"rule" : "uniquify_header_ids" ,
90
98
"variables" : {
91
- "man-name" : man . stem ,
99
+ "man-name" : man_name ,
92
100
"in-file" : html_man ,
93
101
}
94
102
})
95
103
html_mans .append (html_unique )
96
104
97
105
98
- def man_to_html (man , man_out , builds ):
99
- html_man = HTML_MAN_SRC_DIR / f"{ man . stem } .html"
106
+ def man_to_html (man_name , man_out , builds ):
107
+ html_man = HTML_MAN_SRC_DIR / f"{ man_name } .html"
100
108
builds .append ({
101
109
"inputs" : [man_out ],
102
110
"outputs" : [html_man ],
103
111
"rule" : "man_to_html" ,
104
112
"variables" : {
105
- "man-name" : man . stem ,
113
+ "man-name" : man_name ,
106
114
"in-file" : html_man ,
107
115
}
108
116
})
@@ -112,13 +120,14 @@ def man_to_html(man, man_out, builds):
112
120
def convert_man_dir_to_man (
113
121
src_dir , dst_dir , rule , html_mans , builds , extra_inputs = None ):
114
122
for man in (src_dir ).iterdir ():
123
+ man_name = str (man .name ).split ("." , 1 )[0 ]
115
124
if man .suffix == ".scdoc" :
116
125
with open (man ) as fp :
117
126
line = fp .readline ().rstrip ()
118
127
index = line [line .find ('(' )+ 1 :line .find (')' )]
119
- man_out = dst_dir / f"{ man . stem } .{ index } "
128
+ man_out = dst_dir / f"{ man_name } .{ index } "
120
129
else :
121
- man_out = dst_dir / f"{ man . stem } .5"
130
+ man_out = dst_dir / f"{ man_name } .5"
122
131
inputs = [man ]
123
132
if extra_inputs :
124
133
inputs .extend (extra_inputs )
@@ -127,12 +136,43 @@ def convert_man_dir_to_man(
127
136
"outputs" : [man_out ],
128
137
"rule" : rule ,
129
138
"variables" : {
130
- "man-name" : man . stem ,
139
+ "man-name" : man_name ,
131
140
"data-path" : man .resolve (),
132
141
}
133
142
})
134
- html_man = man_to_html (man , man_out , builds )
135
- make_html_unique (man , html_man , html_mans , builds )
143
+ html_man = man_to_html (man_name , man_out , builds )
144
+ make_html_unique (man_name , html_man , html_mans , builds )
145
+
146
+
147
+ def add_litani_7 (builds , html_mans ):
148
+ """The litani(7) man page is special because it contains a table of contents
149
+ of the other pages, so it depends on the others."""
150
+
151
+ templ = SRC_DIR / "litani7" / "litani.jinja.scdoc"
152
+ script = BIN_DIR / "gen-litani7"
153
+
154
+ inputs = [b ["outputs" ][0 ] for b in builds if str (b ["outputs" ][0 ])[- 1 ].isdigit ()]
155
+ inputs .extend ([templ , script ])
156
+
157
+ sc_out = TMP_DIR / "litani.scdoc"
158
+ man_out = TMP_DIR / "litani.7"
159
+
160
+ builds .extend ([{
161
+ "inputs" : inputs ,
162
+ "outputs" : [sc_out ],
163
+ "rule" : "gen-litani7" ,
164
+ "variables" : {
165
+ "src" : templ ,
166
+ "script" : script ,
167
+ "man-dir" : MAN_DIR ,
168
+ }
169
+ }, {
170
+ "inputs" : [sc_out ],
171
+ "outputs" : [man_out ],
172
+ "rule" : "sc_to_man" ,
173
+ }])
174
+ html_man = man_to_html ("litani.7" , man_out , builds )
175
+ make_html_unique ("litani.7" , html_man , html_mans , builds )
136
176
137
177
138
178
def main ():
@@ -145,6 +185,8 @@ def main():
145
185
SRC_DIR / "voluptuous-man" , MAN_DIR , "voluptuous_to_man" , html_mans ,
146
186
builds , extra_inputs = [TEMPLATE_DIR / "voluptuous-man.jinja.scdoc" ])
147
187
188
+ add_litani_7 (builds , html_mans )
189
+
148
190
builds .append ({
149
191
"inputs" : html_mans + [
150
192
BIN_DIR / "build-html-doc" ,
@@ -162,6 +204,8 @@ def main():
162
204
for k , v in build .items ():
163
205
if isinstance (v , list ):
164
206
build [k ] = [str (s ) for s in v ]
207
+ elif isinstance (v , dict ):
208
+ build [k ] = {ik : str (iv ) for ik , iv in v .items ()}
165
209
try :
166
210
build ["implicit" ].append (str (DOC_DIR / "configure" ))
167
211
except KeyError :
0 commit comments