antlets/makeantlet/src/resources/stylesheets cleanup-comment.xsl,NONE,1.1 properties2xdoc.xsl,1.3,1.4 xbuild2xdoc.xsl,1.2,1.3
Pim Schrama <[email protected]> Fri, 19 Mar 2004 09:45:24 +0000
| Newsgroups | gmane.comp.krysalis.metamorphosis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/metamorphosis/antlets/makeantlet/src/resources/stylesheets
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13858/makeantlet/src/resources/stylesheets
Modified Files:
properties2xdoc.xsl xbuild2xdoc.xsl
Added Files:
cleanup-comment.xsl
Log Message:
building documentation parses properties
Index: xbuild2xdoc.xsl
===================================================================
RCS file: /cvsroot/metamorphosis/antlets/makeantlet/src/resources/stylesheets/xbuild2xdoc.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** xbuild2xdoc.xsl 10 Mar 2004 12:30:56 -0000 1.2
--- xbuild2xdoc.xsl 19 Mar 2004 09:45:22 -0000 1.3
***************
*** 4,18 ****
<xsl:output method="xml" doctype-public="-//APACHE//DTD Documentation V1.1//EN" doctype-system="./dtd/document-v11.dtd"/>
<xsl:strip-space elements="project target"/>
!
<xsl:template match="/">
<document>
! <xsl:apply-templates select="project"/>
</document>
! </xsl:template>
!
!
! <xsl:template match="project">
<header>
! <title><xsl:value-of select="@name"/></title>
<authors>
<person id="AD" name="Antlet Documentation" email="[email protected]"/>
--- 4,21 ----
<xsl:output method="xml" doctype-public="-//APACHE//DTD Documentation V1.1//EN" doctype-system="./dtd/document-v11.dtd"/>
<xsl:strip-space elements="project target"/>
!
! <xsl:include href="cleanup-comment.xsl"/>
!
<xsl:template match="/">
<document>
! <xsl:apply-templates select="project"/>
</document>
! </xsl:template>
!
! <xsl:template match="project">
<header>
! <title>
! <xsl:value-of select="@name"/>
! </title>
<authors>
<person id="AD" name="Antlet Documentation" email="[email protected]"/>
***************
*** 21,66 ****
<body>
<p>
! <xsl:if test="@description or description">
! <strong>Description:</strong>
! <xsl:value-of select="@description"/>
! <xsl:value-of select="description"/>
! </xsl:if>
</p>
<section>
! <title>Main Targets</title>
! <xsl:apply-templates select="target">
! <xsl:with-param name="target-filter" select="'main'" />
! </xsl:apply-templates>
</section>
<section>
<title>Helper Targets</title>
! <xsl:apply-templates select="target">
! <xsl:with-param name="target-filter" select="'helper'" />
! </xsl:apply-templates>
</section>
<section>
<title>Internal Targets</title>
! <xsl:apply-templates select="target">
! <xsl:with-param name="target-filter" select="'internal'" />
! </xsl:apply-templates>
</section>
<section>
! <title>internal Properties</title>
! <!-- xsl:apply-templates select="property"/ -->
</section>
! </body>
! </xsl:template>
!
!
! <xsl:template match="target">
! <xsl:param name="target-filter" select="'main'" />
<xsl:variable name="targetType">
<xsl:choose>
<xsl:when test="starts-with(@name, '-')">
<xsl:text>internal</xsl:text>
</xsl:when>
<xsl:when test="@description">
<xsl:text>main</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>helper</xsl:text>
--- 24,71 ----
<body>
<p>
! <xsl:if test="@description or description">
! <strong>Description:</strong>
! <xsl:value-of select="@description"/>
! <xsl:value-of select="description"/>
! </xsl:if>
</p>
<section>
! <title>Main Targets</title>
! <xsl:apply-templates select="target">
! <xsl:with-param name="target-filter" select="'main'"/>
! </xsl:apply-templates>
</section>
<section>
<title>Helper Targets</title>
! <xsl:apply-templates select="target">
! <xsl:with-param name="target-filter" select="'helper'"/>
! </xsl:apply-templates>
</section>
<section>
<title>Internal Targets</title>
! <xsl:apply-templates select="target">
! <xsl:with-param name="target-filter" select="'internal'"/>
! </xsl:apply-templates>
</section>
<section>
! <title>Internal Properties</title>
! <xsl:apply-templates select="property"/>
</section>
! </body>
! </xsl:template>
!
! <xsl:template match="target">
! <xsl:param name="target-filter" select="'main'"/>
<xsl:variable name="targetType">
<xsl:choose>
+ <!-- name of an internal target starts with '-' -->
<xsl:when test="starts-with(@name, '-')">
<xsl:text>internal</xsl:text>
</xsl:when>
+ <!-- name of a main target does not start with '-', but has a description attribute -->
<xsl:when test="@description">
<xsl:text>main</xsl:text>
</xsl:when>
+ <!-- otherwise, it's a helper target -->
<xsl:otherwise>
<xsl:text>helper</xsl:text>
***************
*** 68,107 ****
</xsl:choose>
</xsl:variable>
!
<xsl:if test="$target-filter=$targetType">
! <p />
<table>
! <tr><td><strong><xsl:value-of select="@name"/></strong></td></tr>
! <tr><td><em>Description:</em><xsl:value-of select="@description"/> </td></tr>
! <tr><td><em>Comment:</em><xsl:call-template name="get-comment"/> </td></tr>
</table>
</xsl:if>
- <!-- xsl:apply-templates select="property"/ -->
- </xsl:template>
-
-
- <xsl:template match="property">
- <property>
- <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
- <description>
- <xsl:call-template name="get-comment"/>
- </description>
- <default>
- <xsl:value-of select="@value"/>
- </default>
- </property>
- </xsl:template>
-
- <xsl:template name="get-comment">
- <xsl:param name="count" select="1"/>
- <xsl:variable name="mynode" select="preceding-sibling::comment()[$count]"/>
- <xsl:if test="preceding-sibling::node()[$count] = $mynode">
- <xsl:value-of disable-output-escaping="yes" select="normalize-space(translate($mynode,'=',''))"/>
- <xsl:call-template name="get-comment">
- <xsl:with-param name="count" select="$count+1" />
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
- </xsl:stylesheet>
--- 73,134 ----
</xsl:choose>
</xsl:variable>
!
<xsl:if test="$target-filter=$targetType">
! <p/>
<table>
! <tr>
! <td>
! <strong>
! <xsl:value-of select="@name"/>
! </strong>
! </td>
! </tr>
! <tr>
! <td>
! <em>Description:</em>
! <xsl:value-of select="@description"/> </td>
! </tr>
! <tr>
! <td>
! <em>Comment:</em>
! <xsl:variable name="comment-node" select="preceding-sibling::node()[1][self::comment()]"/>
! <!-- clean up the comment -->
! <xsl:call-template name="cleanup-comment">
! <xsl:with-param name="my-comment" select="$comment-node"/>
! </xsl:call-template> 
! </td>
! </tr>
</table>
</xsl:if>
+ </xsl:template>
+
+ <xsl:template match="//property">
+ <p/>
+ <table>
+ <tr>
+ <td>
+ <strong>
+ <xsl:value-of select="@name"/>
+ </strong>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <em>Description:</em>
+ <xsl:value-of select="@value"/> 
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <em>Comment:</em>
+ <xsl:variable name="comment-node" select="preceding-sibling::node()[1][self::comment()]"/>
+ <xsl:call-template name="cleanup-comment">
+ <xsl:with-param name="my-comment" select="$comment-node"/>
+ </xsl:call-template> 
+ </td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ </xsl:stylesheet>
--- NEW FILE: cleanup-comment.xsl ---
<?xml version="1.0"?>
<!-- style sheet to output the 'public' properties and their comments in xdoc format -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" doctype-public="-//APACHE//DTD Documentation V1.1//EN" doctype-system="./dtd/document-v11.dtd"/>
<xsl:strip-space elements="properties"/>
<xsl:param name="version">0.0</xsl:param>
<!-- remove any sequence of 2 or more successive equal signs for they could have been used within
comment as in the following comment -->
<!-- =================================================================================
this could have been the <em>comment</em> for a property
================================================================================= -->
<!-- TODO this is a rather crude solution to the problem of removing to much successve equal signs or
apostrophes: in case an odd number of equal signs is used within the comment, there will still be
1 equal sign left; meaningful comment like a == b will also be removed in the current implementation. -->
<xsl:template name="cleanup-comment">
<xsl:param name="my-comment"/>
<xsl:variable name="comment-node-multiple-equal-signs-removed">
<xsl:call-template name="remove-substring">
<xsl:with-param name="text" select="$my-comment"/>
<xsl:with-param name="to-remove" select="'=='"/>
</xsl:call-template>
</xsl:variable>
<!-- remove any sequence of 2 or more successive apostrophe signs -->
<xsl:variable name="comment-node-cleaned-up">
<xsl:call-template name="remove-substring">
<xsl:with-param name="text" select="$comment-node-multiple-equal-signs-removed"/>
<xsl:with-param name="to-remove" select=""''""/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of disable-output-escaping="yes" select="normalize-space($comment-node-cleaned-up)"/>
</xsl:template>
<!-- Removes all occurrences of a substring within a string.
Within the the supplied parameter text, all occurrences the supplied parameter to-remove will be removed.
If the text does not contain to-remove, the text will be returned.
E.g.: when called with
text 'xxxx as part of my xx documentation xxxxxxxxx'
to-remove 'xxxx'
the result will be
' as part of my xx documentation '.
-->
<xsl:template name="remove-substring">
<xsl:param name="text"/>
<xsl:param name="to-remove"/>
<xsl:choose>
<xsl:when test="contains($text,$to-remove)">
<xsl:value-of select="substring-before($text,$to-remove)"/>
<xsl:call-template name="remove-substring">
<xsl:with-param name="text" select="substring-after($text,$to-remove)"/>
<xsl:with-param name="to-remove" select="$to-remove"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Index: properties2xdoc.xsl
===================================================================
RCS file: /cvsroot/metamorphosis/antlets/makeantlet/src/resources/stylesheets/properties2xdoc.xsl,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** properties2xdoc.xsl 10 Mar 2004 12:30:56 -0000 1.3
--- properties2xdoc.xsl 19 Mar 2004 09:45:22 -0000 1.4
***************
*** 3,12 ****
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" doctype-public="-//APACHE//DTD Documentation V1.1//EN" doctype-system="./dtd/document-v11.dtd"/>
! <xsl:strip-space elements="project target"/>
<xsl:param name="version">0.0</xsl:param>
<xsl:template match="/">
<document>
<header>
! <title>Properties</title>
<authors>
<person id="AD" name="Antlet Documentation" email="[email protected]"/>
--- 3,15 ----
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" doctype-public="-//APACHE//DTD Documentation V1.1//EN" doctype-system="./dtd/document-v11.dtd"/>
! <xsl:strip-space elements="properties"/>
<xsl:param name="version">0.0</xsl:param>
+
+ <xsl:include href="cleanup-comment.xsl"/>
+
<xsl:template match="/">
<document>
<header>
! <title>Public Properties</title>
<authors>
<person id="AD" name="Antlet Documentation" email="[email protected]"/>
***************
*** 14,46 ****
</header>
<body>
! <table>
! <tr>
! <th>Name</th>
! <th>Default Value</th>
! <th>Comment</th>
! </tr>
! <xsl:for-each select="*">
! <xsl:call-template name="find-property"/>
! </xsl:for-each>
! </table>
</body>
</document>
</xsl:template>
!
! <xsl:template name="find-property">
<xsl:param name="prop-path"/>
! <xsl:for-each select="*">
<xsl:call-template name="find-property">
- <!--xsl:with-param name="prop-path" select="concat($property-path,'.',name())"/-->
<xsl:with-param name="prop-path" select="concat($prop-path,substring('.', 1, boolean($prop-path) * 1),name())"/>
</xsl:call-template>
</xsl:for-each>
<xsl:if test="text() and not(*)">
<tr>
! <td><strong><xsl:value-of select="$prop-path"/></strong></td>
! <td><code><xsl:value-of select="text()" /></code></td>
! <td> </td>
</tr>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
--- 17,67 ----
</header>
<body>
! <xsl:for-each select="*">
! <xsl:call-template name="find-property"/>
! </xsl:for-each>
</body>
</document>
</xsl:template>
!
! <xsl:template name="find-property">
<xsl:param name="prop-path"/>
! <xsl:for-each select="* | comment()">
<xsl:call-template name="find-property">
<xsl:with-param name="prop-path" select="concat($prop-path,substring('.', 1, boolean($prop-path) * 1),name())"/>
</xsl:call-template>
</xsl:for-each>
<xsl:if test="text() and not(*)">
+ <p />
+ <table>
<tr>
! <td>
! <strong>
! <xsl:value-of select="$prop-path"/>
! </strong>
! </td>
! </tr>
! <tr>
! <td>
! <em>Description:</em>
! <code>
! <xsl:value-of select="."/>
! </code>
! </td>
</tr>
+ <tr>
+ <td>
+ <em>Comment:</em>
+ <!-- selects the comment-node that immediately precedes the current node -->
+ <xsl:variable name="comment-node" select="preceding-sibling::node()[1][self::comment()]"/>
+
+ <!-- clean up the comment -->
+ <xsl:call-template name="cleanup-comment">
+ <xsl:with-param name="my-comment" select="$comment-node"/>
+ </xsl:call-template>
+ </td>
+ </tr>
+ </table>
</xsl:if>
</xsl:template>
+
</xsl:stylesheet>
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click