Skip to content

Commit d838d82

Browse files
pks-tgitster
authored andcommitted
meson: wire up support for AsciiDoctor
While our Makefile supports both Asciidoc and AsciiDoctor, our Meson build instructions only support the former. Wire up support for the latter, as well. Our Makefile always favors Asciidoc, but Meson will automatically figure out which of both to use based on whether they are installed or not. To keep compatibility with our Makefile it favors Asciidoc over Asciidoctor in case both are available. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 76cf4f6 commit d838d82

File tree

2 files changed

+84
-28
lines changed

2 files changed

+84
-28
lines changed

Documentation/meson.build

Lines changed: 82 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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=&#x2d;&#x2d;',
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

231289
cmd_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-
250304
documentation_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,

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ option('docs', type: 'array', choices: ['man', 'html'], value: [],
8585
description: 'Which documenattion formats to build and install.')
8686
option('default_help_format', type: 'combo', choices: ['man', 'html'], value: 'man',
8787
description: 'Default format used when executing git-help(1).')
88+
option('docs_backend', type: 'combo', choices: ['asciidoc', 'asciidoctor', 'auto'], value: 'auto',
89+
description: 'Which backend to use to generate documentation.')
8890

8991
# Testing.
9092
option('tests', type: 'boolean', value: true,

0 commit comments

Comments
 (0)