@@ -204,29 +204,87 @@ manpages = {
204204 ' gitworkflows.txt' : 7 ,
205205}
206206
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
210217
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 = [ ]
224223
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' )
230288
231289cmd_lists = [
232290 ' cmds-ancillaryinterrogators.txt' ,
@@ -243,10 +301,6 @@ cmd_lists = [
243301 ' cmds-foreignscminterface.txt' ,
244302]
245303
246- documentation_deps = [
247- asciidoc_conf,
248- ]
249-
250304documentation_deps += custom_target (
251305 command : [
252306 perl,
@@ -278,7 +332,7 @@ foreach manpage, category : manpages
278332 if get_option (' docs' ).contains(' man' )
279333 manpage_xml_target = custom_target (
280334 command : asciidoc_common_options + [
281- ' --backend=docbook ' ,
335+ ' --backend=' + asciidoc_docbook ,
282336 ' --doctype=manpage' ,
283337 ' --out-file=@OUTPUT@' ,
284338 meson .current_source_dir() / manpage,
@@ -301,7 +355,7 @@ foreach manpage, category : manpages
301355 manpage_xml_target,
302356 ' -o' ,
303357 meson .current_build_dir(),
304- ],
358+ ] + xmlto_extra ,
305359 output : manpage_path,
306360 install : true ,
307361 install_dir : get_option (' mandir' ) / ' man' + category.to_string(),
@@ -311,7 +365,7 @@ foreach manpage, category : manpages
311365 if get_option (' docs' ).contains(' html' ) and category == 1
312366 custom_target (
313367 command : asciidoc_common_options + [
314- ' --backend=xhtml11 ' ,
368+ ' --backend=' + asciidoc_html ,
315369 ' --doctype=manpage' ,
316370 ' --out-file=@OUTPUT@' ,
317371 meson .current_source_dir() / manpage,
0 commit comments