[libvirt] [PATCH 0/2] Colorize HTML documentation

Hi. This patchset adds a few classes to the generated HTML documentation. The style sheets are also adapted making use of the new classes to give the documentation a little visual overhaul. YMMV, but it looks good for me using Firefox, Webkit and Opera. I did check the CSS rules using the W3C CSS validator. Claudio Bley (2): docs: Assign classes to documentation elements docs: Add some style and color to the HTML documentation docs/generic.css | 4 ++ docs/libvirt.css | 56 +++++++++++++++- docs/newapi.xsl | 187 +++++++++++++++++++++++++++++++----------------------- 3 files changed, 166 insertions(+), 81 deletions(-) -- 1.7.9.5

In CSS the following class names are available: * keyword (keywords like "typedef", "struct") * type (types like "int", "void*") * comment (comments after members of enums or structs) * directive (preprocessor directives, #define) * undisclosed (text saying that the API is not public) Additionally, kill all of the left-over "programlisting" class assignments. There are no CSS rules for them. Signed-off-by: Claudio Bley <cbley@av-test.de> --- docs/newapi.xsl | 187 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 108 insertions(+), 79 deletions(-) diff --git a/docs/newapi.xsl b/docs/newapi.xsl index 24831ee..3982f8f 100644 --- a/docs/newapi.xsl +++ b/docs/newapi.xsl @@ -116,16 +116,18 @@ </xsl:template> <xsl:template match="macro" mode="toc"> - <xsl:text>#define </xsl:text> + <span class="directive">#define</span><xsl:text> </xsl:text> <a href="#{@name}"><xsl:value-of select="@name"/></a> <xsl:text> </xsl:text> </xsl:template> <xsl:template match="variable" mode="toc"> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="string(@type)"/> - </xsl:call-template> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="string(@type)"/> + </xsl:call-template> + </span> <xsl:text> </xsl:text> <a name="{@name}"></a> <xsl:value-of select="@name"/> @@ -134,18 +136,21 @@ </xsl:template> <xsl:template match="typedef" mode="toc"> - <xsl:text>typedef </xsl:text><xsl:variable name="name" select="string(@name)"/> + <span class="keyword">typedef</span> + <xsl:text> </xsl:text><xsl:variable name="name" select="string(@name)"/> <xsl:choose> <xsl:when test="@type = 'enum'"> - <xsl:text>enum </xsl:text> + <span class="keyword">enum</span><xsl:text> </xsl:text> <a href="#{$name}"><xsl:value-of select="$name"/></a> <xsl:text> </xsl:text> </xsl:when> <xsl:otherwise> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@type"/> - </xsl:call-template> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@type"/> + </xsl:call-template> + </span> <xsl:text> </xsl:text> <a name="{$name}"><xsl:value-of select="$name"/></a> <xsl:text> @@ -159,7 +164,7 @@ <h3><a name="{$name}"><code><xsl:value-of select="$name"/></code></a></h3> <div class="api"> <pre> - <xsl:text>enum </xsl:text> + <span class="keyword">enum</span><xsl:text> </xsl:text> <xsl:value-of select="$name"/> <xsl:text> { </xsl:text> @@ -173,10 +178,11 @@ <td><xsl:value-of select="@value"/></td> <xsl:if test="@info != ''"> <td> - <xsl:text> : </xsl:text> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@info"/> - </xsl:call-template> + <div class="comment"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@info"/> + </xsl:call-template> + </div> </td> </xsl:if> </tr> @@ -190,8 +196,8 @@ </xsl:template> <xsl:template match="struct" mode="toc"> - <xsl:text>typedef </xsl:text> - <xsl:value-of select="@type"/> + <span class="keyword">typedef</span><xsl:text> </xsl:text> + <span class="type"><xsl:value-of select="@type"/></span> <xsl:text> </xsl:text> <a href="#{@name}"><xsl:value-of select="@name"/></a> <xsl:text> @@ -202,32 +208,35 @@ <h3><a name="{@name}"><code><xsl:value-of select="@name"/></code></a></h3> <div class="api"> <pre> - <xsl:text>struct </xsl:text> + <span class="keyword">struct </span> <xsl:value-of select="@name"/> - <xsl:text>{ + <xsl:text> { </xsl:text> </pre> <table> <xsl:for-each select="field"> <xsl:choose> <xsl:when test='@type = "union"'> - <tr><td>union {</td></tr> + <tr><td><span class="keyword">union</span> {</td></tr> <tr> <td><table> <xsl:for-each select="union/field"> <tr> <td> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@type"/> - </xsl:call-template> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@type"/> + </xsl:call-template> + </span> </td> <td><xsl:value-of select="@name"/></td> <xsl:if test="@info != ''"> <td> - <xsl:text> : </xsl:text> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@info"/> - </xsl:call-template> + <div class="comment"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@info"/> + </xsl:call-template> + </div> </td> </xsl:if> </tr> @@ -238,10 +247,11 @@ <td><xsl:value-of select="@name"/></td> <xsl:if test="@info != ''"> <td> - <xsl:text> : </xsl:text> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@info"/> - </xsl:call-template> + <div class="comment"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@info"/> + </xsl:call-template> + </div> </td> </xsl:if> <td></td></tr> @@ -249,17 +259,20 @@ <xsl:otherwise> <tr> <td> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@type"/> - </xsl:call-template> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@type"/> + </xsl:call-template> + </span> </td> <td><xsl:value-of select="@name"/></td> <xsl:if test="@info != ''"> <td> - <xsl:text> : </xsl:text> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@info"/> - </xsl:call-template> + <div class="comment"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@info"/> + </xsl:call-template> + </div> </td> </xsl:if> </tr> @@ -269,7 +282,7 @@ <xsl:if test="not(field)"> <tr> <td colspan="3"> - <xsl:text>The content of this structure is not made public by the API</xsl:text> + <span class="undisclosed">The content of this structure is not made public by the API</span> </td> </tr> </xsl:if> @@ -285,7 +298,7 @@ <xsl:template match="macro"> <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> + <pre class="api"><span class="directive">#define</span><xsl:text> </xsl:text><xsl:value-of select="$name"/></pre> <div> <xsl:call-template name="formattext"> <xsl:with-param name="text" select="info"/> @@ -299,9 +312,11 @@ <xsl:variable name="nlen" select="string-length($name)"/> <xsl:variable name="tlen" select="string-length(return/@type)"/> <xsl:variable name="blen" select="(($nlen + 8) - (($nlen + 8) mod 8)) + (($tlen + 8) - (($tlen + 8) mod 8))"/> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="return/@type"/> - </xsl:call-template> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="return/@type"/> + </xsl:call-template> + </span> <xsl:text> </xsl:text> <a href="#{@name}"><xsl:value-of select="@name"/></a> <xsl:if test="$blen - 40 < -8"> @@ -312,12 +327,14 @@ </xsl:if> <xsl:text> (</xsl:text> <xsl:if test="not(arg)"> - <xsl:text>void</xsl:text> + <span class="type">void</span> </xsl:if> <xsl:for-each select="arg"> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@type"/> - </xsl:call-template> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@type"/> + </xsl:call-template> + </span> <xsl:text> </xsl:text> <xsl:value-of select="@name"/> <xsl:if test="position() != last()"> @@ -340,13 +357,15 @@ <xsl:variable name="nlen" select="string-length($name)"/> <xsl:variable name="tlen" select="string-length(return/@type)"/> <xsl:variable name="blen" select="(($nlen + 8) - (($nlen + 8) mod 8)) + (($tlen + 8) - (($tlen + 8) mod 8))"/> - <xsl:text>typedef </xsl:text> + <span class="keyword">typedef</span><xsl:text> </xsl:text> <a href="#{$name}"><xsl:value-of select="$name"/></a> <xsl:text> </xsl:text> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="return/@type"/> - </xsl:call-template> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="return/@type"/> + </xsl:call-template> + </span> <xsl:text> </xsl:text> <a href="#{$name}"><xsl:value-of select="$name"/></a> <xsl:if test="$blen - 40 < -8"> @@ -357,12 +376,14 @@ </xsl:if> <xsl:text> (</xsl:text> <xsl:if test="not(arg)"> - <xsl:text>void</xsl:text> + <span class="type">void</span> </xsl:if> <xsl:for-each select="arg"> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@type"/> - </xsl:call-template> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@type"/> + </xsl:call-template> + </span> <xsl:text> </xsl:text> <xsl:value-of select="@name"/> <xsl:if test="position() != last()"> @@ -388,11 +409,13 @@ <xsl:variable name="tlen" select="string-length(return/@type)"/> <xsl:variable name="blen" select="(($nlen + 8) - (($nlen + 8) mod 8)) + (($tlen + 8) - (($tlen + 8) mod 8))"/> <h3><a name="{$name}"><code><xsl:value-of select="$name"/></code></a></h3> - <pre class="programlisting"> - <xsl:text>typedef </xsl:text> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="return/@type"/> - </xsl:call-template> + <pre class="api"> + <span class="keyword">typedef</span><xsl:text> </xsl:text> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="return/@type"/> + </xsl:call-template> + </span> <xsl:text> (*</xsl:text> <xsl:value-of select="@name"/> <xsl:if test="$blen - 40 < -8"> @@ -403,16 +426,19 @@ </xsl:if> <xsl:text>) (</xsl:text> <xsl:if test="not(arg)"> - <xsl:text>void</xsl:text> + <span class="type">void</span> </xsl:if> <xsl:for-each select="arg"> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@type"/> - </xsl:call-template> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@type"/> + </xsl:call-template> + </span> <xsl:text> </xsl:text> <xsl:value-of select="@name"/> <xsl:if test="position() != last()"> - <xsl:text>, </xsl:text><br/> + <xsl:text>, +</xsl:text> <xsl:if test="$blen - 40 > 8"> <xsl:text> </xsl:text> </xsl:if> @@ -465,10 +491,12 @@ <xsl:variable name="tlen" select="string-length(return/@type)"/> <xsl:variable name="blen" select="(($nlen + 8) - (($nlen + 8) mod 8)) + (($tlen + 8) - (($tlen + 8) mod 8))"/> <h3><a name="{$name}"><code><xsl:value-of select="$name"/></code></a></h3> - <pre class="programlisting"> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="return/@type"/> - </xsl:call-template> + <pre class="api"> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="return/@type"/> + </xsl:call-template> + </span> <xsl:text> </xsl:text> <xsl:value-of select="@name"/> <xsl:if test="$blen - 40 < -8"> @@ -479,16 +507,19 @@ </xsl:if> <xsl:text> (</xsl:text> <xsl:if test="not(arg)"> - <xsl:text>void</xsl:text> + <span class="type">void</span> </xsl:if> <xsl:for-each select="arg"> - <xsl:call-template name="dumptext"> - <xsl:with-param name="text" select="@type"/> - </xsl:call-template> + <span class="type"> + <xsl:call-template name="dumptext"> + <xsl:with-param name="text" select="@type"/> + </xsl:call-template> + </span> <xsl:text> </xsl:text> <xsl:value-of select="@name"/> <xsl:if test="position() != last()"> - <xsl:text>, </xsl:text><br/> + <xsl:text>, +</xsl:text> <xsl:if test="$blen - 40 > 8"> <xsl:text> </xsl:text> </xsl:if> @@ -498,9 +529,7 @@ <xsl:text> </xsl:text> </xsl:if> </xsl:for-each> - <xsl:text>)</xsl:text><br/> - <xsl:text> -</xsl:text> + <xsl:text>)</xsl:text> </pre> <div> <xsl:call-template name="formattext"> @@ -579,20 +608,20 @@ <h2>Table of Contents</h2> <xsl:if test="count(exports[@type='macro']) > 0"> <h3><a href="#macros">Macros</a></h3> - <pre> + <pre class="api"> <xsl:apply-templates select="exports[@type='macro']" mode="toc"> <xsl:sort select='@symbol'/> </xsl:apply-templates> </pre> </xsl:if> <h3><a href="#types">Types</a></h3> - <pre> + <pre class="api"> <xsl:apply-templates select="exports[@type='typedef']" mode="toc"> <xsl:sort select='@symbol'/> </xsl:apply-templates> </pre> <h3><a href="#functions">Functions</a></h3> - <pre> + <pre class="api"> <xsl:apply-templates select="exports[@type='function']" mode="toc"> <xsl:sort select='@symbol'/> </xsl:apply-templates> -- 1.7.9.5

Signed-off-by: Claudio Bley <cbley@av-test.de> --- docs/generic.css | 4 ++++ docs/libvirt.css | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/docs/generic.css b/docs/generic.css index dbf7b56..1def6bf 100644 --- a/docs/generic.css +++ b/docs/generic.css @@ -73,3 +73,7 @@ dl dd { margin-right: 2em; margin-bottom: 0.5em; } + +tt, pre { + font-family: "Ubuntu Monospace", "Consolas", "Lucida Console", monospace; +} diff --git a/docs/libvirt.css b/docs/libvirt.css index 5123ed6..305dedf 100644 --- a/docs/libvirt.css +++ b/docs/libvirt.css @@ -184,23 +184,25 @@ div.api { border: 1px solid #999999; background: #eeeeee; color: black; + padding: 3px; } div.api pre { margin: 0px; border: 0px; background: inherit; + padding: inherit; } div.api table { margin: 0px; padding-left: 2em; - font-family: fixed; - whitespace: pre; + border-spacing: 0px; } div.api table td, div.variablelist table td { vertical-align: top; + padding-left: 1em; } @@ -412,3 +414,53 @@ table.data tbody td.n { background: rgb(255,220,220); text-align: center; } + +.api { + font-family: "Ubuntu Monospace", "Consolas", "Lucida Console", monospace; + line-height: 175%; +} + +.api .type { + font-weight: bold; + white-space: nowrap; + color: darkslateblue; +} + +.api .keyword { + font-weight: bold; + color: #A2F; +} + +.api .comment { + color: #080; + margin-left: 2em; + position: relative; +} + +.api .comment:before { + content: ": "; + position: absolute; + left: -1.3em; +} + +.api .undisclosed { + font-style: italic; + letter-spacing: .3ex; + font-weight: bolder; + text-transform: uppercase; +} + +.api .directive { + color: teal; +} + +.api:link:hover, .api:link:focus { + color: blue; + border-color: blue; +} + +.api:link { + text-decoration: none; + padding-bottom: 2px; + border-bottom: 1px dashed grey; +} -- 1.7.9.5
participants (1)
-
Claudio Bley