<?xml version="1.0" encoding="UTF-8"?>

<!--
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->

<project name="tobago-doc-reference" default="generate-html">

  <property name="build-system.home" value="../../tool/build-system"/>
  <property name="build-system.dir" location="${build-system.home}"/>
  <import file="${build-system.dir}/build-basic.xml"/>

  <!-- overwrite these properties in your build.properties file -->
  <property name="saxon.jar" value="tool/saxon-6.5.3.jar"/>
  <property name="docbook.dir" value="tool/docbook/docbook-xsl-1.68.1"/>

  <property name="docbook.saxon-extension.jar"
            value="${docbook.dir}/extensions/saxon653.jar"/>

  <target name="sniplet-extract" depends="init-apt">
    <mkdir dir="build/sniplets"/>
    <sniplet-extract outputDir="build/sniplets" stripLeadingSpaces="true">
      <fileset dir="../../example/demo/src/main/webapp/reference">
        <include name="*.jsp"/>
      </fileset>
      <fileset dir="../../example/demo/src/main/webapp/overview">
        <include name="*.jsp"/>
      </fileset>
    </sniplet-extract>
  </target>

  <target name="generate-html" depends="sniplet-extract"
          description="Creates the documentation as html output.">
    <!-- XXX add check if XML file already exists -->
    <ant antfile="build.xml"
         dir="../../core" target="generate-tag-reference"/>

    <mkdir dir="build/html"/>
    <mkdir dir="build/html/image"/>
    <mkdir dir="build/docbook"/>
    <style
        in="../../core/build/classes/main/org/apache/myfaces/tobago/taglib/tag-reference.xml"
        out="build/docbook/tag-reference.xml" extension=".xml"
        style="tag-reference2docbook.xsl">
    </style>
    <java classname="com.icl.saxon.StyleSheet" fork="true" failonerror="true">
      <classpath>
        <pathelement path="${saxon.jar}"/>
        <pathelement path="${docbook.saxon-extension.jar}"/>
      </classpath>
      <arg line="
          reference.xml
          ${docbook.dir}/html/chunk.xsl
          use.extensions=1
          textinsert.extension=1
          base.dir=build/html/
          use.id.as.filename=true
          section.autolabel=true
          toc.section.depth=2
          table.footnote.number.format=1
          css.decoration=true
          chunk.section.depth=2
          linenumbering.extension=true
          html.stylesheet=tobago-reference.css
          table.borders.with.css=true"/>

      <!-- You can find the documentation of the style sheet params in the document
 '/doc/html/index.html' in your docbook installation. -->

    </java>
    <copy file="tobago-reference.css" todir="build/html"/>
    <copy todir="build/html/image">
      <fileset dir="image">
        <include name="*.png"/>
        <include name="*.gif"/>
      </fileset>
    </copy>
  </target>

</project>
