<!--
build.xml

Ant build file for Bio-Formats Sphinx documentation.
Download Apache Ant from http://ant.apache.org/.
Type "ant -p" for a list of targets.
-->

<project>
  <description>Sphinx macros</description>

  <property name="sphinx.build" value="sphinx-build"/>
  <property name="sphinx.opts" value=""/>
  <property name="sphinx.warnopts" value=""/>
  <property name="sphinx.builddir" location="_build"/>
  <property name="latex.opts" value=""/>

  <macrodef name="xelatex" description="Run XeLaTeX">
    <attribute name="file" default=""/>
    <sequential>
      <basename property="file.basename" file="@{file}"/>
      <dirname property="file.dirname" file="@{file}"/>
      <exec executable="xelatex" failonerror="true" dir="${file.dirname}">
        <arg line="${latex.opts}"/>
        <arg value="${file.basename}"/>
      </exec>
    </sequential>
  </macrodef>

  <macrodef name="makeindex" description="Run makeindex">
    <attribute name="file" default=""/>
    <sequential>
      <basename property="file.basename" file="@{file}"/>
      <dirname property="file.dirname" file="@{file}"/>
      <propertyregex property="file.index" input="${file.basename}" regexp="(.*)\.tex" select="\1.idx"/>
      <exec executable="makeindex" failonerror="true" dir="${file.dirname}">
        <arg value="-s"/>
        <arg value="python.ist"/>
        <arg value="${file.index}"/>
      </exec>
    </sequential>
  </macrodef>

  <macrodef name="runlatex">
    <attribute name="file" default=""/>
    <sequential>
      <basename property="jar.filename" file="${lib.jarfile}"/>
      <xelatex file="@{file}"/>
      <xelatex file="@{file}"/>
      <makeindex file="@{file}"/>
      <xelatex file="@{file}"/>
      <xelatex file="@{file}"/>
      <xelatex file="@{file}"/>
    </sequential>
  </macrodef>

  <macrodef name="apidoc" description="Run sphinx-apidoc">
    <attribute name="source" default=""/>
    <attribute name="output" default=""/>
    <sequential>
      <dirname property="output.path" file="@{output}"/>
      <mkdir dir="@{output}"/>
      <exec executable="sphinx-apidoc" failonerror="true" dir="${output.path}">
        <arg value="-T"/>
        <arg value="-o"/>
        <arg value="@{output}"/>
        <arg value="@{source}"/>
      </exec>
    </sequential>
  </macrodef>

</project>
