dion        2002/06/15 20:19:36

  Modified:    src/templates/build/plugins/docs Control.vm build.xml
  Added:       src/templates/build/plugins/docs default.properties
                        docbook2document.xsl
  Log:
  - Allow docbook-simple to markup maven documentation.
  - If the maven.src.docbook-simple property points to a valid directory, the 
docbook-simple
     target is called as part of docs processing
  - Currently this functionality is experimental, and the stylesheet that does
     the processing is known to have some 'issues'
  
  Revision  Changes    Path
  1.5       +2 -0      
jakarta-turbine-maven/src/templates/build/plugins/docs/Control.vm
  
  Index: Control.vm
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/templates/build/plugins/docs/Control.vm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Control.vm        4 Jun 2002 04:45:24 -0000       1.4
  +++ Control.vm        16 Jun 2002 03:19:35 -0000      1.5
  @@ -6,6 +6,8 @@
   ## Add build files to the list
   ## -------------------------------------------------------
   $buildElements.add("plugins/$plugin/build.xml")
  +$buildElements.add("plugins/$plugin/default.properties")
  +$buildElements.add("plugins/$plugin/docbook2document.xsl")
   
   ## -------------------------------------------------------
   ## Make the list of delegators
  
  
  
  1.16      +21 -3     jakarta-turbine-maven/src/templates/build/plugins/docs/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/templates/build/plugins/docs/build.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- build.xml 10 Jun 2002 09:51:50 -0000      1.15
  +++ build.xml 16 Jun 2002 03:19:35 -0000      1.16
  @@ -50,6 +50,8 @@
     <target
       name="local-init"
       depends="init">
  +    <!-- Pick up tool specific defaults -->
  +    <property file="${maven.home}/plugins/docs/default.properties"/>
   
       <mkdir dir="${maven.src.dir}"/>
       <mkdir dir="${maven.docs.src}"/>
  @@ -59,6 +61,10 @@
       <mkdir dir="${maven.gen.docs}"/>
       <mkdir dir="${maven.jxr.destdir}"/>
       <mkdir dir="${maven.javadoc.destdir}"/>
  +    
  +    <!-- if docbook processing should happen -->
  +    <available property="maven.docbook-simple.ok" 
  +      file="${maven.src.docbook-simple}" type="dir"/>
   
       <!-- activity-log -->
       <condition property="maven.docs.callback.pre-activity-log.ok">
  @@ -297,7 +303,7 @@
       name="docs"
       depends="local-init, pre-docs-callback, jdepend-metrics, junit-report, 
         checkstyle-report, change-log, activity-log, task-list, generate-xdocs,
  -      docs:site, post-docs-callback"
  +      docbook-simple, docs:site, post-docs-callback"
       description="o Generate html project documentation xdoc sources">
     </target>
     
  @@ -315,8 +321,8 @@
   
     <target
       name="docs-quick"
  -    depends="local-init, pre-docs-quick-callback,generate-xdocs, docs:site,
  -       post-docs-quick-callback"
  +    depends="local-init, pre-docs-quick-callback,generate-xdocs, docbook-simple,
  +      docs:site, post-docs-quick-callback"
       description="o Generates documentation that are quickly generated.">
     </target>
   
  @@ -554,6 +560,18 @@
         outputFile="xdocs.report"
         projectDescriptor="project.xml" />
   
  +  </target>
  +
  +  <!-- ================================================================== -->
  +  <!-- S I M P L E   D O C B O O K   D O C U M E N T A T I O N            -->
  +  <!-- ================================================================== -->
  +  <target name="docbook-simple" depends="local-init" if="maven.docbook-simple.ok"
  +    description="Transform any docbook-simple source into xdocs for later use">
  +    
  +    <style basedir="${maven.src.docbook-simple}"
  +      destdir="${maven.gen.docs}" extension=".xml"
  +      style="${maven.home}/plugins/docs/docbook2document.xsl" 
  +      includes="**/*.xml"/>
     </target>
   
     <!-- ================================================================== -->
  
  
  
  1.1                  
jakarta-turbine-maven/src/templates/build/plugins/docs/default.properties
  
  Index: default.properties
  ===================================================================
  # properties for the docs plugin only
  maven.src.docbook-simple=${maven.src.dir}/sdocbook
  
  
  
  1.1                  
jakarta-turbine-maven/src/templates/build/plugins/docs/docbook2document.xsl
  
  Index: docbook2document.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
      Author:     Berin Loritsch ([EMAIL PROTECTED])
      Author:     Peter Donald  ([EMAIL PROTECTED])
      Author:     dIon Gillard ([EMAIL PROTECTED])
      Version:    $Id: docbook2document.xsl,v 1.1 2002/06/16 03:19:35 dion Exp $
      FIXME:      Doesn't handle attributes of informaltable and other docbook elements
    -->
  
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
      <!-- used for cross ref links (xref) -->
    <xsl:key name="id" match="*" use="@id"/>
  
    <xsl:template match="/">
      <xsl:comment>This document generated by docbook2document.xsl</xsl:comment>
      <xsl:apply-templates />
    </xsl:template>
      
    <!-- top level component templates -->
    <xsl:template match="book">
      <document>
        <properties>
          <title>
            <xsl:value-of select="title"/>
            <xsl:if test="subtitle">
              (<xsl:value-of select="subtitle"/>)
            </xsl:if>
          </title>
          <xsl:for-each select="//authorgroup/author">
            <author email="{affiliation/address/email}">
              <xsl:if test="honorific"><xsl:value-of select="honorific"/>. </xsl:if>
              <xsl:if test="firstname">
                <xsl:value-of select="firstname"/>
                <xsl:text> </xsl:text>
              </xsl:if>
              <xsl:value-of select="surname"/>
            </author>
          </xsl:for-each>
        </properties>
  
        <body>
          <xsl:apply-templates select="dedication"/>
          <xsl:apply-templates select="bookinfo"/>
        </body>
      </document>    
    </xsl:template>
  
    <!-- 
        top level components create document, properties element and start body
      -->
    <xsl:template match="chapter|article|appendix">
      <document>
        <properties>
          <title>
            <xsl:value-of select="title"/>
            <xsl:if test="subtitle">
              (<xsl:value-of select="subtitle"/>)
            </xsl:if>
          </title>
          <xsl:for-each select="//authorgroup/author">
            <author email="{affiliation/address/email}">
              <xsl:if test="honorific"><xsl:value-of select="honorific"/>. </xsl:if>
              <xsl:if test="firstname">
                <xsl:value-of select="firstname"/>
                <xsl:text> </xsl:text>
              </xsl:if>
              <xsl:value-of select="surname"/>
            </author>
          </xsl:for-each>
        </properties>
  
        <body>
          <xsl:apply-templates />
  
          <xsl:apply-templates select="//footnote" mode="base"/>
        </body>
      </document>
    </xsl:template>
  
    <xsl:template match="title|subtitle"/>
  
    <!-- author block -->
    <!-- FIXME: Where would this match? -->
    <xsl:template match="author">
      <p>Author: 
        <xsl:value-of select="honorific"/><xsl:text>. </xsl:text>
        <xsl:value-of select="firstname"/><xsl:text> </xsl:text>
        <xsl:value-of select="surname"/>
      </p>
        
      <xsl:text>Affiliations</xsl:text>
      <ul>
        <xsl:apply-templates select="affiliation"/>
      </ul>
      <xsl:apply-templates select="authorblurb"/>
    </xsl:template>
  
    <xsl:template match="affiliation">
      <li>
        <xsl:text>[</xsl:text>
        <xsl:value-of select="shortaffil"/>
        <xsl:text>] </xsl:text>
        <b><xsl:value-of select="jobtitle"/></b>
        <i><xsl:value-of select="orgname"/>
          <xsl:if test="orgdiv">
            <xsl:text>/</xsl:text>
            <xsl:value-of select="orgdiv"/>
          </xsl:if>
        </i>
      </li>
    </xsl:template>
  
    <xsl:template match="authorblurb">
      <xsl:text>Bio</xsl:text>
      <ul>
        <xsl:apply-templates/>
      </ul>
    </xsl:template>
  
    <xsl:template 
match="honorific|firstname|surname|orgdiv|orgname|shortaffil|jobtitle"/>
  
    <!-- revision history -->
    <xsl:template match="revhistory">
      <section name="Revision History">
        <xsl:variable name="unique-revisions" 
          
select="revision[not(revnumber=preceding-sibling::revision/revnumber)]/revnumber"/>
  
        <xsl:variable name="base" select="."/>
  
        <xsl:for-each select="$unique-revisions">
          <p>Revision <xsl:value-of select="."/> 
            (<xsl:value-of select="$base/revision[revnumber=current()]/date"/>)
          </p>
          <ul>
            <xsl:apply-templates select="$base/revision[revnumber=current()]"/>
          </ul>
        </xsl:for-each>
      </section>
    </xsl:template>
  
    <xsl:template match="revision">
      <li>
        <xsl:choose>
          <xsl:when test="@revisionflag='added'">
            <img align="absmiddle" alt="added" border="0" src="images/add.jpg"/>
          </xsl:when>
          <xsl:when test="@revisionflag='changed'">
            <img align="absmiddle" alt="changed" border="0" src="images/update.jpg"/>
          </xsl:when>
          <xsl:when test="@revisionflag='deleted'">
            <img align="absmiddle" alt="deleted" border="0" src="images/remove.jpg"/>
          </xsl:when>
          <xsl:when test="@revisionflag='off'">
            <img align="absmiddle" alt="off" border="0" src="images/fix.jpg"/>
          </xsl:when>
          <xsl:otherwise>
            <img align="absmiddle" alt="changed" border="0" src="images/update.jpg"/>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:value-of select="revremark"/>
        <xsl:text> (</xsl:text><xsl:value-of 
select="authorinitials"/><xsl:text>)</xsl:text>
      </li>
    </xsl:template>
  
    <xsl:template match="revnumber|revremark|authorinitials|date"/>
  
    <xsl:template match="section">
      <xsl:call-template name="section-common">
        <xsl:with-param name="level" select="1"/>
      </xsl:call-template>
    </xsl:template>
  
    <xsl:template match="sect1">
      <xsl:call-template name="section-common">
        <xsl:with-param name="level" select="1"/>
      </xsl:call-template>
    </xsl:template>
  
    <xsl:template match="sect2">
      <xsl:call-template name="section-common">
        <xsl:with-param name="level" select="2"/>
      </xsl:call-template>
    </xsl:template>
          
    <!-- sections - and nested -->
    <xsl:template name="section-common">
      <xsl:param name="level"/>
  
      <xsl:choose>
        <xsl:when test="number($level)=1">
          <xsl:if test="@id"><a name="{@id}"> </a></xsl:if>
          <section name="{title}">
            <xsl:apply-templates>
              <xsl:with-param name="level" select="number($level)+1"/>
            </xsl:apply-templates>
          </section>
        </xsl:when>
        <xsl:when test="number($level)=2">
          <xsl:if test="@id"><a name="{@id}"> </a></xsl:if>
          <subsection name="{title}">
            <xsl:apply-templates>
              <xsl:with-param name="level" select="number($level)+1"/>
            </xsl:apply-templates>
          </subsection>
        </xsl:when>
        <xsl:otherwise>
          <xsl:if test="@id"><a name="{@id}"> </a></xsl:if>
          <p><a name="{@name}"><strong><xsl:value-of select="title"/></strong></a><br 
/>
            <xsl:apply-templates>
              <xsl:with-param name="level" select="number($level)+1"/>
            </xsl:apply-templates>
          </p>    
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
      
    <!-- paragraphs/textual elements -->
    <xsl:template match="para">
      <p><xsl:apply-templates/></p>
    </xsl:template>
  
    <xsl:template match="emphasis"><em><xsl:apply-templates/></em></xsl:template>
      
    <xsl:template match="example">
      <p><pre><xsl:apply-templates/></pre></p>
    </xsl:template>
  
    <!-- book details --> 
    <xsl:template match="bookinfo">
      <b><xsl:value-of select="edition"/></b><xsl:text> </xsl:text>
      <i>pub. <xsl:value-of select="pubdate"/></i>
      <xsl:apply-templates/>
    </xsl:template>
  
    <xsl:template match="dedication">
      <b>Dedication</b>
      <xsl:apply-templates/>
    </xsl:template>
  
    <xsl:template match="edition|pubdate|year|holder"/>
  
    <xsl:template match="copyright">
      <p>Copyright &#x00A9;<xsl:value-of select="year"/> by 
        <xsl:value-of select="holder"/>.<br/>
        <i>All rights reserved.</i>
      </p>
    </xsl:template>
  
    <xsl:template match="legalnotice">
      <p>Legal Notice</p>
      <xsl:apply-templates/>
    </xsl:template>
  
    <!-- lists etc -->
    <xsl:template match="programlisting">
      <source><xsl:apply-templates/></source>
    </xsl:template>
  
    <xsl:template match="orderedlist"><ol><xsl:apply-templates/></ol></xsl:template>
  
    <xsl:template 
match="listitem|member"><li><xsl:apply-templates/></li></xsl:template>
  
    <xsl:template 
match="itemizedlist|simplelist"><ul><xsl:apply-templates/></ul></xsl:template>
      
    <xsl:template 
match="classname|function|parameter"><code><xsl:apply-templates/><xsl:if 
test="name(.)='function'"><xsl:text>()</xsl:text></xsl:if></code></xsl:template>
  
    <xsl:template match="blockquote">
      <xsl:if test="title">
        <blockquote><xsl:value-of select="title"/><br/>
          <xsl:apply-templates/>
        </blockquote>
      </xsl:if>
      <p></p>
    </xsl:template>
  
    <xsl:template match="warning">
      <xsl:if test="title">
        <p><em><xsl:value-of select="title"/></em></p>
      </xsl:if>
      <p><xsl:apply-templates/></p>
    </xsl:template>
  
    <!-- links -->
    <xsl:template match="ulink"><a 
href="{@url}"><xsl:apply-templates/></a></xsl:template>
    <xsl:template match="xref">
      <!--
          make a link to the linkend specified, prefixing with a # since it's
          internal to the generated html. The text of the link should be either
          a) element pointed to by linkend's xreflabel or
          b) endterm content
       -->
      <xsl:variable name="link-targets" select="key('id',@linkend)"/>
      <xsl:variable name="link-target" select="$link-targets[1]"/>
  
      <a href="#{@linkend}">
        <!-- xreflabel of target goes here-->
        <xsl:choose>
          <xsl:when test="$link-target/@xreflabel">
            <xsl:value-of select="$link-target/@xreflabel"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:variable name="endterm-targets" select="key('id',@endterm)"/>
            <xsl:variable name="endterm-target" select="$endterm-targets[1]"/>
            <xsl:apply-templates select="$endterm-target"/>
          </xsl:otherwise>
        </xsl:choose>
      </a>
    </xsl:template>
  
    <!-- tables, footnotes etc -->
    <xsl:template match="footnote">
      <sup><a href="#{generate-id(.)}"><xsl:value-of select="generate-id(.)"/></a>
      </sup>
    </xsl:template>
  
    <xsl:template match="footnote" mode="base">
      <a name="{generate-id(.)}"/><xsl:value-of select="generate-id(.)"/><xsl:text>) 
</xsl:text><i><xsl:value-of select="."/></i>
    </xsl:template>
  
    <xsl:template match="figure">
      <p>Figure: <xsl:value-of select="title"/></p>
      <xsl:apply-templates/>
    </xsl:template>
  
    <xsl:template match="graphic">
      <img border="0" alt="{@srccredit}" src="{@fileref}"/>
      <xsl:if test="@srccredit">
        <ul><li><xsl:value-of select="@srccredit"/></li></ul>
      </xsl:if>
    </xsl:template>
  
    <xsl:template match="table"><table><xsl:apply-templates/></table></xsl:template>
  
    <!-- FIXME: support attributes of informal table here -->
    <xsl:template match="informaltable">
      <table><xsl:apply-templates/></table>
    </xsl:template>
  
    <xsl:template match="tgroup">
      <xsl:apply-templates select="thead|tbody|tfoot"/>
    </xsl:template>
  
    <xsl:template match="thead">
      <xsl:apply-templates select="row" mode="head"/>
    </xsl:template>
  
    <xsl:template match="row" mode="head">
      <tr><xsl:apply-templates select="entry" mode="head"/></tr>
    </xsl:template>
  
    <xsl:template match="row">
      <tr><xsl:apply-templates/></tr>
    </xsl:template>
  
    <xsl:template match="tbody|tfoot">
      <xsl:apply-templates/>
    </xsl:template>
  
    <xsl:template match="entry" mode="head">
      <th><xsl:apply-templates/></th>
    </xsl:template>
    
    <xsl:template match="entry">
      <td><xsl:apply-templates/></td>
    </xsl:template>
  
    <xsl:template match="firstterm">
      <i><xsl:apply-templates/></i>
    </xsl:template>
    
    <xsl:template match="remark">
      <p><b>Note:</b> <xsl:apply-templates/></p>
    </xsl:template>
    
    <xsl:template match="sgmltag">
      <code><xsl:apply-templates/></code>
    </xsl:template>
    
    <xsl:template match="trademark"><xsl:apply-templates/><sup>TM</sup></xsl:template>
  
    <xsl:template match="node()|@*" priority="-1">
      <xsl:copy>
        <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
    </xsl:template>
    
  </xsl:stylesheet>
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to