Meson unfortunately doesn't give us any means to share the code using
xsltproc to output HTMLs processed by our template. This means we will
have to resort to copy&paste engineering.
To make things simpler, let's use the same block of code in
docs/meson.build but also any of the subdirs which generate htmls.
This will be achieved by making it configurable and wrapping it in a
comment that instructs anybody editing it to keep it identical.
We need to be able to configure the template file used and installation
directory. The rest of the processing is same as we do in
docs/meson.build.
This code will then be copied to subdirs to refactor the current
approach used there.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
docs/meson.build | 60 +++++++++++++++++++++++++++++-------------------
1 file changed, 36 insertions(+), 24 deletions(-)
diff --git a/docs/meson.build b/docs/meson.build
index 8b7c63bc6f..a915d6252a 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -193,35 +193,37 @@ docs_rst2html_gen = generator(
)
-# docs_html_in_gen:
+# html_xslt_gen config
+
+html_xslt_gen_xslt = site_xsl
+html_xslt_gen_install_dir = docs_html_dir
+
+html_xslt_gen = []
+# html_xslt_gen:
# each entry is a dictionary with following items:
-# name - base file name (required)
-# file - generated file (required)
+# name - base file name (required), output file will become 'name.html'
+# file - input file (optional, 'name.html.in' assumed if missing)
# source - source filename relative to repository root (optional, if there is no source)
# depends - explicit dependency on other input (optional)
-docs_html_in_gen = []
foreach name : docs_html_in_files
- html_in_file = '@0@.html.in'.format(name)
- docs_html_in_gen += {
+ html_xslt_gen += {
'name': name,
- 'file': html_in_file,
- 'source': 'docs' / html_in_file,
+ 'source': 'docs' / name + '.html.in',
}
endforeach
foreach name : docs_rst_files
rst_file = '@0@.rst'.format(name)
- docs_html_in_gen += {
+ html_xslt_gen += {
'name': name,
'file': docs_rst2html_gen.process(rst_file),
'source': 'docs' / rst_file,
}
endforeach
-docs_html_in_gen += {
- 'name': 'acl.html',
- 'file': 'acl.html.in',
+html_xslt_gen += {
+ 'name': 'acl',
'source': 'docs' / 'acl.html.in',
'depends': aclperms_gen,
}
@@ -247,45 +249,55 @@ hvsupport_html_in = custom_target(
docs_api_generated,
],
)
-docs_html_in_gen += {
+html_xslt_gen += {
'name': 'hvsupport',
'file': hvsupport_html_in,
}
news_html_in = docs_rst2html_gen.process(meson.source_root() / 'NEWS.rst')
-docs_html_in_gen += {
+html_xslt_gen += {
'name': 'news',
'file': news_html_in,
'source': 'NEWS.rst',
}
-foreach data : docs_html_in_gen
- html_file = '@0@.html'.format(data['name'])
+# The following code between the markers must be kept identical with the other
+# copies of the code in various subdirs, since meson doesn't support any kind
+# of functions.
+
+# --- begin of XSLT processing ---
- out_file = custom_target(
- html_file,
- input: data['file'],
- output: html_file,
+foreach data : html_xslt_gen
+ html_filename = data['name'] + '.html'
+
+ html_file = custom_target(
+ html_filename,
+ input: data.get('file', data['name'] + '.html.in'),
+ output: html_filename,
command: [
xsltproc_prog,
'--stringparam', 'pagesrc', data.get('source',
''),
'--stringparam', 'builddir', meson.build_root(),
'--stringparam', 'timestamp', docs_timestamp,
'--nonet',
- site_xsl,
+ html_xslt_gen_xslt,
'@INPUT@',
],
depends: data.get('depends', []),
depend_files: [ page_xsl ],
capture: true,
install: true,
- install_dir: docs_html_dir,
+ install_dir: html_xslt_gen_install_dir,
)
- install_web_deps += out_file
- install_web_files += '@0@:@1@'.format(out_file.full_path(), docs_html_dir)
+ install_web_deps += html_file
+ install_web_files += html_file.full_path() + ':' + html_xslt_gen_install_dir
endforeach
+html_xslt_gen = []
+
+# --- end of XSLT processing ---
+
subdir('fonts')
subdir('html')
subdir('internals')
--
2.26.2