grim/purple-objects-docbook

Parents 96f4c487e144
Children 2b9a5fd42173
created class.xsl to turn an xml formatted .class file into input suitable for graphviz
created plugin.class based off of plugin-class.dot
  • +115 -0
    class.xsl
  • +23 -0
    plugin.class
  • --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/class.xsl Fri Apr 17 22:55:04 2009 -0500
    @@ -0,0 +1,115 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    + <xsl:output method="text"/>
    +
    + <xsl:strip-space elements="*"/>
    +
    + <!-- variables -->
    + <xsl:variable name="newline" select="'&#10;'"/>
    + <xsl:variable name="tab" select="'&#9;'"/>
    +
    + <xsl:variable name="newline-tab">
    + <xsl:value-of select="$newline"/>
    + <xsl:value-of select="$tab"/>
    + </xsl:variable>
    +
    + <!-- scope template -->
    + <xsl:template name="scope">
    + <xsl:choose>
    + <xsl:when test="@scope = 'private'">
    + <xsl:text>-</xsl:text>
    + </xsl:when>
    + <xsl:when test="@scope = 'public'">
    + <xsl:text>+</xsl:text>
    + </xsl:when>
    + <xsl:when test="@scope = 'protected'">
    + <xsl:text>#</xsl:text>
    + </xsl:when>
    + <xsl:otherwise>
    + <xsl:text> </xsl:text>
    + </xsl:otherwise>
    + </xsl:choose>
    + </xsl:template>
    +
    + <!-- the actual matching -->
    + <xsl:template match="class">
    + <!-- start the diagram -->
    + <xsl:text>digraph {</xsl:text>
    + <xsl:value-of select="$newline-tab"/>
    +
    + <!-- set our node settings -->
    + <xsl:text>node[fontname="sans", fontsize="9", shape="record", style="filled", fillcolor="lightyellow"];</xsl:text>
    + <xsl:value-of select="$newline-tab"/>
    +
    + <!-- handle the beginning of the class node -->
    + <xsl:text>class[label="{</xsl:text>
    + <xsl:value-of select="@name"/>
    +
    + <!-- if the class is abstract, mark it as such -->
    + <xsl:if test="@abstract">
    + <xsl:text>\n\&lt;\&lt; abstract \&gt;\&gt;</xsl:text>
    + </xsl:if>
    +
    + <xsl:text>|</xsl:text>
    +
    + <!-- run through the properties -->
    + <xsl:for-each select="properties/property">
    + <xsl:call-template name="scope"/>
    +
    + <!-- now the rest of the property -->
    + <xsl:text> </xsl:text>
    + <xsl:value-of select="@name"/>
    +
    + <xsl:if test="@type">
    + <xsl:text> : </xsl:text>
    + <xsl:value-of select="@type"/>
    + </xsl:if>
    +
    + <xsl:text>\l</xsl:text>
    + </xsl:for-each>
    +
    + <xsl:text>|</xsl:text>
    +
    + <!-- run through the methods -->
    + <xsl:for-each select="methods/method">
    + <xsl:call-template name="scope"/>
    +
    + <!-- start the method -->
    + <xsl:text> </xsl:text>
    + <xsl:value-of select="@name"/>
    +
    + <!-- start the arguments -->
    + <xsl:text>(</xsl:text>
    +
    + <!-- run through the arguments -->
    + <xsl:for-each select="argument">
    + <!-- put a comment at the end of the last text if this isn't
    + the first argument.
    + -->
    + <xsl:if test="position() &gt; 1">
    + <xsl:text>, </xsl:text>
    + </xsl:if>
    +
    + <xsl:value-of select="@name"/>
    +
    + <xsl:if test="@type">
    + <xsl:text> : </xsl:text>
    + <xsl:value-of select="@type"/>
    + </xsl:if>
    + </xsl:for-each>
    +
    + <!-- finish the arguments -->
    + <xsl:text>)</xsl:text>
    +
    + <xsl:text>\l</xsl:text>
    + </xsl:for-each>
    +
    + <!-- finish off the class node -->
    + <xsl:text>}"];</xsl:text>
    +
    + <!-- finish up -->
    + <xsl:value-of select="$newline"/>
    + <xsl:text>}</xsl:text>
    + <xsl:value-of select="$newline"/>
    + </xsl:template>
    +</xsl:stylesheet>
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/plugin.class Fri Apr 17 22:55:04 2009 -0500
    @@ -0,0 +1,23 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<class name="PurplePlugin" abstract="true">
    + <properties>
    + <property name="state" type="PurplePluginState" scope="private"/>
    + <property name="filename" type="gchar *" scope="private"/>
    + <property name="info" type="PurplePluginInfo" scope="private"/>
    + </properties>
    + <methods>
    + <method name="purple_plugin_get_state" type="PurplePluginState" scope="public">
    + <argument name="plugin" type="const PurplePlugin *"/>
    + </method>
    + <method name="purple_plugin_get_filename" type="const gchar *" scope="public">
    + <argument name="plugin" type="const PurplePlugin *"/>
    + </method>
    + <method name="purple_plugin_get_info" type="PurplePluginInfo *" scope="public">
    + <argument name="plugin" type="const PurplePlugin *"/>
    + </method>
    + </methods>
    +</class>
    +
    +<!--
    + vi: syntax=xml
    +-->