mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 04:02:05 +00:00
doc: fix views and applicable VMs label handling in config option doc
Custom attributes in the XML schema, such as `applicable-vms` and `views`, are designed to recursively inherit those of the parent. Thus, the effective attribute of an element should be derived by its lowest ancestor that has that attribute explicitly defined. Looking up only one level would not be sufficient. This patch updates the `configdoc.xsl` to derive the effective attributes properly so that icons in the generated doc properly reflects what is specified in the schema. Addresses ACRN-7347 Signed-off-by: Junjie Mao <junjie.mao@intel.com> Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
This commit is contained in:
parent
991f55598b
commit
893fbfec78
@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:acrn="https://projectacrn.org" version="1.0">
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
|
xmlns:acrn="https://projectacrn.org"
|
||||||
|
xmlns:func="http://exslt.org/functions"
|
||||||
|
extension-element-prefixes="func"
|
||||||
|
version="1.0">
|
||||||
<xsl:output method="text"/>
|
<xsl:output method="text"/>
|
||||||
<xsl:variable name="newline" select="' '"/>
|
<xsl:variable name="newline" select="' '"/>
|
||||||
<xsl:variable name="section_adornment" select="'#*=-%+@`'"/>
|
<xsl:variable name="section_adornment" select="'#*=-%+@`'"/>
|
||||||
@ -13,7 +18,6 @@
|
|||||||
<xsl:apply-templates select="xs:complexType[@name='ACRNConfigType']">
|
<xsl:apply-templates select="xs:complexType[@name='ACRNConfigType']">
|
||||||
<xsl:with-param name="level" select="2"/>
|
<xsl:with-param name="level" select="2"/>
|
||||||
<xsl:with-param name="prefix" select="''"/>
|
<xsl:with-param name="prefix" select="''"/>
|
||||||
<xsl:with-param name="parent" select="."/>
|
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
<!-- Walk through all the ACRNConfigType element's children -->
|
<!-- Walk through all the ACRNConfigType element's children -->
|
||||||
@ -23,24 +27,21 @@
|
|||||||
<xsl:apply-templates select="descendant::xs:element">
|
<xsl:apply-templates select="descendant::xs:element">
|
||||||
<xsl:with-param name="level" select="$level"/>
|
<xsl:with-param name="level" select="$level"/>
|
||||||
<xsl:with-param name="prefix" select="$prefix"/>
|
<xsl:with-param name="prefix" select="$prefix"/>
|
||||||
<xsl:with-param name="parent" select="."/>
|
<xsl:with-param name="views-of-parent" select="'basic, advanced'"/>
|
||||||
|
<xsl:with-param name="applicable-vms-of-parent" select="''"/>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
<!-- ... and process all the child elements -->
|
<!-- ... and process all the child elements -->
|
||||||
<xsl:template match="xs:element">
|
<xsl:template match="xs:element">
|
||||||
<xsl:param name="level"/>
|
<xsl:param name="level"/>
|
||||||
<xsl:param name="prefix"/>
|
<xsl:param name="prefix"/>
|
||||||
<xsl:param name="parent"/>
|
<xsl:param name="views-of-parent"/>
|
||||||
<xsl:variable name="ty">
|
<xsl:param name="applicable-vms-of-parent"/>
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="@type">
|
<xsl:variable name="views" select="acrn:conditional(count(xs:annotation/@acrn:views) = 1, xs:annotation/@acrn:views, $views-of-parent)"/>
|
||||||
<xsl:value-of select="@type"/>
|
<xsl:variable name="applicable-vms" select="acrn:conditional(count(xs:annotation/@acrn:applicable-vms) = 1, xs:annotation/@acrn:applicable-vms, $applicable-vms-of-parent)"/>
|
||||||
</xsl:when>
|
<xsl:variable name="ty" select="acrn:conditional(count(@type) = 1, @type, .//xs:alternative[1]/@type)"/>
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:value-of select=".//xs:alternative[1]/@type"/>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:variable>
|
|
||||||
<!-- dxnamePure and dxname hold the element name with and without spaces converted to underscores -->
|
<!-- dxnamePure and dxname hold the element name with and without spaces converted to underscores -->
|
||||||
<xsl:variable name="dxnamePure">
|
<xsl:variable name="dxnamePure">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
@ -58,9 +59,8 @@
|
|||||||
<!-- Only visit elements having complex types. Those having simple types are
|
<!-- Only visit elements having complex types. Those having simple types are
|
||||||
described as an option -->
|
described as an option -->
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<!-- don't document elements if not viewable -->
|
<!-- don't document elements if not viewable -->
|
||||||
<xsl:when test="xs:annotation/@acrn:views='' and $showHidden='n'">
|
<xsl:when test="$views='' and $showHidden='n'"/>
|
||||||
</xsl:when>
|
|
||||||
<xsl:when test="//xs:complexType[@name=$ty]">
|
<xsl:when test="//xs:complexType[@name=$ty]">
|
||||||
<!-- The section header -->
|
<!-- The section header -->
|
||||||
<xsl:if test="$level <= 4">
|
<xsl:if test="$level <= 4">
|
||||||
@ -84,8 +84,9 @@
|
|||||||
<xsl:apply-templates select="//xs:complexType[@name=$ty]">
|
<xsl:apply-templates select="//xs:complexType[@name=$ty]">
|
||||||
<xsl:with-param name="level" select="$level"/>
|
<xsl:with-param name="level" select="$level"/>
|
||||||
<xsl:with-param name="name" select="concat($prefix, $dxname)"/>
|
<xsl:with-param name="name" select="concat($prefix, $dxname)"/>
|
||||||
<xsl:with-param name="parent" select="."/>
|
<xsl:with-param name="views-of-parent" select="$views"/>
|
||||||
</xsl:apply-templates>
|
<xsl:with-param name="applicable-vms-of-parent" select="$applicable-vms"/>
|
||||||
|
</xsl:apply-templates>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:if test="$level = 3">
|
<xsl:if test="$level = 3">
|
||||||
@ -112,56 +113,27 @@
|
|||||||
<xsl:text>|icon-hypervisor| </xsl:text>
|
<xsl:text>|icon-hypervisor| </xsl:text>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:choose>
|
<xsl:if test="$applicable-vms = '' or contains($applicable-vms, 'pre-launched')">
|
||||||
<xsl:when test="count((ancestor-or-self::node()|$parent)[xs:annotation[@acrn:applicable-vms]])=0">
|
<xsl:text>|icon-pre-launched-vm| </xsl:text>
|
||||||
<xsl:text>|icon-pre-launched-vm| |icon-post-launched-vm| |icon-service-vm| </xsl:text>
|
</xsl:if>
|
||||||
</xsl:when>
|
<xsl:if test="$applicable-vms = '' or contains($applicable-vms, 'post-launched')">
|
||||||
<xsl:otherwise>
|
<xsl:text>|icon-post-launched-vm| </xsl:text>
|
||||||
<xsl:if test="count((ancestor-or-self::node()|$parent)[xs:annotation[contains(@acrn:applicable-vms,'pre-launched')]][1])!=0">
|
</xsl:if>
|
||||||
<xsl:text>|icon-pre-launched-vm| </xsl:text>
|
<xsl:if test="$applicable-vms = '' or contains($applicable-vms, 'service-vm')">
|
||||||
</xsl:if>
|
<xsl:text>|icon-service-vm| </xsl:text>
|
||||||
<xsl:if test="count((ancestor-or-self::node()|$parent)[xs:annotation[contains(@acrn:applicable-vms,'post-launched')]][1])!=0">
|
</xsl:if>
|
||||||
<xsl:text>|icon-post-launched-vm| </xsl:text>
|
|
||||||
</xsl:if>
|
|
||||||
<xsl:if test="count((ancestor-or-self::node()|$parent)[xs:annotation[contains(@acrn:applicable-vms,'service-vm')]][1])!=0">
|
|
||||||
<xsl:text>|icon-service-vm| </xsl:text>
|
|
||||||
</xsl:if>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
<xsl:text>/ </xsl:text>
|
<xsl:text>/ </xsl:text>
|
||||||
<xsl:choose>
|
<xsl:if test="contains($views, 'basic')">
|
||||||
<xsl:when test="count((ancestor-or-self::node()|$parent)[xs:annotation[@acrn:views]])=0">
|
<xsl:text>|icon-basic| </xsl:text>
|
||||||
<xsl:text>|icon-basic| |icon-advanced|</xsl:text>
|
</xsl:if>
|
||||||
</xsl:when>
|
<xsl:if test="contains($views, 'advanced')">
|
||||||
<xsl:when test="xs:annotation/@acrn:views=''">
|
<xsl:text>|icon-advanced| </xsl:text>
|
||||||
<xsl:text>|icon-not-available| </xsl:text>
|
</xsl:if>
|
||||||
</xsl:when>
|
<xsl:if test="$views = ''">
|
||||||
<xsl:when test="$parent/xs:annotation/@acrn:views=''">
|
<xsl:text>|icon-not-availble| </xsl:text>
|
||||||
<xsl:text>|icon-not-available| </xsl:text>
|
</xsl:if>
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="count(ancestor-or-self::node()[xs:annotation[@acrn:views]])!=0">
|
|
||||||
<xsl:if test="count((ancestor-or-self::node())[xs:annotation[contains(@acrn:views,'basic')]][1])!=0">
|
|
||||||
<xsl:text>|icon-basic| </xsl:text>
|
|
||||||
</xsl:if>
|
|
||||||
<xsl:if test="count((ancestor-or-self::node())[xs:annotation[contains(@acrn:views,'advanced')]][1])!=0">
|
|
||||||
<xsl:text>|icon-advanced| </xsl:text>
|
|
||||||
</xsl:if>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:if test="count(($parent)[xs:annotation[contains(@acrn:views,'basic')]][1])!=0">
|
|
||||||
<xsl:text>|icon-basic| </xsl:text>
|
|
||||||
</xsl:if>
|
|
||||||
<xsl:if test="count(($parent)[xs:annotation[contains(@acrn:views,'advanced')]][1])!=0">
|
|
||||||
<xsl:text>|icon-advanced| </xsl:text>
|
|
||||||
</xsl:if>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
<xsl:if test="$option-icons!=''">
|
<xsl:if test="$option-icons!=''">
|
||||||
<xsl:value-of select="concat(' ',$option-icons,$newline)"/>
|
<xsl:value-of select="concat(' ',$option-icons,$newline)"/>
|
||||||
@ -177,7 +149,6 @@
|
|||||||
<xsl:apply-templates select="//xs:simpleType[@name=$ty]">
|
<xsl:apply-templates select="//xs:simpleType[@name=$ty]">
|
||||||
<xsl:with-param name="level" select="$level"/>
|
<xsl:with-param name="level" select="$level"/>
|
||||||
<xsl:with-param name="prefix" select="''"/>
|
<xsl:with-param name="prefix" select="''"/>
|
||||||
<xsl:with-param name="parent" select="$parent"/>
|
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="starts-with($ty, 'xs:')">
|
<xsl:when test="starts-with($ty, 'xs:')">
|
||||||
@ -191,7 +162,6 @@
|
|||||||
<xsl:apply-templates select="descendant::xs:simpleType">
|
<xsl:apply-templates select="descendant::xs:simpleType">
|
||||||
<xsl:with-param name="level" select="$level"/>
|
<xsl:with-param name="level" select="$level"/>
|
||||||
<xsl:with-param name="prefix" select="''"/>
|
<xsl:with-param name="prefix" select="''"/>
|
||||||
<xsl:with-param name="parent" select="$parent"/>
|
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
@ -207,7 +177,9 @@
|
|||||||
<xsl:template match="xs:complexType">
|
<xsl:template match="xs:complexType">
|
||||||
<xsl:param name="level"/>
|
<xsl:param name="level"/>
|
||||||
<xsl:param name="name"/>
|
<xsl:param name="name"/>
|
||||||
<xsl:param name="parent"/>
|
<xsl:param name="views-of-parent"/>
|
||||||
|
<xsl:param name="applicable-vms-of-parent"/>
|
||||||
|
|
||||||
<!-- Visit the sub-menus -->
|
<!-- Visit the sub-menus -->
|
||||||
<xsl:variable name="newLevel">
|
<xsl:variable name="newLevel">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
@ -220,7 +192,8 @@
|
|||||||
<xsl:apply-templates select="descendant::xs:element">
|
<xsl:apply-templates select="descendant::xs:element">
|
||||||
<xsl:with-param name="level" select="$newLevel"/>
|
<xsl:with-param name="level" select="$newLevel"/>
|
||||||
<xsl:with-param name="prefix" select="concat($name, '.')"/>
|
<xsl:with-param name="prefix" select="concat($name, '.')"/>
|
||||||
<xsl:with-param name="parent" select="$parent"/>
|
<xsl:with-param name="views-of-parent" select="$views-of-parent"/>
|
||||||
|
<xsl:with-param name="applicable-vms-of-parent" select="$applicable-vms-of-parent"/>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
<xsl:template match="xs:simpleType">
|
<xsl:template match="xs:simpleType">
|
||||||
@ -400,4 +373,17 @@
|
|||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
<func:function name="acrn:conditional">
|
||||||
|
<xsl:param name="cond"/>
|
||||||
|
<xsl:param name="a"/>
|
||||||
|
<xsl:param name="b"/>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$cond">
|
||||||
|
<func:result select="$a"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<func:result select="$b"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</func:function>
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
|
Loading…
Reference in New Issue
Block a user