git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 01/12] meson: wire up support for AsciiDoctor

From
Patrick Steinhardt <ps@pks.im>
Date
Dec 27, 2024, 13:59 UTC
Message-ID
<20241227-b4-pks-meson-docs-v2-1-f61e63edbfa1@pks.im>
In-Reply-To
<20241227-b4-pks-meson-docs-v2-0-f61e63edbfa1@pks.im>

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 <ps@pks.im>
---
 Documentation/meson.build | 110 ++++++++++++++++++++++++++++++++++------------
 meson_options.txt         |   2 +
 2 files changed, 84 insertions(+), 28 deletions(-)
diff --git a/Documentation/meson.build b/Documentation/meson.build
index fca3eab1f1360a5fdeda89c1766ab8cdb3267b89..acd6d86ec779e63230c88b7bff937aff330d2d4f 100644
--- a/Documentation/meson.build
+++ b/Documentation/meson.build
@@ -204,29 +204,87 @@ manpages = {
   'gitworkflows.txt' : 7,
 }
 
-asciidoc = find_program('asciidoc')
-git = find_program('git', required: false)
-xmlto = find_program('xmlto')
+docs_backend = get_option('docs_backend')
+if docs_backend == 'auto'
+  if find_program('asciidoc', required: false).found()
+    docs_backend = 'asciidoc'
+  elif find_program('asciidoctor', required: false).found()
+    docs_backend = 'asciidoctor'
+  else
+    error('Neither asciidoc nor asciidoctor were found.')
+  endif
+endif
 
-asciidoc_conf = custom_target(
-  command: [
-    shell,
-    meson.project_source_root() / 'GIT-VERSION-GEN',
-    meson.project_source_root(),
-    '@INPUT@',
-    '@OUTPUT@',
-  ],
-  input: meson.current_source_dir() / 'asciidoc.conf.in',
-  output: 'asciidoc.conf',
-  depends: [git_version_file],
-  env: version_gen_environment,
-)
+if docs_backend == 'asciidoc'
+  asciidoc = find_program('asciidoc', required: true)
+  asciidoc_html = 'xhtml11'
+  asciidoc_docbook = 'docbook'
+  xmlto_extra = [ ]
 
-asciidoc_common_options = [
-  asciidoc,
-  '--conf-file=' + asciidoc_conf.full_path(),
-  '--attribute=build_dir=' + meson.current_build_dir(),
-]
+  asciidoc_conf = custom_target(
+    command: [
+      shell,
+      meson.project_source_root() / 'GIT-VERSION-GEN',
+      meson.project_source_root(),
+      '@INPUT@',
+      '@OUTPUT@',
+    ],
+    input: meson.current_source_dir() / 'asciidoc.conf.in',
+    output: 'asciidoc.conf',
+    depends: [git_version_file],
+    env: version_gen_environment,
+  )
+
+  asciidoc_common_options = [
+    asciidoc,
+    '--conf-file=' + asciidoc_conf.full_path(),
+    '--attribute=build_dir=' + meson.current_build_dir(),
+  ]
+
+  documentation_deps = [
+    asciidoc_conf,
+  ]
+elif docs_backend == 'asciidoctor'
+  asciidoctor = find_program('asciidoctor', required: true)
+  asciidoc_html = 'xhtml5'
+  asciidoc_docbook = 'docbook5'
+  xmlto_extra = [
+    '--skip-validation',
+    '-x', meson.current_source_dir() / 'manpage.xsl',
+  ]
+
+  asciidoctor_extensions = custom_target(
+    command: [
+      shell,
+      meson.project_source_root() / 'GIT-VERSION-GEN',
+      meson.project_source_root(),
+      '@INPUT@',
+      '@OUTPUT@',
+    ],
+    input: meson.current_source_dir() / 'asciidoctor-extensions.rb.in',
+    output: 'asciidoctor-extensions.rb',
+    depends: [git_version_file],
+    env: version_gen_environment,
+  )
+
+  asciidoc_common_options = [
+    asciidoctor,
+    '--attribute', 'compat-mode',
+    '--attribute', 'tabsize=8',
+    '--attribute', 'litdd=&#x2d;&#x2d;',
+    '--attribute', 'docinfo=shared',
+    '--attribute', 'build_dir=' + meson.current_build_dir(),
+    '--load-path', meson.current_build_dir(),
+    '--require', 'asciidoctor-extensions',
+  ]
+
+  documentation_deps = [
+    asciidoctor_extensions,
+  ]
+endif
+
+git = find_program('git', required: false)
+xmlto = find_program('xmlto')
 
 cmd_lists = [
   'cmds-ancillaryinterrogators.txt',
@@ -243,10 +301,6 @@ cmd_lists = [
   'cmds-foreignscminterface.txt',
 ]
 
-documentation_deps = [
-  asciidoc_conf,
-]
-
 documentation_deps += custom_target(
   command: [
     perl,
@@ -278,7 +332,7 @@ foreach manpage, category : manpages
   if get_option('docs').contains('man')
     manpage_xml_target = custom_target(
       command: asciidoc_common_options + [
-        '--backend=docbook',
+        '--backend=' + asciidoc_docbook,
         '--doctype=manpage',
         '--out-file=@OUTPUT@',
         meson.current_source_dir() / manpage,
@@ -301,7 +355,7 @@ foreach manpage, category : manpages
         manpage_xml_target,
         '-o',
         meson.current_build_dir(),
-      ],
+      ] + xmlto_extra,
       output: manpage_path,
       install: true,
       install_dir: get_option('mandir') / 'man' + category.to_string(),
@@ -311,7 +365,7 @@ foreach manpage, category : manpages
   if get_option('docs').contains('html') and category == 1
     custom_target(
       command: asciidoc_common_options + [
-        '--backend=xhtml11',
+        '--backend=' + asciidoc_html,
         '--doctype=manpage',
         '--out-file=@OUTPUT@',
         meson.current_source_dir() / manpage,
diff --git a/meson_options.txt b/meson_options.txt
index 4be7eab39939178ae2ffde1ff9e78f83a1b482b2..f50bb40cdf6046529a0cea0a03a8cb696c3a6b18 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -85,6 +85,8 @@ option('docs', type: 'array', choices: ['man', 'html'], value: [],
   description: 'Which documenattion formats to build and install.')
 option('default_help_format', type: 'combo', choices: ['man', 'html'], value: 'man',
   description: 'Default format used when executing git-help(1).')
+option('docs_backend', type: 'combo', choices: ['asciidoc', 'asciidoctor', 'auto'], value: 'auto',
+  description: 'Which backend to use to generate documentation.')
 
 # Testing.
 option('tests', type: 'boolean', value: true,
-- 
2.48.0.rc0.311.gb6c66824c1.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 19 of 33 in “meson: wire up missing HTML documentation”
  1. 00/10 meson: wire up missing HTML documentationPatrick Steinhardt, Dec 13, 2024
  2. 01/10 meson: wire up support for AsciiDoctorPatrick Steinhardt, Dec 13, 2024
  3. 02/10 meson: properly wire up dependencies for our docsPatrick Steinhardt, Dec 13, 2024
  4. 03/10 meson: fix generation of merge toolsPatrick Steinhardt, Dec 13, 2024
  5. 04/10 meson: generate HTML pages for all man page categoriesPatrick Steinhardt, Dec 13, 2024
  6. Toon ClaesDec 23, 2024
  7. Patrick SteinhardtDec 27, 2024
  8. 06/10 meson: generate user manualPatrick Steinhardt, Dec 13, 2024
  9. 05/10 Documentation: inline user-manual.confPatrick Steinhardt, Dec 13, 2024
  10. 07/10 Documentation: refactor "api-index.sh" for out-of-tree buildsPatrick Steinhardt, Dec 13, 2024
  11. 09/10 meson: generate articlesPatrick Steinhardt, Dec 13, 2024
  12. 08/10 Documentation: refactor "howto-index.sh" for out-of-tree buildsPatrick Steinhardt, Dec 13, 2024
  13. 10/10 meson: install static files for HTML documentationPatrick Steinhardt, Dec 13, 2024
  14. Toon ClaesDec 23, 2024
  15. Patrick SteinhardtDec 27, 2024
  16. Toon ClaesJan 3, 2025
  17. Patrick SteinhardtJan 3, 2025
  18. 00/12 meson: wire up missing HTML documentationPatrick Steinhardt, Dec 27, 2024
  19. 01/12 meson: wire up support for AsciiDoctorPatrick Steinhardt, Dec 27, 2024
  20. 02/12 meson: properly wire up dependencies for our docsPatrick Steinhardt, Dec 27, 2024
  21. 03/12 meson: fix generation of merge toolsPatrick Steinhardt, Dec 27, 2024
  22. 04/12 meson: generate HTML pages for all man page categoriesPatrick Steinhardt, Dec 27, 2024
  23. 05/12 Documentation: inline user-manual.confPatrick Steinhardt, Dec 27, 2024
  24. 06/12 meson: generate user manualPatrick Steinhardt, Dec 27, 2024
  25. 07/12 Documentation: refactor "api-index.sh" for out-of-tree buildsPatrick Steinhardt, Dec 27, 2024
  26. 08/12 Documentation: refactor "howto-index.sh" for out-of-tree buildsPatrick Steinhardt, Dec 27, 2024
  27. 09/12 meson: generate articlesPatrick Steinhardt, Dec 27, 2024
  28. 10/12 meson: install static files for HTML documentationPatrick Steinhardt, Dec 27, 2024
  29. 11/12 t/Makefile: make "check-meson" work with DashPatrick Steinhardt, Dec 27, 2024
  30. Jonathan NiederJan 2, 2025
  31. Junio C HamanoJan 2, 2025
  32. Junio C HamanoJan 3, 2025
  33. 12/12 Documentation: wire up sanity checks for MesonPatrick Steinhardt, Dec 27, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.