1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-02-01 09:47:20 +03:00

docs: Simplify passing of 'href_base' XSL variable

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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2022-04-05 16:52:57 +02:00
parent c72249674d
commit 98ffd82060
7 changed files with 21 additions and 47 deletions

View File

@ -3,7 +3,6 @@ docs_go_files = [
'libvirtxml', 'libvirtxml',
] ]
html_xslt_gen_xslt = subsite_xsl
html_xslt_gen_install_dir = docs_html_dir / 'go' html_xslt_gen_install_dir = docs_html_dir / 'go'
html_xslt_gen = [] html_xslt_gen = []
@ -14,6 +13,7 @@ foreach name : docs_go_files
'name': name, 'name': name,
'file': docs_rst2html5_gen.process(rst_file), 'file': docs_rst2html5_gen.process(rst_file),
'source': 'docs' / 'go' / rst_file, 'source': 'docs' / 'go' / rst_file,
'href_base': '../',
} }
endforeach endforeach
@ -33,8 +33,9 @@ foreach data : html_xslt_gen
'--stringparam', 'pagesrc', data.get('source', ''), '--stringparam', 'pagesrc', data.get('source', ''),
'--stringparam', 'builddir', meson.build_root(), '--stringparam', 'builddir', meson.build_root(),
'--stringparam', 'timestamp', docs_timestamp, '--stringparam', 'timestamp', docs_timestamp,
'--stringparam', 'href_base', data.get('href_base', ''),
'--nonet', '--nonet',
html_xslt_gen_xslt, site_xsl,
'@INPUT@', '@INPUT@',
], ],
depends: data.get('depends', []), depends: data.get('depends', []),

View File

@ -5,7 +5,6 @@ internals_in_files = [
'rpc', 'rpc',
] ]
html_xslt_gen_xslt = subsite_xsl
html_xslt_gen_install_dir = docs_html_dir / 'internals' html_xslt_gen_install_dir = docs_html_dir / 'internals'
html_xslt_gen = [] html_xslt_gen = []
@ -13,6 +12,7 @@ foreach name : internals_in_files
html_xslt_gen += { html_xslt_gen += {
'name': name, 'name': name,
'source': 'docs' / 'internals' / name + '.html.in', 'source': 'docs' / 'internals' / name + '.html.in',
'href_base': '../'
} }
endforeach endforeach
@ -32,8 +32,9 @@ foreach data : html_xslt_gen
'--stringparam', 'pagesrc', data.get('source', ''), '--stringparam', 'pagesrc', data.get('source', ''),
'--stringparam', 'builddir', meson.build_root(), '--stringparam', 'builddir', meson.build_root(),
'--stringparam', 'timestamp', docs_timestamp, '--stringparam', 'timestamp', docs_timestamp,
'--stringparam', 'href_base', data.get('href_base', ''),
'--nonet', '--nonet',
html_xslt_gen_xslt, site_xsl,
'@INPUT@', '@INPUT@',
], ],
depends: data.get('depends', []), depends: data.get('depends', []),

View File

@ -24,7 +24,6 @@ docs_kbase_files = [
'virtiofs', 'virtiofs',
] ]
html_xslt_gen_xslt = subsite_xsl
html_xslt_gen_install_dir = docs_html_dir / 'kbase' html_xslt_gen_install_dir = docs_html_dir / 'kbase'
html_xslt_gen = [] html_xslt_gen = []
@ -35,6 +34,7 @@ foreach name : docs_kbase_files
'name': name, 'name': name,
'file': docs_rst2html5_gen.process(rst_file), 'file': docs_rst2html5_gen.process(rst_file),
'source': 'docs' / 'kbase' / rst_file, 'source': 'docs' / 'kbase' / rst_file,
'href_base': '../',
} }
endforeach endforeach
@ -54,8 +54,9 @@ foreach data : html_xslt_gen
'--stringparam', 'pagesrc', data.get('source', ''), '--stringparam', 'pagesrc', data.get('source', ''),
'--stringparam', 'builddir', meson.build_root(), '--stringparam', 'builddir', meson.build_root(),
'--stringparam', 'timestamp', docs_timestamp, '--stringparam', 'timestamp', docs_timestamp,
'--stringparam', 'href_base', data.get('href_base', ''),
'--nonet', '--nonet',
html_xslt_gen_xslt, site_xsl,
'@INPUT@', '@INPUT@',
], ],
depends: data.get('depends', []), depends: data.get('depends', []),

View File

@ -1,4 +1,3 @@
html_xslt_gen_xslt = subsite_xsl
html_xslt_gen_install_dir = docs_html_dir / 'manpages' html_xslt_gen_install_dir = docs_html_dir / 'manpages'
html_xslt_gen = [] html_xslt_gen = []
@ -130,6 +129,7 @@ foreach data : docs_man_files
'name': data['name'], 'name': data['name'],
'file': html_in, 'file': html_in,
'source': 'docs' / 'manpages' / rst_in_file, 'source': 'docs' / 'manpages' / rst_in_file,
'href_base': '../',
} }
endforeach endforeach
@ -149,8 +149,9 @@ foreach data : html_xslt_gen
'--stringparam', 'pagesrc', data.get('source', ''), '--stringparam', 'pagesrc', data.get('source', ''),
'--stringparam', 'builddir', meson.build_root(), '--stringparam', 'builddir', meson.build_root(),
'--stringparam', 'timestamp', docs_timestamp, '--stringparam', 'timestamp', docs_timestamp,
'--stringparam', 'href_base', data.get('href_base', ''),
'--nonet', '--nonet',
html_xslt_gen_xslt, site_xsl,
'@INPUT@', '@INPUT@',
], ],
depends: data.get('depends', []), depends: data.get('depends', []),

View File

@ -18,7 +18,6 @@ docs_assets = [
] ]
docs_html_in_files = [ docs_html_in_files = [
'404',
'docs', 'docs',
'formatcaps', 'formatcaps',
'formatnetwork', 'formatnetwork',
@ -132,7 +131,6 @@ docs_timestamp = run_command(
).stdout().strip() ).stdout().strip()
site_xsl = files('site.xsl') site_xsl = files('site.xsl')
subsite_xsl = files('subsite.xsl')
page_xsl = files('page.xsl') page_xsl = files('page.xsl')
newapi_xsl = files('newapi.xsl') newapi_xsl = files('newapi.xsl')
@ -218,7 +216,6 @@ docs_rst2html5_gen = generator(
# html_xslt_gen config # html_xslt_gen config
html_xslt_gen_xslt = site_xsl
html_xslt_gen_install_dir = docs_html_dir html_xslt_gen_install_dir = docs_html_dir
html_xslt_gen = [] html_xslt_gen = []
@ -251,6 +248,12 @@ html_xslt_gen += {
'depends': aclperms_gen, 'depends': aclperms_gen,
} }
html_xslt_gen += {
'name': '404',
'source': 'docs' / '404.html.in',
'href_base': '/',
}
hvsupport_html_in = custom_target( hvsupport_html_in = custom_target(
'hvsupport.html.in', 'hvsupport.html.in',
output: 'hvsupport.html.in', output: 'hvsupport.html.in',
@ -302,8 +305,9 @@ foreach data : html_xslt_gen
'--stringparam', 'pagesrc', data.get('source', ''), '--stringparam', 'pagesrc', data.get('source', ''),
'--stringparam', 'builddir', meson.build_root(), '--stringparam', 'builddir', meson.build_root(),
'--stringparam', 'timestamp', docs_timestamp, '--stringparam', 'timestamp', docs_timestamp,
'--stringparam', 'href_base', data.get('href_base', ''),
'--nonet', '--nonet',
html_xslt_gen_xslt, site_xsl,
'@INPUT@', '@INPUT@',
], ],
depends: data.get('depends', []), depends: data.get('depends', []),

View File

@ -13,21 +13,11 @@
encoding="UTF-8" encoding="UTF-8"
indent="yes"/> 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:template match="/">
<xsl:apply-templates select="." mode="page"> <xsl:apply-templates select="." mode="page">
<xsl:with-param name="pagesrc" select="$pagesrc"/> <xsl:with-param name="pagesrc" select="$pagesrc"/>
<xsl:with-param name="timestamp" select="$timestamp"/> <xsl:with-param name="timestamp" select="$timestamp"/>
<xsl:with-param name="href_base" select="$href_base"/>
</xsl:apply-templates> </xsl:apply-templates>
</xsl:template> </xsl:template>

View File

@ -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>