[libvirt] [PATCH] docs: Format bit shift notation for bitwise flag enums

Peter Krempa pkrempa at redhat.com
Thu Jan 24 14:43:15 UTC 2019


Big number itself does not make much sense in some cases. Format the
bitshift format as well.

Changes our web page docs from:

VIR_MIGRATE_POSTCOPY = 32768 : Setting the VIR_MIGRATE_POSTCOPY...
VIR_MIGRATE_TLS      = 65536 : Setting the VIR_MIGRATE_TLS flag...

to:

VIR_MIGRATE_POSTCOPY = 32768 (1<<15) : Setting the VIR_MIGRATE_POSTCOPY...
VIR_MIGRATE_TLS      = 65536 (1<<16) : Setting the VIR_MIGRATE_TLS flag...

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 docs/apibuild.py |  4 ++++
 docs/libvirt.css |  4 ++++
 docs/newapi.xsl  | 15 +++++++++++++--
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 3ef5d0f554..a57f995189 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -2123,6 +2123,10 @@ class docBuilder:
                 except:
                     val = info[0]
                 output.write(" value='%s'" % (val))
+                valuestr = re.sub("<", "<", info[0])
+                valuestr = re.sub("[\(\)]", "", valuestr)
+                output.write(" valuestr='%s'" % valuestr)
+
             if info[2] is not None and info[2] != '':
                 output.write(" type='%s'" % info[2])
             if info[1] is not None and info[1] != '':
diff --git a/docs/libvirt.css b/docs/libvirt.css
index e590b33cfb..c5fe27fa3f 100644
--- a/docs/libvirt.css
+++ b/docs/libvirt.css
@@ -537,3 +537,7 @@ dl.mail dt a:hover {
     color:  rgb(255, 230, 0);
     text-decoration: none;
 }
+
+td.enumvalue {
+    white-space: nowrap;
+}
diff --git a/docs/newapi.xsl b/docs/newapi.xsl
index 8d4c032c03..0a3658c9a5 100644
--- a/docs/newapi.xsl
+++ b/docs/newapi.xsl
@@ -288,6 +288,17 @@
     </xsl:choose>
   </xsl:template>

+  <xsl:template name="enumvalue">
+    <xsl:param name="value" select="@value"/>
+    <xsl:param name="valuestr" select="@valuestr"/>
+    <xsl:value-of select="@value"/>
+    <xsl:if test="$value != $valuestr">
+      <xsl:text> (</xsl:text>
+      <xsl:value-of select="@valuestr"/>
+      <xsl:text>)</xsl:text>
+    </xsl:if>
+  </xsl:template>
+
   <xsl:template match="typedef[@type = 'enum']">
     <xsl:variable name="name" select="string(@name)"/>
     <h3><a name="{$name}"><code><xsl:value-of select="$name"/></code></a></h3>
@@ -306,7 +317,7 @@
             <td><xsl:text> = </xsl:text></td>
             <xsl:choose>
               <xsl:when test="@info != ''">
-                <td><xsl:value-of select="@value"/></td>
+                <td class="enumvalue"><xsl:call-template name="enumvalue"/></td>
                 <td>
                   <div class="comment">
                     <xsl:call-template name="dumptext">
@@ -316,7 +327,7 @@
                 </td>
               </xsl:when>
               <xsl:otherwise>
-                <td colspan="2"><xsl:value-of select="@value"/></td>
+                <td colspan="2" class="enumvalue"><xsl:call-template name="enumvalue"/></td>
               </xsl:otherwise>
             </xsl:choose>
           </tr>
-- 
2.20.1




More information about the libvir-list mailing list