]> xenbits.xensource.com Git - libvirt.git/commitdiff
docs: Format bit shift and hex notation for bitwise flag enums
authorPeter Krempa <pkrempa@redhat.com>
Thu, 24 Jan 2019 11:23:15 +0000 (12:23 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 31 Jan 2019 11:02:35 +0000 (12:02 +0100)
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 (0x8000; 1 << 15)  : Setting the VIR_MIGRATE_POSTCOPY...
VIR_MIGRATE_TLS      = 65536 (0x10000; 1 << 16) : Setting the VIR_MIGRATE_TLS flag...

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
docs/apibuild.py
docs/libvirt.css
docs/newapi.xsl

index 3ef5d0f554e8831a02f52f0a4751271a6d6e8f2f..9e0487122053572817f221ec0641ad3dbc2b68f6 100755 (executable)
@@ -2117,12 +2117,22 @@ class docBuilder:
                      self.modulename_file(id.header)))
         if id.info is not None:
             info = id.info
+            valhex = ""
             if info[0] is not None and info[0] != '':
                 try:
                     val = eval(info[0])
+                    valhex = hex(val)
                 except:
                     val = info[0]
                 output.write(" value='%s'" % (val))
+
+                if valhex != "":
+                    output.write(" value_hex='%s'" % (valhex))
+
+                m = re.match("\(?1<<(\d+)\)?", info[0])
+                if m:
+                    output.write(" value_bitshift='%s'" % (m.group(1)))
+
             if info[2] is not None and info[2] != '':
                 output.write(" type='%s'" % info[2])
             if info[1] is not None and info[1] != '':
index e590b33cfb9ab1264e0ec654e12bb4e92bad1456..c5fe27fa3f118321cbc341b20bb09559a5657ea1 100644 (file)
@@ -537,3 +537,7 @@ dl.mail dt a:hover {
     color:  rgb(255, 230, 0);
     text-decoration: none;
 }
+
+td.enumvalue {
+    white-space: nowrap;
+}
index 8d4c032c03d96d8095def1b7247ec4c775d40c66..c808fe5ff8384c16ca73e396abb3c2489afb45ba 100644 (file)
     </xsl:choose>
   </xsl:template>
 
+  <xsl:template name="enumvalue">
+    <xsl:param name="value" select="@value"/>
+    <xsl:param name="valuehex" select="@value_hex"/>
+    <xsl:param name="valuebitshift" select="@value_bitshift"/>
+    <xsl:value-of select="@value"/>
+    <xsl:if test="$valuehex != '' or $valuebitshift != ''">
+      <xsl:text> (</xsl:text>
+      <xsl:if test="$valuehex != ''">
+        <xsl:value-of select="@value_hex"/>
+      </xsl:if>
+      <xsl:if test="$valuebitshift != ''">
+        <xsl:text>; 1 &lt;&lt; </xsl:text>
+        <xsl:value-of select="@value_bitshift"/>
+      </xsl:if>
+      <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>
             <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">
                 </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>