From nobody Sun Feb 8 22:08:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602512948; cv=none; d=zohomail.com; s=zohoarc; b=BGZADOtMfyha5g8BrKxBeWjsgDXodr7S9PS1dXPfqgSa0ybIOD4VHwWb4hGcG4qtGbKfYhANZCasDitRvi2VSH4hz3oj3dPtVitG/SB2zkgGHVuQhvy6x/FiNM4H6w7jtDYsgz69FJ0Kva3DsNvnfO1Fz1oLVQD9xyqbiCmQMSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602512948; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dG2wtG37/QU9nQW6LIGEhSJQ2ZPv1uLNIEQJPkpaKUc=; b=S6ulP+wtgBVauu49eFUngRae5itTa98Pv5qENGq3WbMuOFOb9oUKEH7RGUDNC/HeyhbnssP1iDs3dTIo9dKrDlWIvuZAjq1j3y4z0HZXjpC5bwU7Twie9JZhPeuDD/GUgJ1ch/yUOTkchXviiKQpnWueDt4FoiZAg5f8pHDKIWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 160251294818133.06715828654421; Mon, 12 Oct 2020 07:29:08 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-252-lh0B_ZzOOsarNHMXtQCoeA-1; Mon, 12 Oct 2020 10:29:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F395802B6C; Mon, 12 Oct 2020 14:28:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 216CF76668; Mon, 12 Oct 2020 14:28:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E22609A050; Mon, 12 Oct 2020 14:28:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09CESg7t008851 for ; Mon, 12 Oct 2020 10:28:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 96E6460C13; Mon, 12 Oct 2020 14:28:42 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED3C360C0F for ; Mon, 12 Oct 2020 14:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602512947; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dG2wtG37/QU9nQW6LIGEhSJQ2ZPv1uLNIEQJPkpaKUc=; b=AGV/zdsjtTlLCNKGUt/HcK6hWW6nefIIdLdnqL2sgU/vnPPiOeQ5UdusHPAonqmMHXXALO ErPSOc1pb6n0iEn/aAtQ7NTarw1cYkXpWbrGghqzX6u9zpp5mY1+We3vUGZDnCqC0N0aXY XkaOS7DGUuAeM4tDDy2vv0xhr3iqrko= X-MC-Unique: lh0B_ZzOOsarNHMXtQCoeA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] docs: meson.build: Generate HTML files directly by meson Date: Mon, 12 Oct 2020 16:28:35 +0200 Message-Id: <22959329577cb4d2f5b2ccaf1beda26b72e8da71.1602512803.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Our HTML file generation has two steps: 1) XSL transformation This applies headers/footers and various other bits. 2) xmllint reformat To fix indentation and to look like a proper XML/XHTML. Historically these were done in a pipeline. The meson conversion attempted to do the same by adding 'scripts/meson-html-gen.py' which tried to pipeline them. Unfortunately this hid errors from 'xsltproc' as return value was not checked and the stderr was piped into xmllints stdin. The result was that any invalid input file would result into an empty output file. Since the script's only purpose was to prevent additional temporary files being created at the cost of compexity and obscurity (by hiding the commands used to process the XMLs and their arguments being weirdly passed through positional arguments) we can remove it if we accept extra temporary files in the directory. Moving the generation directly into the meson definition makes it more obvious what's happening and saves readers from having to parse what's going on. A free bonus is that errors are now properly caught and reported. Signed-off-by: Peter Krempa --- docs/meson.build | 39 +++++++++++++++++++++++++-------------- scripts/meson-html-gen.py | 37 ------------------------------------- 2 files changed, 25 insertions(+), 51 deletions(-) delete mode 100755 scripts/meson-html-gen.py diff --git a/docs/meson.build b/docs/meson.build index 400c1ca955..d1943161b8 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -253,33 +253,44 @@ docs_html_in_gen +=3D { } foreach data : docs_html_in_gen - html_file =3D '@0@.html'.format(data['name']) + xslout_filename =3D '@0@.xslout.html'.format(data['name']) + html_filename =3D '@0@.html'.format(data['name']) - out_file =3D custom_target( - html_file, + xslout_file =3D custom_target( + xslout_filename, input: data['file'], - output: html_file, + output: xslout_filename, command: [ - meson_python_prog, - python3_prog.path(), - meson_html_gen_prog.path(), xsltproc_prog.path(), - xmllint_prog.path(), - meson.build_root(), - docs_timestamp, + '--stringparam', 'pagesrc', data.get('source', ''), + '--stringparam', 'builddir', meson.build_root(), + '--stringparam', 'timestamp', docs_timestamp, + '--nonet', site_xsl, '@INPUT@', - '@OUTPUT@', - data.get('source', []), ], depends: [ aclperms_gen ], depend_files: [ page_xsl ], + capture: true, + ) + + html_file =3D custom_target( + html_filename, + input: xslout_file, + output: html_filename, + command: [ + xmllint_prog.path(), + '--nonet', + '--format', + '@INPUT@', + ], install: true, install_dir: docs_html_dir, + capture: true ) - install_web_deps +=3D out_file - install_web_files +=3D '@0@:@1@'.format(out_file.full_path(), docs_html_= dir) + install_web_deps +=3D html_file + install_web_files +=3D '@0@:@1@'.format(html_file.full_path(), docs_html= _dir) endforeach subdir('fonts') diff --git a/scripts/meson-html-gen.py b/scripts/meson-html-gen.py deleted file mode 100755 index 2731d734a7..0000000000 --- a/scripts/meson-html-gen.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import subprocess - -parser =3D argparse.ArgumentParser() -parser.add_argument("xsltproc", type=3Dstr, help=3D"path to xsltproc bin") -parser.add_argument("xmllint", type=3Dstr, help=3D"path to xmllint bin") -parser.add_argument("builddir", type=3Dstr, help=3D"build root dir path") -parser.add_argument("timestamp", type=3Dstr, help=3D"docs timestamp") -parser.add_argument("style", type=3Dstr, help=3D"XSL stile file") -parser.add_argument("infile", type=3Dstr, help=3D"path to source HTML file= ") -parser.add_argument("htmlfile", type=3Dstr, help=3D"path to generated HTML= file") -parser.add_argument("pagesrc", type=3Dstr, default=3D"", nargs=3D'?', help= =3D"(optional) path to source file used for edit this page") -args =3D parser.parse_args() - -html_tmp =3D subprocess.run( - [ - args.xsltproc, - '--stringparam', 'pagesrc', args.pagesrc, - '--stringparam', 'builddir', args.builddir, - '--stringparam', 'timestamp', args.timestamp, - '--nonet', args.style, args.infile, - ], - stdout=3Dsubprocess.PIPE, - stderr=3Dsubprocess.PIPE, -) - -html =3D subprocess.run( - [args.xmllint, '--nonet', '--format', '-'], - input=3Dhtml_tmp.stdout, - stdout=3Dsubprocess.PIPE, - stderr=3Dsubprocess.PIPE, -) - -with open(args.htmlfile, 'wb') as outfile: - outfile.write(html.stdout) --=20 2.26.2