On Tue, Jul 28, 2020 at 03:18:23PM +0200, Peter Krempa wrote:
On Thu, Jul 16, 2020 at 11:59:17 +0200, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
> ---
> docs/Makefile.am | 26 ---------------------
> scripts/meson-html-gen.py | 49 +++++++++++++++++++++++++++++++++++++++
> scripts/meson.build | 1 +
> 3 files changed, 50 insertions(+), 26 deletions(-)
> create mode 100755 scripts/meson-html-gen.py
>
> diff --git a/docs/Makefile.am b/docs/Makefile.am
> index a2fe2fbdc75..0c42db2badb 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 00000000000..9ac649a9ef7
> --- /dev/null
> +++ b/scripts/meson-html-gen.py
> @@ -0,0 +1,49 @@
> +#!/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")
> +args = parser.parse_args()
> +
> +name = os.path.basename(args.htmlfile).replace('.html', '')
> +
> +pagesrc = args.infile
> +rstfile = pagesrc.replace('.html.in', '.rst')
> +if os.path.exists(rstfile):
> + pagesrc = rstfile
> +
> +with open(args.infile, 'rb') as infile:
> + html_in_data = infile.read()
> +
> +html_tmp = subprocess.run(
> + [
> + args.xsltproc,
> + '--stringparam', 'pagename', name,
> + '--stringparam', 'pagesrc', pagesrc,
> + '--stringparam', 'builddir', args.builddir,
> + '--stringparam', 'timestamp', args.timestamp,
> + '--nonet', args.style, '-',
> + ],
> + input=html_in_data,
> + stdout=subprocess.PIPE,
> + stderr=subprocess.PIPE,
xsltproc can take an input file as argument so if all of this is just
for feeding it the input, it's not necessary to do it so.
Nice catch, leftover from one of the previous versions where I was
modifying the infile data directly in python, hence the open() call
and passing it to stdin. I'll remove it.
> +)
> +
> +html = subprocess.run(
> + [args.xmllint, '--nonet', '--format', '-'],
> + input=html_tmp.stdout,
> + stdout=subprocess.PIPE,
> + stderr=subprocess.PIPE,
We can then do this as separate stage.
What do you mean by separate stage? Not following here.
Pavel