maven-plugins/html2xdoc/plugin.jelly
jstrachan 4f0f367def Initial version of a plugin which can take HTML and turn it into the xdoc format ready for styling by the xdoc plugin.
This allows developers to use good old HTML (and some WYSIWYG tool) to edit & maintain documentation and get it included in the same site documentation as all the xdoc stuff


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113056 13f79535-47bb-0310-9956-ffa450edef68
2003-03-06 19:15:11 +00:00

88 lines
3.1 KiB
XML

<?xml version="1.0"?>
<project
xmlns:j="jelly:core"
xmlns:x="jelly:xml"
xmlns:html="jelly:html"
xmlns:maven="jelly:maven"
xmlns:log="jelly:log"
xmlns:util="jelly:util"
xmlns:doc="doc"
xmlns:m="maven">
<goal name="html2xdoc" prereqs="xdoc:init"
description="Generates XDoc documentation from normal HTML files">
<j:set var="destdir" value="${maven.gen.docs}"/>
<j:if test="${empty(destdir)}">
<j:set var="destdir" value="${maven.build.dir}/generated-xdocs"/>
</j:if>
<j:set var="srcdir" value="${maven.html2xdoc.dir}"/>
<j:if test="${empty(srcdir)}">
<j:set var="srcdir" value="${basedir}/xdocs"/>
</j:if>
<j:set var="outputencoding" value="${maven.docs.outputencoding}"/>
<!-- tool for converting HTML into XDoc -->
<j:useBean class="org.apache.maven.html2xdoc.Html2XdocBean" var="htmlTool"/>
<!-- mapper for determining output file name -->
<j:new var="mapper" className="org.apache.maven.util.CaseInsensitiveGlobPatternMapper"/>
<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()}"/>
<util:replace var="fromPattern" oldChar="\" newChar="/" value="${srcdir}/*.html"/>
<util:replace var="toPattern" oldChar="\" newChar="/" value="${destdir}/*.xml"/>
<j:setProperties object="${mapper}" from="${fromPattern}" to="${toPattern}"/>
<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}"/>
<fileScanner var="docFiles">
<fileset dir="${srcdir}">
<patternset>
<include name="**/*.html"/>
</patternset>
</fileset>
</fileScanner>
<j:forEach var="file" items="${docFiles.iterator()}">
<util:replace var="inDirForward" oldChar="\" newChar="/" value="${file.parent}"/>
<j:set var="outDir" value="${dirMapper.mapFileName(inDirForward).0}"/>
<mkdir dir="${outDir}"/>
<!-- 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>
<!-- parse the HTML doc and pass it to the stylesheet -->
<html:parse var="htmlDoc" html="${file}" element="lower" attribute="lower"/>
<!-- now lets convert the document into XML -->
<j:set var="xmlDoc" value="${htmlTool.convert(htmlDoc)}"/>
<j:file name="${outFile}" encoding="${outputencoding}"
omitXmlDeclaration="true" outputMode="xml"
prettyPrint="true">
<x:copyOf select="$xmlDoc"/>
</j:file>
</j:forEach>
</goal>
</project>