diff --git a/docs/Makefile.am b/docs/Makefile.am index a2fe2fbdc7..0c42db2bad 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -320,32 +320,6 @@ news.html.in: $(top_srcdir)/NEWS.rst $(AM_V_GEN)$(MKDIR_P) `dirname $@` && \ $(RST2HTML) --strict $< > $@ || { rm $@ && exit 1; } -%.html.tmp: %.html.in site.xsl subsite.xsl page.xsl \ - $(acl_generated) - $(AM_V_GEN)name=`echo $@ | sed -e 's/.tmp//'`; \ - genhtmlin=`echo $@ | sed -e 's/.tmp/.in/'`; \ - rst=`echo $@ | sed -e 's/.html.tmp/.rst/'`; \ - src="$$genhtmlin"; \ - test -f "$$genhtmlin" && src="$$rst"; \ - dir=`dirname $@` ; \ - if test "$$dir" = "."; \ - then \ - style=site.xsl; \ - else \ - $(MKDIR_P) $$dir; \ - style=subsite.xsl; \ - fi; \ - $(XSLTPROC) --stringparam pagename $$name \ - --stringparam pagesrc $$src \ - --stringparam builddir '$(abs_top_builddir)' \ - --stringparam timestamp $(timestamp) --nonet \ - $(top_srcdir)/docs/$$style $< > $@ \ - || { rm $@ && exit 1; } - -%.html: %.html.tmp - $(AM_V_GEN)$(XMLLINT) --nonet --format $< > $@ \ - || { rm $@ && exit 1; } - $(apihtml_generated): html/index.html $(apiadminhtml_generated): html/index-admin.html $(apiqemuhtml_generated): html/index-qemu.html diff --git a/scripts/meson-html-gen.py b/scripts/meson-html-gen.py new file mode 100755 index 0000000000..08041f14ec --- /dev/null +++ b/scripts/meson-html-gen.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +import argparse +import os +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, help="path to source file used for edit this page") +args = parser.parse_args() + +name = os.path.basename(args.htmlfile).replace('.html', '') + +html_tmp = subprocess.run( + [ + args.xsltproc, + '--stringparam', 'pagename', name, + '--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) diff --git a/scripts/meson.build b/scripts/meson.build index d1d069847d..74662db4b0 100644 --- a/scripts/meson.build +++ b/scripts/meson.build @@ -20,6 +20,7 @@ scripts = [ 'hyperv_wmi_generator.py', 'meson-gen-def.py', 'meson-gen-sym.py', + 'meson-html-gen.py', 'meson-install-dirs.py', 'meson-install-symlink.py', 'meson-python.sh',