You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by js...@apache.org on 2002/12/11 17:45:59 UTC

cvs commit: jakarta-turbine-maven/src/plugins-build/xdoc plugin.jelly site.jsl

jstrachan    2002/12/11 08:45:59

  Modified:    src/plugins-build/xdoc plugin.jelly site.jsl
  Log:
  Patched the JSL implementation of xdoc so that JSL is now an alternative to DVSL
  
  To enable JSL for now you need to define this property
  
  maven.xdoc.useJSL=true
  
  Then it will use JSL rather than DVSL
  
  Revision  Changes    Path
  1.28      +103 -61   jakarta-turbine-maven/src/plugins-build/xdoc/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/xdoc/plugin.jelly,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- plugin.jelly	8 Dec 2002 14:32:33 -0000	1.27
  +++ plugin.jelly	11 Dec 2002 16:45:59 -0000	1.28
  @@ -140,7 +140,7 @@
   
     <!-- transform maven generated docs -->
     <goal name="xdoc:transform-docs"
  -    description="Transform the auto-generated xdocs">
  +    description="Transform the auto-generated xdocs using DVSL">
       
       <!-- Transform the auto-generated xdocs first -->
       <j:if test="${maven.gen.docs.available}">
  @@ -301,7 +301,7 @@
     <!-- ================================================================== -->
   
     <goal name="xdoc:transform"
  -        prereqs="init-dvsl-tag,xdoc:init"
  +        prereqs="xdoc:init"
           description="Generate html project documentation xdoc sources">
       
       <!-- This is busted
  @@ -312,12 +312,27 @@
       </j:if>
       -->
   
  -    <attainGoal name="xdoc:transform-docs" />
  -    <attainGoal name="xdoc:copy-resources" />
  -    <!-- allow user overrides and extra docs/resources -->
  -    <attainGoal name="xdoc:transform-user-docs" />
  -    <attainGoal name="xdoc:copy-user-resources" />
  -
  +		<j:choose>
  +			<j:when test="${maven.xdoc.useJSL}">
  +				<echo>Using Jelly to create the documentation</echo>
  +				
  +				<!-- use JSL in Jelly to build the documenation -->
  +				<attainGoal name="xdoc:copy-resources" />
  +				<attainGoal name="xdoc:copy-user-resources" />
  +				<attainGoal name="xdoc:jelly-transform" />
  +			</j:when>
  +			<j:otherwise>
  +				
  +				<!-- use DVSL to build the documentation -->
  +				<attainGoal name="init-dvsl-tag" />
  +				<attainGoal name="xdoc:transform-docs" />
  +				<attainGoal name="xdoc:copy-resources" />
  +				<!-- allow user overrides and extra docs/resources -->
  +				<attainGoal name="xdoc:transform-user-docs" />
  +				<attainGoal name="xdoc:copy-user-resources" />
  +			</j:otherwise>
  +		</j:choose>
  +			
     </goal>
   
     <!-- ================================================================== -->
  @@ -359,6 +374,64 @@
           </j:if>
         </define:tag>
   
  +			<!-- Generates the JSL files on the given srcdir attribute -->
  +			<define:tag name="performJSL">
  +
  +				<util:replace var="fromPattern" oldChar="\" newChar="/" value="${srcdir}/*.xml"/>
  +				<util:replace var="toPattern" oldChar="\" newChar="/" value="${maven.docs.dest}/*.html"/>
  +		
  +				<j:setProperties object="${mapper}" from="${fromPattern}" to="${toPattern}" />
  +				
  +				<fileScanner var="docFiles">
  +					<fileset dir="${srcdir}">
  +						<patternset>
  +							<exclude name="**/project.xml" />
  +							<exclude name="**/template.xml" />
  +							<exclude name="**/navigation.xml" />
  +							<include name="**/*.xml"/>
  +						</patternset>
  +					</fileset>
  +				</fileScanner>
  +		
  +				<j:forEach var="file" items="${docFiles.iterator()}">
  +					<!-- generate output file name -->
  +					<util:replace var="outFileForward" oldChar="\" newChar="/" value="${file.toString()}"/>      
  +					<j:set var="outFiles" value="${mapper.mapFileName(outFileForward)}" />
  +					<j:set var="outFile" value="${outFiles[0]}" />
  +		
  +					<echo>Generating ${outFile} from ${file}</echo>
  +					<!-- work out relative path -->
  +					<util:replace var="docsForward" oldChar="\" newChar="/" value="${srcdir}"/>
  +					<j:set var="relativePath" value="${pathTool.getRelativePath(docsForward, outFileForward)}"/>
  +		
  +					<util:available file="${file.parentFile.absoluteFile}/navigation.xml">
  +						<j:set var="navFile" value="${file.parentFile.absoluteFile}/navigation.xml" />
  +					</util:available>
  +
  +					<!-- determine nav file to be used -->
  +					<util:available file="${maven.docs.src}/stylesheets/project.xml">
  +						<j:set var="navFile" value="${maven.docs.src}/stylesheets/project.xml" />
  +					</util:available>
  +					<util:available file="${maven.docs.src}/project.xml">
  +						<j:set var="navFile" value="${maven.docs.src}/project.xml" />
  +					</util:available>
  +					<util:available file="${maven.docs.src}/navigation.xml">
  +						<j:set var="navFile" value="${maven.docs.src}/navigation.xml" />
  +					</util:available>
  +						
  +		
  +					<!-- parse nav and make it available to the stylesheet -->
  +					<x:parse var="navXML" xml="${navFile}" />
  +					<x:set var="nav" select="$navXML/project" />
  +					<!-- parse the doc and pass it to the stylesheet -->      
  +					<x:parse var="doc" xml="${file.toURL()}" />
  +					
  +					<j:file name="${outFile}" encoding="${outputencoding}">
  +						<j:include uri="${stylesheet.toString()}" />
  +					</j:file>        
  +				</j:forEach>
  +
  +			</define:tag>
       </define:taglib>
     </goal>
            
  @@ -370,65 +443,34 @@
   
       <!-- need to parse navigation into $nav -->
     
  -    <fileScanner var="docFiles">
  -      <fileset dir="${maven.docs.src}">
  -        <patternset>
  -          <exclude name="**/project.xml" />
  -          <exclude name="**/template.xml" />
  -          <exclude name="**/navigation.xml" />
  -          <include name="**/*.xml"/>
  -        </patternset>
  -      </fileset>
  -    </fileScanner>
  -
  -    <!-- all this replace'ing is for the mapper's benefit - it treats 
  -    / and \ as different chars -->  
  -    <util:replace var="fromPattern" oldChar="\" newChar="/" value="${maven.docs.src}/*.xml"/>
  -    <util:replace var="toPattern" oldChar="\" newChar="/" value="${maven.docs.dest}/*.html"/>
  -
       <!-- mapper for determining output file name -->
       <j:new var="mapper" className="org.apache.tools.ant.util.GlobPatternMapper" />
  -    <j:setProperties object="${mapper}" from="${fromPattern}" to="${toPattern}" />
   
  -    <!-- path tool for relative processing -->
  -    <j:new var="pathTool" className="org.apache.maven.DVSLPathTool" />
   
  +    <!-- path tool for relative processing -->
  +    <j:useBean var="pathTool" class="org.apache.maven.DVSLPathTool" />
   
  -    <j:forEach var="file" items="${docFiles.iterator()}">
  -      <!-- generate output file name -->
  -      <util:replace var="outFileForward" oldChar="\" newChar="/" value="${file.toString()}"/>
  -      <j:set var="outFiles" value="${mapper.mapFileName(outFileForward)}" />
  -      <j:set var="outFile" value="${outFiles[0]}" />
  -
  -      <echo>Generating ${outFile} from ${file}</echo>
  -      <!-- work out relative path -->
  -      <util:replace var="docsForward" oldChar="\" newChar="/" value="${maven.docs.src}"/>
  -      <j:set var="relativePath" value="${pathTool.getRelativePath(docsForward, outFileForward)}"/>
  -
  -      <!-- determine nav file to be used -->
  -      <util:available file="${maven.docs.src}/stylesheets/project.xml">
  -        <j:set var="navFile" value="${maven.docs.src}/stylesheets/project.xml" />
  -      </util:available>
  -      <util:available file="${maven.docs.src}/project.xml">
  -        <j:set var="navFile" value="${maven.docs.src}/project.xml" />
  -      </util:available>
  -      <util:available file="${maven.docs.src}/navigation.xml">
  -        <j:set var="navFile" value="${maven.docs.src}/navigation.xml" />
  -      </util:available>
  -      <util:available file="${file.parentFile.absoluteFile}/navigation.xml">
  -        <j:set var="navFile" value="${file.parentFile.absoluteFile}/navigation.xml" />
  -      </util:available>
  -
  -      <!-- parse nav and make it available to the stylesheet -->
  -      <x:parse var="navXML" xml="${navFile}" />
  -      <x:set var="nav" select="$navXML/project" />
  -      <!-- parse the doc and pass it to the stylesheet -->      
  -      <x:parse var="doc" xml="${file.toURL()}" />
  -      <j:file name="${outFile}" prettyPrint="true">
  -        <j:include uri="./site.jsl" />
  -      </j:file>        
  +		<!-- tool for loading resources from the class loader -->
  +		<j:useBean class="org.apache.maven.util.ResourceBean" var="resourceTool"/>
   
  -    </j:forEach>
  +		<!-- determine which stylesheet to use -->		
  +		<j:set var="stylesheet" value="${maven.xdoc.jsl}"/>
  +		<j:if test="${empty(stylesheet)}">
  +			<j:set var="stylesheet" value="${resourceTool.findResource('site.jsl')}"/>
  +			<j:if test="${empty(stylesheet)}">
  +				<log:warn>Could not load the JSL stylesheet 'site.jsl' on the classpath</log:warn>
  +				<j:set var="stylesheet" value="./site.jsl"/>
  +			</j:if>
  +		</j:if>
  +
  +		<log:info>About to use JSL stylesheet ${stylesheet}</log:info>
  +
  +		<!-- perform JSL on generated docs -->
  +		<jslXdoc:performJSL srcdir="${maven.gen.docs}"/>
  +			
  +		<!-- perform JSL on user provided docs -->
  +		<jslXdoc:performJSL srcdir="${maven.docs.src}"/>
  +		
     
     </goal>
    
  
  
  
  1.6       +25 -11    jakarta-turbine-maven/src/plugins-build/xdoc/site.jsl
  
  Index: site.jsl
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/xdoc/site.jsl,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- site.jsl	7 Dec 2002 20:38:32 -0000	1.5
  +++ site.jsl	11 Dec 2002 16:45:59 -0000	1.6
  @@ -315,7 +315,7 @@
         <jsl:template match="subsection">
           <div class="h4">
           <x:if select="@name">
  -          <j:set var="_sectionName"><x:expr select="@name"/></j:set>
  +          <j:set var="_sectionName" trim="false"><x:expr select="@name"/></j:set>
             <h4><a name="${_sectionName}">${_sectionName}</a></h4>
           </x:if>
           <jsl:applyTemplates select="*"/>
  @@ -336,22 +336,36 @@
         </jsl:template>
         
         <jsl:template match="tr">
  -        <jslXdoc:printRow />
  -          <j:set var="count" value="${1+count}"/>
  -          <jsl:applyTemplates select="*"/>
  -        <!-- FIXME what the hell does this do? -->
  -        <x:element name="/tr" />
  +				<x:element name="tr">
  +					<j:choose>
  +						<j:when test="${(count % 2) gt 0}">
  +							<x:attribute name="class">a</x:attribute>
  +						</j:when>
  +						<j:otherwise>
  +							<x:attribute name="class">b</x:attribute>
  +						</j:otherwise>
  +					</j:choose>
  +					
  +					<!-- copy attributes -->
  +					<x:forEach select="@*">
  +						<x:set var="attr" value="."/>
  +						<x:attribute name="${attr.name}">${attr.text}</x:attribute>
  +					</x:forEach>
  +					
  +					<j:set var="count" value="${1+count}"/>
  +					
  +					<jsl:applyTemplates select="*"/>
  +				</x:element>
         </jsl:template>
   
  -      <jsl:template match="p|a|@*">
  +			<!-- copy any other elements through -->
  +      <jsl:template match="*">
           <jsl:copy>
             <jsl:applyTemplates />
           </jsl:copy>
         </jsl:template>
   
  +			<!-- element values don't pass through as text -->
  +      <jsl:template match="@*"/>
         
  -<!--      <jsl:template match="text()">
  -        <jsl:copy select="." />
  -      </jsl:template>
  --->      
       </jsl:stylesheet>