dion        2003/10/09 17:04:08

  Modified:    src/plugins-build/faq plugin.jelly
  Added:       src/plugins-build/faq/src/plugin-test .cvsignore project.xml
                        maven.xml
               src/plugins-build/faq plugin.properties
               src/plugins-build/faq/src/plugin-test/xdocs faq.fml faq2.fml
  Log:
  Apply MAVEN-904 with some changes for reporting.
  Add a test project to test new functionality.
  
  Revision  Changes    Path
  1.1                  maven/src/plugins-build/faq/src/plugin-test/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  *.log
  target
  
  
  
  1.1                  maven/src/plugins-build/faq/src/plugin-test/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <project>
    <pomVersion>3</pomVersion>
    <id>test-maven-faq-plugin</id>
    <name>Test project for Maven Faq Plugin</name>
    <groupId>maven</groupId>
    <currentVersion>1.0-SNAPSHOT</currentVersion>
    <organization>
      <name>Apache Software Foundation</name>
      <url>http://www.apache.org/</url>
      <logo>http://maven.apache.org/images/jakarta-logo-blue.gif</logo>
    </organization>
    <inceptionYear>2001</inceptionYear>
    <package>org.apache.maven</package>
    <logo>http://maven.apache.org/images/maven.jpg</logo>
    <description>Test for Maven Faq plugin</description>
    <shortDescription>Test for Maven Faq plugin</shortDescription>
    <url>http://maven.apache.org/reference/plugins/faq/</url>
    <siteDirectory>/www/maven.apache.org/reference/plugins/faq/</siteDirectory>
    <repository>
      <connection>scm:cvs:pserver:[EMAIL 
PROTECTED]:/home/cvspublic:maven/src/plugins-build/faq/</connection>
      <url>http://cvs.apache.org/viewcvs/maven/src/plugins-build/faq/</url>
    </repository>
    <developers>
      <developer>
        <name>dIon Gillard</name>
        <id>dion</id>
        <email>[EMAIL PROTECTED]</email>
        <organization>Multitask Consulting</organization>
        <roles>
          <role>Documentation</role>
        </roles>
      </developer>
    </developers>
  
    <build>
    </build>
    
    <reports>
      <report>maven-faq-plugin</report>
    </reports>
  </project>
  
  
  
  1.1                  maven/src/plugins-build/faq/src/plugin-test/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project xmlns:util="jelly:util"
           xmlns:j="jelly:core">
           
    <goal name="testPlugin" prereqs="clean,test-faq">
      <!-- bad xdoc leaves files open <attainGoal name="clean"/> -->
    </goal>
    
    <goal name="test-faq">
      <attainGoal name="site"/>
  
      <j:set var="expectedFile" 
        value="${maven.docs.dest}/faq.html"/>
      <util:file var="file" name="${expectedFile}" />
      <j:if test="${!(file.exists())}">
        <fail>${expectedFile} not generated</fail>
      </j:if>
  
      <j:set var="expectedFile" 
        value="${maven.docs.dest}/faq2.html"/>
      <util:file var="file" name="${expectedFile}" />
      <j:if test="${!(file.exists())}">
        <fail>${expectedFile} not generated</fail>
      </j:if>
  
    </goal>
  </project>
  
  
  1.11      +89 -53    maven/src/plugins-build/faq/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/faq/plugin.jelly,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- plugin.jelly      29 Aug 2003 06:27:54 -0000      1.10
  +++ plugin.jelly      10 Oct 2003 00:04:08 -0000      1.11
  @@ -5,58 +5,71 @@
     xmlns:util="jelly:util"
     xmlns:x="jelly:xml"
     xmlns:ant="jelly:ant"
  -  xmlns:doc="doc">
  +  xmlns:define="jelly:define"
  +  xmlns:doc="doc"
  +  xmlns:faq="faq">
  +
  +  <define:taglib uri="faq">
  +
  +    <!-- 
  +      Transforms *.fml files into *.xml xdoc files.
  +        parameters:
  +           srcdir:  directory where to find *.fml files under
  +           destdir: directory where to produce output xdoc xml files
  +      -->
  +    <define:tag name="performTransformation">
  +      <!-- NOTE: part of this tag implementation is based on jelly-code from 
xdoc-plugin -->
  +
  +      <util:file var="srcdirFile" name="${srcdir}"/>
  +      <j:set var="srcdir" value="${srcdirFile.getCanonicalPath()}"/>
  +      <util:file var="destdirFile" name="${destdir}"/>
  +      <j:set var="destdir" value="${destdirFile.getCanonicalPath()}"/>
  +
  +      <!-- construct a mapper, which is to help map input files to output path -->
  +      <util:replace var="fromPattern" oldChar="\" newChar="/" 
value="${srcdir}/*.fml"/>
  +      <util:replace var="toPattern" oldChar="\" newChar="/" 
value="${destdir}/*.xml"/>
  +      <j:if test="${mapper == null}">
  +        <j:new var="mapper" 
className="org.apache.maven.util.CaseInsensitiveGlobPatternMapper"/>
  +      </j:if>
  +      <j:setProperties object="${mapper}" from="${fromPattern}" to="${toPattern}"/>
  +
  +      <!-- construct a mapper, which is to help map input dirs to output dirs (so 
we can create output paths) -->
  +      <util:replace var="fromDirPattern" oldChar="\" newChar="/" 
value="${srcdir}*"/>
  +      <util:replace var="toDirPattern" oldChar="\" newChar="/" value="${destdir}*"/>
  +      <j:new var="dirMapper" 
className="org.apache.maven.util.CaseInsensitiveGlobPatternMapper"/>
  +      <j:setProperties object="${dirMapper}" from="${fromDirPattern}" 
to="${toDirPattern}"/>
  +
  +      <!-- scan for all .fml faq source files -->
  +      <ant:fileScanner var="faqFilenames">
  +        <ant:fileset dir="${srcdir}">
  +          <ant:patternset>
  +            <ant:include name="**/*.fml"/>
  +          </ant:patternset>
  +        </ant:fileset>
  +      </ant:fileScanner>
  +
  +      <j:set var="outputencoding" value="${maven.docs.outputencoding}"/>
  +
  +      <!-- loop each found .fml file and produce output .xml xdocs file -->
  +      <j:forEach var="faqFile" items="${faqFilenames.iterator()}">
  +        <!-- first, create the relative output-dir into the destdir -->
  +        <!-- e.g.: if source file is "xdocs/faqs/foofaq.fml" we need to create 
"target/generated-xdocs/faqs" -->
  +        <util:replace var="inDirForward" oldChar="\" newChar="/" 
value="${faqFile.parent}"/>
  +        <j:set var="outDir" value="${dirMapper.mapFileName(inDirForward).0}"/>
  +        <mkdir dir="${outDir}"/>
  +
  +        <!-- generate output file name -->
  +        <util:replace var="outFileForward" oldChar="\" newChar="/" 
value="${faqFile.toString()}"/>
  +        <j:set var="outFile" value="${mapper.mapFileName(outFileForward).0}"/>
  +
  +        <echo>Generating ${outFile} from ${faqFile}</echo>
  +
  +        <!-- xml-parse .fml faq file -->
  +        <x:parse var="doc" xml="${faqFile}"/>
  +        <x:set var="root" select="$doc/*"/>
   
  -  <goal name="maven-faq-plugin:register">
  -    <doc:registerReport
  -      name="FAQs"
  -      pluginName="faq"
  -      description="Frequently Asked Questions."
  -      link="faq"/>
  -  </goal>
  -
  -  <goal name="maven-faq-plugin:deregister">
  -    <doc:deregisterReport name="FAQs"/>
  -  </goal>
  -
  -  <goal name="faq:report" 
  -    description="Generate FAQs">
  -      <attainGoal name="faq"/>
  -  </goal>
  -
  -  <!--
  -   | @TODO: Make this a tag and transform multiple *.fml files
  -   -->
  -  <goal name="faq"
  -    description="Generates an FAQ xdoc file from an FAQ XML document">
  -
  -    <j:set var="destfile" value="${maven.faq.dest.file}"/>
  -    <j:if test="${empty(destfile)}">
  -      <j:set var="destfile" value="${maven.build.dir}/generated-xdocs/faq.xml"/>
  -    </j:if>
  -
  -    <ant:mkdir dir="${maven.build.dir}/generated-xdocs"/>
  -        
  -    <j:set var="srcfile" value="${maven.faq.src.file}"/>
  -    <j:if test="${empty(srcfile)}">
  -      <j:set var="srcfile" value="${basedir}/xdocs/faq.fml"/>
  -    </j:if>
  -    
  -    <util:file var="srcfileFile" name="${srcfile}"/>
  -    <j:set var="srcfile" value="${srcfileFile.canonicalPath}"/>
  -    <util:file var="destfileFile" name="${destfile}"/>
  -    <j:set var="destfile" value="${destfileFile.canonicalPath}"/>
  -        
  -    <j:set var="outputencoding" value="${maven.docs.outputencoding}"/>
  -
  -    <util:available file="${srcfile}">
  -      <j:set var="srcFileExists" value="true" />
  -    </util:available>
  -    <j:if test="${srcFileExists == 'true'}">
  -      <x:parse var="doc" xml="${srcfileFile}"/>    
  -      <x:set var="root" select="$doc/*"/>
  -
  -      <j:file name="${destfile}" encoding="${outputencoding}" outputMode="xml">
  +        <!-- produce a output xdoc xml file from parsed .fml source -->
  +        <j:file name="${outFile}" encoding="${outputencoding}" outputMode="xml">
   <document>
   
     <properties>
  @@ -102,8 +115,31 @@
       </x:forEach>
     </body>
   </document>
  -      </j:file>
  -    </j:if>
  +        </j:file>
  +      </j:forEach>
  +    </define:tag>
  +
  +  </define:taglib>
  +
  +  <goal name="maven-faq-plugin:register">
  +    <doc:registerReport
  +      name="FAQs"
  +      pluginName="maven-faq-plugin"
  +      description="Frequently Asked Questions."
  +      link="faq"/>
  +  </goal>
  +
  +  <goal name="maven-faq-plugin:deregister">
  +    <doc:deregisterReport name="FAQs"/>
  +  </goal>
  +
  +  <goal name="maven-faq-plugin:report" 
  +    description="Generate FAQs">
  +      <attainGoal name="faq"/>
  +  </goal>
  +
  +  <goal name="faq" description="Generates FAQ xdoc files from FAQ XML documents">
  +      <faq:performTransformation srcdir="${maven.faq.src}" 
destdir="${maven.faq.dest}" />
     </goal>
   
   </project>
  
  
  
  1.1                  maven/src/plugins-build/faq/plugin.properties
  
  Index: plugin.properties
  ===================================================================
  # Where source *.fml files are looked for
  maven.faq.src=${basedir}/xdocs
  
  # Destination directory where output xdocs file are produced
  maven.faq.dest=${maven.build.dir}/generated-xdocs
  
  
  
  1.1                  maven/src/plugins-build/faq/src/plugin-test/xdocs/faq.fml
  
  Index: faq.fml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <faqs title="Frequently Asked Questions">
  
    <part id="general">
      <title>General</title>
     
      <faq id="whats-foo">
        <question>
          What is Foo?
        </question>
        <answer>
          <p>some markup goes here</p>
          
          <source>some source code</source>
          
          <p>some markup goes here</p>
        </answer>
      </faq>
  
      <faq id="whats-bar">
        <question>
          What is Bar?
        </question>
        <answer>
          <p>some markup goes here</p>
        </answer>
      </faq>
    </part>
    
    <part id="install">
      <title>Installation</title>
     
      <faq id="how-install">
        <question>
          How do I install Foo?
        </question>
        <answer>
          <p>some markup goes here</p>
        </answer>
      </faq>
    </part>  
  </faqs>
  
  
  1.1                  maven/src/plugins-build/faq/src/plugin-test/xdocs/faq2.fml
  
  Index: faq2.fml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <faqs title="Frequently Asked Questions">
  
    <part id="general">
      <title>General</title>
     
      <faq id="whats-foo">
        <question>
          What is Foo?
        </question>
        <answer>
          <p>some markup goes here</p>
          
          <source>some source code</source>
          
          <p>some markup goes here</p>
        </answer>
      </faq>
  
      <faq id="whats-bar">
        <question>
          What is Bar?
        </question>
        <answer>
          <p>some markup goes here</p>
        </answer>
      </faq>
    </part>
    
    <part id="install">
      <title>Installation</title>
     
      <faq id="how-install">
        <question>
          How do I install Foo?
        </question>
        <answer>
          <p>some markup goes here</p>
        </answer>
      </faq>
    </part>  
  </faqs>
  
  

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

Reply via email to