]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
docs: break longer text into paragraphs in HTML
authorClaudio Bley <cbley@av-test.de>
Tue, 8 Jan 2013 13:55:12 +0000 (14:55 +0100)
committerClaudio Bley <cbley@av-test.de>
Wed, 9 Jan 2013 07:01:28 +0000 (08:01 +0100)
Libvirt's HTML documentation is not as easy to the eyes as it could
be since long text has no visual breaks.

Take advantage of the formatting in documentation comments and wrap
each part separated by two consecutive \n into a HTML <p> element.

docs/newapi.xsl

index 6e1c646703a805923ec6fde9433c939b79d5ab5f..24831eeb1ee5b01e371b1d811062ec6a24b4f853 100644 (file)
     </xsl:for-each>
   </xsl:template>
 
+  <xsl:template name="formattext">
+    <xsl:param name="text" />
+
+    <xsl:if test="$text">
+      <xsl:variable name="head" select="substring-before($text, '&#xA;&#xA;')"/>
+      <xsl:variable name="rest" select="substring-after($text, '&#xA;&#xA;')"/>
+
+      <xsl:choose>
+        <xsl:when test="$head">
+          <p>
+            <xsl:call-template name="dumptext">
+              <xsl:with-param name="text" select="$head"/>
+            </xsl:call-template>
+          </p>
+        </xsl:when>
+        <xsl:when test="not($rest)">
+          <p>
+            <xsl:call-template name="dumptext">
+              <xsl:with-param name="text" select="$text"/>
+            </xsl:call-template>
+          </p>
+        </xsl:when>
+      </xsl:choose>
+
+      <xsl:if test="$rest">
+        <xsl:call-template name="formattext">
+          <xsl:with-param name="text" select="$rest"/>
+        </xsl:call-template>
+      </xsl:if>
+    </xsl:if>
+  </xsl:template>
+
   <xsl:template match="macro" mode="toc">
     <xsl:text>#define </xsl:text>
     <a href="#{@name}"><xsl:value-of select="@name"/></a>
     <xsl:variable name="name" select="string(@name)"/>
     <h3><a name="{$name}"><code><xsl:value-of select="$name"/></code></a></h3>
     <pre><xsl:text>#define </xsl:text><xsl:value-of select="$name"/></pre>
-    <p>
-    <xsl:call-template name="dumptext">
+    <div>
+    <xsl:call-template name="formattext">
       <xsl:with-param name="text" select="info"/>
     </xsl:call-template>
-    </p><xsl:text>
+    </div><xsl:text>
 </xsl:text>
   </xsl:template>
 
     <xsl:text>)
 </xsl:text>
     </pre>
-    <p>
-    <xsl:call-template name="dumptext">
+    <div>
+    <xsl:call-template name="formattext">
       <xsl:with-param name="text" select="info"/>
     </xsl:call-template>
-    </p>
+    </div>
     <xsl:if test="arg | return">
       <div class="variablelist"><table border="0"><col align="left"/><tbody>
       <xsl:for-each select="arg">
     <xsl:text>
 </xsl:text>
     </pre>
-    <p>
-    <xsl:call-template name="dumptext">
+    <div>
+    <xsl:call-template name="formattext">
       <xsl:with-param name="text" select="info"/>
     </xsl:call-template>
-    </p><xsl:text>
+    </div><xsl:text>
 </xsl:text>
     <xsl:if test="arg | return/@info">
       <div class="variablelist"><table border="0"><col align="left"/><tbody>