@@ -204,29 +204,87 @@ manpages = {
204
204
' gitworkflows.txt' : 7 ,
205
205
}
206
206
207
- asciidoc = find_program (' asciidoc' )
208
- git = find_program (' git' , required : false )
209
- xmlto = find_program (' xmlto' )
207
+ docs_backend = get_option (' docs_backend' )
208
+ if docs_backend == ' auto'
209
+ if find_program (' asciidoc' , required : false ).found()
210
+ docs_backend = ' asciidoc'
211
+ elif find_program (' asciidoctor' , required : false ).found()
212
+ docs_backend = ' asciidoctor'
213
+ else
214
+ error (' Neither asciidoc nor asciidoctor were found.' )
215
+ endif
216
+ endif
210
217
211
- asciidoc_conf = custom_target (
212
- command : [
213
- shell,
214
- meson .project_source_root() / ' GIT-VERSION-GEN' ,
215
- meson .project_source_root(),
216
- ' @INPUT@' ,
217
- ' @OUTPUT@' ,
218
- ],
219
- input : meson .current_source_dir() / ' asciidoc.conf.in' ,
220
- output : ' asciidoc.conf' ,
221
- depends : [git_version_file],
222
- env : version_gen_environment,
223
- )
218
+ if docs_backend == ' asciidoc'
219
+ asciidoc = find_program (' asciidoc' , required : true )
220
+ asciidoc_html = ' xhtml11'
221
+ asciidoc_docbook = ' docbook'
222
+ xmlto_extra = [ ]
224
223
225
- asciidoc_common_options = [
226
- asciidoc,
227
- ' --conf-file=' + asciidoc_conf.full_path(),
228
- ' --attribute=build_dir=' + meson .current_build_dir(),
229
- ]
224
+ asciidoc_conf = custom_target (
225
+ command : [
226
+ shell,
227
+ meson .project_source_root() / ' GIT-VERSION-GEN' ,
228
+ meson .project_source_root(),
229
+ ' @INPUT@' ,
230
+ ' @OUTPUT@' ,
231
+ ],
232
+ input : meson .current_source_dir() / ' asciidoc.conf.in' ,
233
+ output : ' asciidoc.conf' ,
234
+ depends : [git_version_file],
235
+ env : version_gen_environment,
236
+ )
237
+
238
+ asciidoc_common_options = [
239
+ asciidoc,
240
+ ' --conf-file=' + asciidoc_conf.full_path(),
241
+ ' --attribute=build_dir=' + meson .current_build_dir(),
242
+ ]
243
+
244
+ documentation_deps = [
245
+ asciidoc_conf,
246
+ ]
247
+ elif docs_backend == ' asciidoctor'
248
+ asciidoctor = find_program (' asciidoctor' , required : true )
249
+ asciidoc_html = ' xhtml5'
250
+ asciidoc_docbook = ' docbook5'
251
+ xmlto_extra = [
252
+ ' --skip-validation' ,
253
+ ' -x' , meson .current_source_dir() / ' manpage.xsl' ,
254
+ ]
255
+
256
+ asciidoctor_extensions = custom_target (
257
+ command : [
258
+ shell,
259
+ meson .project_source_root() / ' GIT-VERSION-GEN' ,
260
+ meson .project_source_root(),
261
+ ' @INPUT@' ,
262
+ ' @OUTPUT@' ,
263
+ ],
264
+ input : meson .current_source_dir() / ' asciidoctor-extensions.rb.in' ,
265
+ output : ' asciidoctor-extensions.rb' ,
266
+ depends : [git_version_file],
267
+ env : version_gen_environment,
268
+ )
269
+
270
+ asciidoc_common_options = [
271
+ asciidoctor,
272
+ ' --attribute' , ' compat-mode' ,
273
+ ' --attribute' , ' tabsize=8' ,
274
+ ' --attribute' , ' litdd=--' ,
275
+ ' --attribute' , ' docinfo=shared' ,
276
+ ' --attribute' , ' build_dir=' + meson .current_build_dir(),
277
+ ' --load-path' , meson .current_build_dir(),
278
+ ' --require' , ' asciidoctor-extensions' ,
279
+ ]
280
+
281
+ documentation_deps = [
282
+ asciidoctor_extensions,
283
+ ]
284
+ endif
285
+
286
+ git = find_program (' git' , required : false )
287
+ xmlto = find_program (' xmlto' )
230
288
231
289
cmd_lists = [
232
290
' cmds-ancillaryinterrogators.txt' ,
@@ -243,10 +301,6 @@ cmd_lists = [
243
301
' cmds-foreignscminterface.txt' ,
244
302
]
245
303
246
- documentation_deps = [
247
- asciidoc_conf,
248
- ]
249
-
250
304
documentation_deps += custom_target (
251
305
command : [
252
306
perl,
@@ -278,7 +332,7 @@ foreach manpage, category : manpages
278
332
if get_option (' docs' ).contains(' man' )
279
333
manpage_xml_target = custom_target (
280
334
command : asciidoc_common_options + [
281
- ' --backend=docbook ' ,
335
+ ' --backend=' + asciidoc_docbook ,
282
336
' --doctype=manpage' ,
283
337
' --out-file=@OUTPUT@' ,
284
338
meson .current_source_dir() / manpage,
@@ -301,7 +355,7 @@ foreach manpage, category : manpages
301
355
manpage_xml_target,
302
356
' -o' ,
303
357
meson .current_build_dir(),
304
- ],
358
+ ] + xmlto_extra ,
305
359
output : manpage_path,
306
360
install : true ,
307
361
install_dir : get_option (' mandir' ) / ' man' + category.to_string(),
@@ -311,7 +365,7 @@ foreach manpage, category : manpages
311
365
if get_option (' docs' ).contains(' html' ) and category == 1
312
366
custom_target (
313
367
command : asciidoc_common_options + [
314
- ' --backend=xhtml11 ' ,
368
+ ' --backend=' + asciidoc_html ,
315
369
' --doctype=manpage' ,
316
370
' --out-file=@OUTPUT@' ,
317
371
meson .current_source_dir() / manpage,
0 commit comments