You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ka...@apache.org on 2002/03/01 19:11:26 UTC

cvs commit: jakarta-turbine-maven/xdocs/stylesheets jdepend.dvsl jdepend.xsl

kaz         02/03/01 10:11:26

  Modified:    .        build-bootstrap.xml
               src/templates/build build-docs.xml build-metrics.xml
               xdocs    toolbox.props
  Added:       src/java/org/apache/maven DVSLFormatter.java
               xdocs/stylesheets jdepend.dvsl
  Removed:     xdocs/stylesheets jdepend.xsl
  Log:
  - Converted the XSL stylesheet that is used to display the XML output of
    JDepend to a DVSL stylesheet.  This makes Maven a pure DVSL shop now.
    As a result, the XSLT is no longer used in the build files (only DVSL).
  
  - The output of the DVSL stylesheet is not HTML, but rather an xdoc that
    is then transformed to HTML when the rest of the documentation is
    built.  Consequently, the new metric page *looks* like the rest of the
    site (jakarta style).
  
  - The DVSL stylesheet required the creation of one helper class that has
    been added to the DVSL toolbox.  This helper class converts a decimal
    to a percentage (I couldn't figure out how to do this in the template).
    As a result, this required the addition of another path to the DVSL
    task's classpath, because because the new helper class was not in the
    existing classpath.
  
  - Finally, the bootstrap build was modified to include the new helper
    class when creating the maven jar file.
  
  Revision  Changes    Path
  1.23      +1 -0      jakarta-turbine-maven/build-bootstrap.xml
  
  Index: build-bootstrap.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/build-bootstrap.xml,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- build-bootstrap.xml	28 Feb 2002 23:38:32 -0000	1.22
  +++ build-bootstrap.xml	1 Mar 2002 18:11:26 -0000	1.23
  @@ -87,6 +87,7 @@
         <class name="org.apache.maven.Jxr"/>
         <class name="org.apache.maven.ChangeLog"/>
         <class name="org.apache.maven.UpdateResources"/>
  +      <class name="org.apache.maven.DVSLFormatter"/>
         
         <!-- The project classes have to be all list, dynamic loading -->
         <class name="org.apache.maven.project.BaseObject"/>
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/DVSLFormatter.java
  
  Index: DVSLFormatter.java
  ===================================================================
  package org.apache.maven;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.text.NumberFormat;
  
  /** 
   * Formatting tool for use with the DVSL toolbox.  This class contains
   * static methods to assist in formatting needs that can't be done or
   * shouldn't be done in a DVSL stylesheet.
   * 
   * @author <a href="mailto:pete@kazmier.com">Pete Kazmier</a>
   * @version $Id: DVSLFormatter.java,v 1.1 2002/03/01 18:11:26 kaz Exp $
   */
  public class DVSLFormatter
  {
      /** 
       * Instance of a percentage number formatter.
       */
      private static NumberFormat percent = NumberFormat.getPercentInstance();
  
      /** 
       * Formats a decimal as a percentage using the current Locale.
       * 
       * @param value A decimal representing a percentage.
       * @return The decimal formatted as a percentage.
       */
      public static final String formatPercentage(Double value)
      {
          return percent.format(value.doubleValue());
      }
  }
  
  
  
  
  1.21      +16 -4     jakarta-turbine-maven/src/templates/build/build-docs.xml
  
  Index: build-docs.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/build-docs.xml,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- build-docs.xml	1 Mar 2002 11:37:41 -0000	1.20
  +++ build-docs.xml	1 Mar 2002 18:11:26 -0000	1.21
  @@ -181,8 +181,14 @@
         toolboxfile="${docs.src}/toolbox.props"
         style="${docs.src}/stylesheets/site.dvsl"
         excludes="**/project.xml,**/template.xml"
  -      includes="**/*.xml"
  -    />
  +      includes="**/*.xml">
  +      <!-- Need to add the maven jar to load the toolbox -->
  +      <classpath>
  +        <path refid="classpath"/>
  +        <path refid="maven-classpath"/>
  +      </classpath>
  +    </dvsl>
  +
       <!-- Then transform user supplied xdocs next -->
       <dvsl
         basedir="${docs.src}"
  @@ -192,8 +198,14 @@
         toolboxfile="${docs.src}/toolbox.props"
         style="${docs.src}/stylesheets/site.dvsl"
         excludes="**/project.xml,**/template.xml"
  -      includes="**/*.xml"
  -    />
  +      includes="**/*.xml">
  +      <!-- Need to add the maven jar to load the toolbox -->
  +      <classpath>
  +        <path refid="classpath"/>
  +        <path refid="maven-classpath"/>
  +      </classpath>
  +    </dvsl>
  +
       <copy todir="${docs.dest}/images" filtering="no">
         <fileset dir="${docs.src}/images">
           <include name="**/*.gif"/>
  
  
  
  1.5       +22 -7     jakarta-turbine-maven/src/templates/build/build-metrics.xml
  
  Index: build-metrics.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/build-metrics.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- build-metrics.xml	27 Feb 2002 17:02:56 -0000	1.4
  +++ build-metrics.xml	1 Mar 2002 18:11:26 -0000	1.5
  @@ -66,19 +66,34 @@
     <target 
       name="jdepend-xml" 
       depends="init,compile">
  +
  +    <taskdef name="dvsl" classname="org.apache.tools.dvsl.DVSLTask">
  +      <classpath>
  +        <path refid="classpath"/>
  +      </classpath>
  +    </taskdef>
  +
       <java 
         classname="jdepend.xmlui.JDepend" 
         fork="yes" 
         failonerror="yes">
  -      <arg line="-file ${build.dir}/jdepend-report.xml ${build.dest}"/>
  +      <arg line="-file ${build.dir}/jdepend-raw-report.xml ${build.dest}"/>
         <classpath refid="classpath"/>
       </java>
  -    <!-- Use XSLT to transform until the DVSL stylesheet is completed -->
  -    <style 
  -      basedir="${build.dir}" 
  -      destdir="${docs.dest}"
  -      includes="jdepend-report.xml" 
  -      style="${docs.src}/stylesheets/jdepend.xsl"/>
  +
  +    <dvsl
  +      basedir="."
  +      style="${docs.src}/stylesheets/jdepend.dvsl"
  +      toolboxfile="${docs.src}/toolbox.props"
  +      in="${build.dir}/jdepend-raw-report.xml"
  +      out="${gen.docs}/jdepend-report.xml">
  +      <!-- Need to add the maven jar to load the toolbox -->
  +      <classpath>
  +        <path refid="classpath"/>
  +        <path refid="maven-classpath"/>
  +      </classpath>
  +    </dvsl>
  +
     </target>
   
   </project>
  
  
  
  1.2       +3 -1      jakarta-turbine-maven/xdocs/toolbox.props
  
  Index: toolbox.props
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/xdocs/toolbox.props,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- toolbox.props	23 Feb 2002 17:10:31 -0000	1.1
  +++ toolbox.props	1 Mar 2002 18:11:26 -0000	1.2
  @@ -1,4 +1,6 @@
   toolbox.contextname = toolbox
   toolbox.tool.htmlescape = org.apache.velocity.anakia.Escape
  -
  +toolbox.tool.numbers = org.apache.commons.lang.Numbers
  +toolbox.tool.strings = org.apache.commons.lang.Strings
  +toolbox.tool.formatter = org.apache.maven.DVSLFormatter
   
  
  
  
  1.1                  jakarta-turbine-maven/xdocs/stylesheets/jdepend.dvsl
  
  Index: jdepend.dvsl
  ===================================================================
  #######################################################################
  ## J D E P E N D    D V S L    S T Y L E S H E E T                   ##
  #######################################################################
  ##
  ## This stylesheet is used to transform the output of JDepend's xml
  ## generator.  The XML is transformed into a standard xdoc that can
  ## then be transformed (yet again) using whatever stylesheet is used
  ## to format one's site.
  ##
  ## Version: $Id: jdepend.dvsl,v 1.1 2002/03/01 18:11:26 kaz Exp $
  
  #######################################################################
  ## V E L O C I T Y    M A C R O S                                    ##
  #######################################################################
  
  ## Prints a standard section header with the addition of some links
  ## that can be used for navigation in the document.
  ##
  #macro (section $title)
      <section name="$title">
        <p>
          [<a href="#Summary">summary</a>]
          [<a href="#Packages">packages</a>]
          [<a href="#Cycles">cycles</a>]
          [<a href="#Explanations">explanations</a>]
        </p>
  #end
  
  ## Used to print the abstract and concrete classes that a package
  ## contains.  Also removes the leading package information from 
  ## the fully qualified class (to conserve screen space).  Also, 
  ## creates a link to the xref sources so users can quickly navigate
  ## the code.
  ##
  #macro (classes $currentNode $xpath)
      #if (! $currentNode.get($xpath))
          <i>None</i>
      #end
      #foreach ($class in $currentNode.selectNodes($xpath))
          #set ($index = $class.value().lastIndexOf('.'))
          #set ($index = $index + 1)
          #set ($dir = $context.toolbox.strings.replace($class.value(), ".", "/"))
          <a href="xref/${dir}.html">$class.value().substring($index)</a><br/>
      #end
  #end
  
  ## Used to print the "used" and "used by" packages.  Also, creates a
  ## link to the appropriate package in the report.  
  ##
  #macro (packages $currentNode $xpath)
      #if (! $currentNode.get($xpath))
          <i>None</i>
      #end
      #foreach ($class in $currentNode.selectNodes($xpath))
          <a href="#${class.value()}">$class.value()</a><br/>
      #end
  #end
  
  ## Convert a string that represents a decimal as a percentage.
  ##
  #macro (percent $string)
      #set ($double = $context.toolbox.numbers.createDouble($string))
      $context.toolbox.formatter.formatPercentage($double)
  #end
  
  #######################################################################
  ## T E M P L A T E    D E F I N I T I O N S                          ## 
  ####################################################################### 
  
  ## Matches the root element of the JDepend XML report.
  ##
  #match ("JDepend")
  <?xml version="1.0"?>
  <document>
  
    <properties>
      <title>JDepend Source Code Analysis</title>
    </properties>
  
    <body>
      ###################################################################
      #section ("Metric Results")
      <p>
        The following document contains the results of a <a
        href="http://www.clarkware.com/software/JDepend.html">JDepend</a>
        metric analysis.  The various metrics are defined at the bottom
        of this document.
      </p>
      </section>
  
      ###################################################################
      #section ("Summary")	
      <table>
        <tr>
          <th>Package</th>
          <th><font size="-1">Total<br/>Classes</font></th>
          <th><font size="-1">Abstract<br/>Classes</font></th>
          <th><font size="-1">Concrete<br/>Classes</font></th>
          <th><font size="-1">Afferent<br/>Couplings</font></th>
          <th><font size="-1">Efferent<br/>Couplings</font></th>
          <th><font size="-1">Abstractness</font></th>
          <th><font size="-1">Instability</font></th>
          <th><font size="-1">Distance</font></th>
        </tr>
  
      #foreach ($package in $node.selectNodes("./Packages/Package"))
          #if (! $package.get("error"))
        <tr>
          <td>
            <a href="#$package.attribute("name")">$package.attribute("name")</a>
          </td>
          <td align="right">$package.valueOf("Stats/TotalClasses")</td>
          <td>$package.valueOf("Stats/AbstractClasses")</td>
          <td>$package.valueOf("Stats/ConcreteClasses")</td>
          <td>$package.valueOf("Stats/Ca")</td>
          <td>$package.valueOf("Stats/Ce")</td>
          <td>#percent ($package.valueOf("Stats/A"))</td>
          <td>#percent ($package.valueOf("Stats/I"))</td>
          <td>#percent ($package.valueOf("Stats/D"))</td>
        </tr>
          #end
      #end
  
      #foreach ($package in $node.selectNodes("./Packages/Package"))
          #if ($package.get("error"))
        <tr>
          <td colspan="1">$package.attribute("name")</td>
          <td colspan="8">$package.valueOf("error")</td>
        </tr>
          #end
      #end
      </table>
      </section>
  
      ###################################################################
      #section ("Packages")
  
      #foreach ($package in $node.selectNodes("./Packages/Package"))
          #if (! $package.get("error"))
        <subsection name="${package.attribute('name')}">
          <table>
            <tr>
              <th>Afferent Couplings</th>
              <th>Efferent Couplings</th>
              <th>Abstractness</th>
              <th>Instability</th>
              <th>Distance</th>
            </tr>
            <tr>
              <td>$package.valueOf("Stats/Ca")</td>
              <td>$package.valueOf("Stats/Ce")</td>
              <td>#percent ($package.valueOf("Stats/A"))</td>
              <td>#percent ($package.valueOf("Stats/I"))</td>
              <td>#percent ($package.valueOf("Stats/D"))</td>
            </tr>
          </table>
  
          <table>
            <tr>
              <th>Abstract Classes</th>
              <th>Concrete Classes</th>
              <th>Used by Packages</th>
              <th>Uses Packages</th>
            </tr>
            <tr>
              <td>#classes ($package "AbstractClasses/Class")</td>
              <td>#classes ($package "ConcreteClasses/Class")</td>
              <td>#packages ($package "UsedBy/Package")</td>
              <td>#packages ($package "DependsUpon/Package")</td>
            </tr>
          </table>
        </subsection>
          #end
      #end
      </section>
  
      ###################################################################
      #section ("Cycles")
  
      #if (! $node.get("Cycles/Package"))
        <p>There are no cyclic dependancies.</p>
  
      #else
        <table>
          <tr>
            <th>Package</th>
            <th>Cyclic Dependencies</th>
          </tr>
          
          #foreach ($cycle in $node.selectNodes("./Cycles/Package"))
          <tr> 
            <td>$cycle.attribute('Name')</td>
            <td>
            #foreach ($package in $cycle.selectNodes("Package"))
              $package.value()<br/>
            #end
            </td>
          </tr>
          #end
        </table>
      #end
      </section>
  
      ###################################################################
      #section ("Explanations")
  
      <p>
        The following explanations are for quick reference and are
        lifted directly from the original <a
        href="http://www.clarkware.com/software/JDepend.html">JDepend
        documentation</a>.
      </p>
      
      <table>
        <tr>
          <th>Term</th>
          <th>Description</th>
        </tr>
        <tr>
          <td>Number of Classes</td>
          <td>
            The number of concrete and abstract classes (and interfaces)
            in the package is an indicator of the extensibility of the
            package.
          </td>
        </tr>
        <tr>
          <td>Afferent Couplings</td>
          <td>
            The number of other packages that depend upon classes within
            the package is an indicator of the package's responsibility.
          </td>
        </tr>
        <tr>
          <td>Efferent Couplings</td>
          <td>
            The number of other packages that the classes in the package
            depend upon is an indicator of the package's independence.
          </td>
        </tr>
        <tr>
          <td>Abstractness</td> 
          <td>
            The ratio of the number of abstract classes (and interfaces)
            in the analyzed package to the total number of classes in
            the analyzed package.  The range for this metric is 0 to 1,
            with A=0 indicating a completely concrete package and A=1
            indicating a completely abstract package.
          </td>
        </tr>
        <tr>
          <td>Instability</td>
          <td>
            The ratio of efferent coupling (Ce) to total coupling (Ce /
            (Ce + Ca)). This metric is an indicator of the package's
            resilience to change.  The range for this metric is 0 to 1,
            with I=0 indicating a completely stable package and I=1
            indicating a completely instable package.
          </td>
        </tr>
        <tr>
          <td>Distance</td>
          <td>
            The perpendicular distance of a package from the idealized
            line A + I = 1. This metric is an indicator of the package's
            balance between abstractness and stability.  A package
            squarely on the main sequence is optimally balanced with
            respect to its abstractness and stability. Ideal packages
            are either completely abstract and stable (x=0, y=1) or
            completely concrete and instable (x=1, y=0).  The range for
            this metric is 0 to 1, with D=0 indicating a package that is
            coincident with the main sequence and D=1 indicating a
            package that is as far from the main sequence as possible. 
          </td>
        </tr>
        <tr>
          <td>Cycles</td>
          <td>
            Packages participating in a package dependency cycle are in
            a deadly embrace with respect to reusability and their
            release cycle. Package dependency cycles can be easily
            identified by reviewing the textual reports of dependency
            cycles. Once these dependency cycles have been identified
            with JDepend, they can be broken by employing various
            object-oriented techniques.
          </td>
        </tr>
      </table>
      </section>
  
    </body>
  </document>
  #end
  
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-maven/xdocs/stylesheets jdepend.dvsl jdepend.xsl

Posted by Pete Kazmier <pe...@kazmier.com>.
If anyone is interested in seeing the below changes, I've updated the
Maven site (http://jakarta.apach.org/turbine/maven).  I also forgot to
mention that I also added links from any classes mentioned in the metric
report to the corresponding cross-referenced source code unifying the
site even further.

On Fri, Mar 01, 2002 at 06:11:26PM -0000, kaz@apache.org wrote:
>   - The output of the DVSL stylesheet is not HTML, but rather an xdoc that
>     is then transformed to HTML when the rest of the documentation is
>     built.  Consequently, the new metric page *looks* like the rest of the
>     site (jakarta style).

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>