build: Fix manpage generation at dist time

The AsciiDoc API only exposes the capabilities of asciidoc, but not
the related a2x tool. Fix generating the manpages by shelling out
to the command line tool instead.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4320

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1859>
This commit is contained in:
Florian Müllner 2021-05-25 16:31:29 +02:00 committed by Marge Bot
parent f8cd01c6dc
commit 55fcb3aa00

View File

@ -2,7 +2,7 @@
import os import os
from pathlib import PurePath from pathlib import PurePath
from asciidocapi import AsciiDocAPI import subprocess
man_pages = [ man_pages = [
'man/gnome-shell.1', 'man/gnome-shell.1',
@ -12,13 +12,12 @@ man_pages = [
sourceroot = os.environ.get('MESON_SOURCE_ROOT') sourceroot = os.environ.get('MESON_SOURCE_ROOT')
distroot = os.environ.get('MESON_DIST_ROOT') distroot = os.environ.get('MESON_DIST_ROOT')
asciidoc = AsciiDocAPI()
for man_page in man_pages: for man_page in man_pages:
page_path = PurePath(man_page) page_path = PurePath(man_page)
src = PurePath(sourceroot, page_path.with_suffix('.txt')) src = PurePath(sourceroot, page_path.with_suffix('.txt'))
dst = PurePath(distroot, page_path) dst = PurePath(distroot, page_path)
stylesheet = src.with_name('stylesheet.xsl') stylesheet = src.with_name('stylesheet.xsl')
asciidoc.options('--xsl-file', os.fspath(stylesheet)) subprocess.call(['a2x', '--xsl-file', os.fspath(stylesheet),
asciidoc.execute(os.fspath(src), outfile=os.fspath(dst)) '--format', 'manpage', '--destination-dir', os.fspath(dst.parent),
os.fspath(src)])