[PATCH 02/11] docs: Simplify passing of 'href_base' XSL variable

Peter Krempa pkrempa at redhat.com
Thu Apr 7 14:00:24 UTC 2022


Historically we had two top level XSL files for top level and nested
documents which only differ in what they pass for 'href_base' to the
main 'page.xsl' file.

We can instead pass the variable as argument from the build system so
that we have just one XSL file and also allow for more nested document
trees in the future.

The '404' page is special even with the current XSL way so we add a
special case for it.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 docs/go/meson.build        |  5 +++--
 docs/internals/meson.build |  5 +++--
 docs/kbase/meson.build     |  5 +++--
 docs/manpages/meson.build  |  5 +++--
 docs/meson.build           | 12 ++++++++----
 docs/site.xsl              | 12 +-----------
 docs/subsite.xsl           | 24 ------------------------
 7 files changed, 21 insertions(+), 47 deletions(-)
 delete mode 100644 docs/subsite.xsl

diff --git a/docs/go/meson.build b/docs/go/meson.build
index 0ae0216ce3..c0e19c4182 100644
--- a/docs/go/meson.build
+++ b/docs/go/meson.build
@@ -3,7 +3,6 @@ docs_go_files = [
   'libvirtxml',
 ]

-html_xslt_gen_xslt = subsite_xsl
 html_xslt_gen_install_dir = docs_html_dir / 'go'
 html_xslt_gen = []

@@ -14,6 +13,7 @@ foreach name : docs_go_files
     'name': name,
     'file': docs_rst2html5_gen.process(rst_file),
     'source': 'docs' / 'go' / rst_file,
+    'href_base': '../',
   }
 endforeach

@@ -33,8 +33,9 @@ foreach data : html_xslt_gen
       '--stringparam', 'pagesrc', data.get('source', ''),
       '--stringparam', 'builddir', meson.build_root(),
       '--stringparam', 'timestamp', docs_timestamp,
+      '--stringparam', 'href_base', data.get('href_base', ''),
       '--nonet',
-      html_xslt_gen_xslt,
+      site_xsl,
       '@INPUT@',
     ],
     depends: data.get('depends', []),
diff --git a/docs/internals/meson.build b/docs/internals/meson.build
index 2d0ae6195c..298a55dd88 100644
--- a/docs/internals/meson.build
+++ b/docs/internals/meson.build
@@ -5,7 +5,6 @@ internals_in_files = [
   'rpc',
 ]

-html_xslt_gen_xslt = subsite_xsl
 html_xslt_gen_install_dir = docs_html_dir / 'internals'
 html_xslt_gen = []

@@ -13,6 +12,7 @@ foreach name : internals_in_files
   html_xslt_gen += {
     'name': name,
     'source': 'docs' / 'internals' / name + '.html.in',
+    'href_base': '../'
   }
 endforeach

@@ -32,8 +32,9 @@ foreach data : html_xslt_gen
       '--stringparam', 'pagesrc', data.get('source', ''),
       '--stringparam', 'builddir', meson.build_root(),
       '--stringparam', 'timestamp', docs_timestamp,
+      '--stringparam', 'href_base', data.get('href_base', ''),
       '--nonet',
-      html_xslt_gen_xslt,
+      site_xsl,
       '@INPUT@',
     ],
     depends: data.get('depends', []),
diff --git a/docs/kbase/meson.build b/docs/kbase/meson.build
index 4114fc81d1..e37feb6d30 100644
--- a/docs/kbase/meson.build
+++ b/docs/kbase/meson.build
@@ -24,7 +24,6 @@ docs_kbase_files = [
   'virtiofs',
 ]

-html_xslt_gen_xslt = subsite_xsl
 html_xslt_gen_install_dir = docs_html_dir / 'kbase'
 html_xslt_gen = []

@@ -35,6 +34,7 @@ foreach name : docs_kbase_files
     'name': name,
     'file': docs_rst2html5_gen.process(rst_file),
     'source': 'docs' / 'kbase' / rst_file,
+    'href_base': '../',
   }
 endforeach

@@ -54,8 +54,9 @@ foreach data : html_xslt_gen
       '--stringparam', 'pagesrc', data.get('source', ''),
       '--stringparam', 'builddir', meson.build_root(),
       '--stringparam', 'timestamp', docs_timestamp,
+      '--stringparam', 'href_base', data.get('href_base', ''),
       '--nonet',
-      html_xslt_gen_xslt,
+      site_xsl,
       '@INPUT@',
     ],
     depends: data.get('depends', []),
diff --git a/docs/manpages/meson.build b/docs/manpages/meson.build
index d9fcb6b057..ba673cf472 100644
--- a/docs/manpages/meson.build
+++ b/docs/manpages/meson.build
@@ -1,4 +1,3 @@
-html_xslt_gen_xslt = subsite_xsl
 html_xslt_gen_install_dir = docs_html_dir / 'manpages'
 html_xslt_gen = []

@@ -130,6 +129,7 @@ foreach data : docs_man_files
     'name': data['name'],
     'file': html_in,
     'source': 'docs' / 'manpages' / rst_in_file,
+    'href_base': '../',
   }
 endforeach

@@ -149,8 +149,9 @@ foreach data : html_xslt_gen
       '--stringparam', 'pagesrc', data.get('source', ''),
       '--stringparam', 'builddir', meson.build_root(),
       '--stringparam', 'timestamp', docs_timestamp,
+      '--stringparam', 'href_base', data.get('href_base', ''),
       '--nonet',
-      html_xslt_gen_xslt,
+      site_xsl,
       '@INPUT@',
     ],
     depends: data.get('depends', []),
diff --git a/docs/meson.build b/docs/meson.build
index 2295fbf752..75b5e4c08f 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -18,7 +18,6 @@ docs_assets = [
 ]

 docs_html_in_files = [
-  '404',
   'docs',
   'formatcaps',
   'formatdomaincaps',
@@ -132,7 +131,6 @@ docs_timestamp = run_command(
 ).stdout().strip()

 site_xsl = files('site.xsl')
-subsite_xsl = files('subsite.xsl')
 page_xsl = files('page.xsl')
 newapi_xsl = files('newapi.xsl')

@@ -218,7 +216,6 @@ docs_rst2html5_gen = generator(

 # html_xslt_gen config

-html_xslt_gen_xslt = site_xsl
 html_xslt_gen_install_dir = docs_html_dir

 html_xslt_gen = []
@@ -251,6 +248,12 @@ html_xslt_gen += {
   'depends': aclperms_gen,
 }

+html_xslt_gen += {
+  'name': '404',
+  'source': 'docs' / '404.html.in',
+  'href_base': '/',
+}
+
 hvsupport_html_in = custom_target(
   'hvsupport.html.in',
   output: 'hvsupport.html.in',
@@ -302,8 +305,9 @@ foreach data : html_xslt_gen
       '--stringparam', 'pagesrc', data.get('source', ''),
       '--stringparam', 'builddir', meson.build_root(),
       '--stringparam', 'timestamp', docs_timestamp,
+      '--stringparam', 'href_base', data.get('href_base', ''),
       '--nonet',
-      html_xslt_gen_xslt,
+      site_xsl,
       '@INPUT@',
     ],
     depends: data.get('depends', []),
diff --git a/docs/site.xsl b/docs/site.xsl
index 931e26272f..f56eb67b8a 100644
--- a/docs/site.xsl
+++ b/docs/site.xsl
@@ -13,21 +13,11 @@
     encoding="UTF-8"
     indent="yes"/>

-  <xsl:variable name="href_base">
-    <xsl:choose>
-      <xsl:when test="$pagesrc = 'docs/404.html.in'">
-        <xsl:value-of select="'/'"/>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:value-of select="''"/>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:variable>
-
   <xsl:template match="/">
     <xsl:apply-templates select="." mode="page">
       <xsl:with-param name="pagesrc" select="$pagesrc"/>
       <xsl:with-param name="timestamp" select="$timestamp"/>
+      <xsl:with-param name="href_base" select="$href_base"/>
     </xsl:apply-templates>
   </xsl:template>

diff --git a/docs/subsite.xsl b/docs/subsite.xsl
deleted file mode 100644
index 2bdfcbb9b1..0000000000
--- a/docs/subsite.xsl
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0"?>
-<xsl:stylesheet
-  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-  xmlns:exsl="http://exslt.org/common"
-  exclude-result-prefixes="xsl exsl"
-  version="1.0">
-
-  <xsl:import href="page.xsl"/>
-
-  <xsl:output
-    method="xml"
-    encoding="UTF-8"
-    indent="yes"/>
-
-  <xsl:variable name="href_base" select="'../'"/>
-
-  <xsl:template match="/">
-    <xsl:apply-templates select="." mode="page">
-      <xsl:with-param name="pagesrc" select="$pagesrc"/>
-      <xsl:with-param name="timestamp" select="$timestamp"/>
-    </xsl:apply-templates>
-  </xsl:template>
-
-</xsl:stylesheet>
-- 
2.35.1



More information about the libvir-list mailing list