[PATCH 1/2] docs: break longer text into paragraphs in HTML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Claudio Bley <cbley@xxxxxxxxxx>
---
 docs/newapi.xsl |   50 +++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 41 insertions(+), 9 deletions(-)

diff --git a/docs/newapi.xsl b/docs/newapi.xsl
index 6e1c646..24831ee 100644
--- a/docs/newapi.xsl
+++ b/docs/newapi.xsl
@@ -83,6 +83,38 @@
     </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>
@@ -254,11 +286,11 @@
     <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>
 
@@ -393,11 +425,11 @@
     <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">
@@ -470,11 +502,11 @@
     <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>
-- 
1.7.9.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]