You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by ep...@apache.org on 2003/11/24 20:38:46 UTC

cvs commit: maven-plugins/faq/xdocs changes.xml

epugh       2003/11/24 11:38:46

  Modified:    faq      plugin.jelly project.xml
               faq/xdocs changes.xml
  Log:
  Prevent FAQ plugin from crashing if there is no /xdocs directory.
  
  Revision  Changes    Path
  1.12      +94 -93    maven-plugins/faq/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/maven-plugins/faq/plugin.jelly,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- plugin.jelly	10 Oct 2003 00:04:08 -0000	1.11
  +++ plugin.jelly	24 Nov 2003 19:38:46 -0000	1.12
  @@ -19,104 +19,105 @@
         -->
       <define:tag name="performTransformation">
         <!-- NOTE: part of this tag implementation is based on jelly-code from xdoc-plugin -->
  +      <util:available file="${srcdir}">
  +        <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/*"/>
  +
  +          <!-- produce a output xdoc xml file from parsed .fml source -->
  +          <j:file name="${outFile}" encoding="${outputencoding}" outputMode="xml">
  +  <document>
  +
  +    <properties>
  +      <title><x:expr select="$root/title"/></title>
  +    </properties>
  +    <body>
  +      <section name="Frequently Asked Questions">
  +        <x:forEach select="$root/part">
  +          <p>
  +            <strong><x:expr select="title"/></strong>
  +          </p>
  +          <ol>
  +            <x:forEach select="faq">
  +            <li>
  +              <x:element name="a">
  +                <x:attribute name="href">#<x:expr select="@id"/></x:attribute>
  +                <x:copyOf select="question/node()"/>
  +              </x:element>
  +            </li>
  +            </x:forEach>
  +          </ol>
  +        </x:forEach>
  +      </section>
   
  -      <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/*"/>
  -
  -        <!-- produce a output xdoc xml file from parsed .fml source -->
  -        <j:file name="${outFile}" encoding="${outputencoding}" outputMode="xml">
  -<document>
  -
  -  <properties>
  -    <title><x:expr select="$root/title"/></title>
  -  </properties>
  -  <body>
  -    <section name="Frequently Asked Questions">
         <x:forEach select="$root/part">
  -        <p>
  -          <strong><x:expr select="title"/></strong>
  -        </p>
  -        <ol>
  +        <x:element name="section">
  +          <x:attribute name="name"><x:expr select="title"/></x:attribute>
  +
             <x:forEach select="faq">
  -          <li>
  -            <x:element name="a">
  -              <x:attribute name="href">#<x:expr select="@id"/></x:attribute>
  -              <x:copyOf select="question/node()"/>
  -            </x:element>
  -          </li>
  +            <dl>
  +              <dt>
  +                <x:element name="a">
  +                  <x:attribute name="name"><x:expr select="@id"/></x:attribute>
  +                  <x:copyOf select="question/node()"/>
  +                </x:element>
  +              </dt>
  +              <dd>
  +                  <x:copyOf select="answer/node()"/>
  +              </dd>
  +            </dl>
             </x:forEach>
  -        </ol>
  +        </x:element>
         </x:forEach>
  -    </section>
  -
  -    <x:forEach select="$root/part">
  -      <x:element name="section">
  -        <x:attribute name="name"><x:expr select="title"/></x:attribute>
  -        
  -        <x:forEach select="faq">
  -          <dl>
  -            <dt>
  -              <x:element name="a">
  -                <x:attribute name="name"><x:expr select="@id"/></x:attribute>
  -                <x:copyOf select="question/node()"/>
  -              </x:element>
  -            </dt>
  -            <dd>
  -                <x:copyOf select="answer/node()"/>
  -            </dd>
  -          </dl>
  -        </x:forEach>
  -      </x:element>
  -    </x:forEach>
  -  </body>
  -</document>
  -        </j:file>
  -      </j:forEach>
  +    </body>
  +  </document>
  +          </j:file>
  +        </j:forEach>
  +      </util:available>        
       </define:tag>
   
     </define:taglib>
  
  
  
  1.19      +9 -0      maven-plugins/faq/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/faq/project.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- project.xml	10 Oct 2003 00:05:39 -0000	1.18
  +++ project.xml	24 Nov 2003 19:38:46 -0000	1.19
  @@ -36,6 +36,15 @@
           <role>Developer</role>
         </roles>
       </developer>
  +    <developer>
  +      <name>Eric Pugh</name>
  +      <id>epugh</id>
  +      <email>epugh@upstate.com</email>
  +      <organization>Upstate</organization>
  +      <roles>
  +        <role>Java Developer</role>
  +      </roles>
  +    </developer>    
     </developers>
     <dependencies>
       <dependency>
  
  
  
  1.5       +3 -0      maven-plugins/faq/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/faq/xdocs/changes.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- changes.xml	28 Oct 2003 00:05:19 -0000	1.4
  +++ changes.xml	24 Nov 2003 19:38:46 -0000	1.5
  @@ -7,6 +7,9 @@
   
     <body>
       <release version="1.2" date="in CVS">
  +      <action dev="epugh" type="fix">
  +        Only run when an xdocs directory exists.
  +      </action>    
         <action dev="dion" type="fix">
           Fix MAVEN-973. xdocs source hardcoded.
         </action>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org