libvirt/scripts/meson-html-gen.py
Daniel P. Berrangé 08376431b4 docs: fix libvirt go-import metadata in pages and links in 404 page
The meson conversion lost the <meta> tags providing the go-import,
because the "$pagename" variable lost the .html suffix. Rather
than fix that, just change to using "$pagesrc" instead, as it is a
better fit.

The 404 page also needs to use absolute links to work correctly for
pages in sub-folders.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-08-04 17:06:33 +01:00

38 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("xsltproc", type=str, help="path to xsltproc bin")
parser.add_argument("xmllint", type=str, help="path to xmllint bin")
parser.add_argument("builddir", type=str, help="build root dir path")
parser.add_argument("timestamp", type=str, help="docs timestamp")
parser.add_argument("style", type=str, help="XSL stile file")
parser.add_argument("infile", type=str, help="path to source HTML file")
parser.add_argument("htmlfile", type=str, help="path to generated HTML file")
parser.add_argument("pagesrc", type=str, default="", nargs='?', help="(optional) path to source file used for edit this page")
args = parser.parse_args()
html_tmp = subprocess.run(
[
args.xsltproc,
'--stringparam', 'pagesrc', args.pagesrc,
'--stringparam', 'builddir', args.builddir,
'--stringparam', 'timestamp', args.timestamp,
'--nonet', args.style, args.infile,
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
html = subprocess.run(
[args.xmllint, '--nonet', '--format', '-'],
input=html_tmp.stdout,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
with open(args.htmlfile, 'wb') as outfile:
outfile.write(html.stdout)