<?xml version="1.0"?>
<!--

  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="ASDocs" default="main" basedir=".">
	<property name="FLEX_HOME" value="${basedir}/.."/>
	<property name="lenient" value="true"/>
	<property name="flexlib" location="${FLEX_HOME}/frameworks"/>

	<property name="doc_output" location="${FLEX_HOME}/asdoc-output"   />
	<property name="include_examples" location="${doc_output}/include_examples" />

	<property file="${FLEX_HOME}/env.properties"/>
	<property environment="env"/>
	<property file="${FLEX_HOME}/build.properties"/>

	<target name="main" depends="clean,copyExamples,doc" description="Clean build of all ASDocs"/>

	<target name="clean" description="Cleans all ASDocs">
		<delete dir="${doc_output}"/>
	</target>

	<target name="copyExamples" description="Copy all  projects asdocs subdir to singe location">
		<copy todir="${include_examples}">
			<!--  <fileset dir="${flexlib}/projects/core/asdoc/en_US"/>-->
			<fileset dir="${flexlib}/projects/framework/asdoc/en_US"/>
		</copy>
	</target>

	<target name="doc">

		<condition property="asdoc.jvm.args" value="-Xmx512m">
			<os family="windows"/>
		</condition>

		<condition property="asdoc.jvm.args" value="-Xmx1024m">
			<os family="mac"/>
		</condition>

		<condition property="asdoc.jvm.args" value="-Xmx512m">
			<os family="unix"/>
		</condition>

		<path id="flexTasks.path">
			<fileset dir="${FLEX_HOME}">
				<include name="lib/flexTasks.jar" />
				<include name="ant/lib/flexTasks.jar" />
			</fileset>
		</path>
		<taskdef resource="flexTasks.tasks" classpathref="flexTasks.path"/>

		<!-- Call asdoc to generate dita xml files -->
		<asdoc output="${doc_output}" lenient="true" failonerror="true" warnings="false" strict="false" locale="en_US" fork="true"
			   window-title="Feathers SDK API Reference"
			   main-title="${release} API Reference "
			   footer="${manifest.Implementation-Vendor}"
			   examples-path="${include_examples}"
				>

			<!-- top level class to include in asdoc -->
			<doc-classes class="CoreClasses"/>
			<doc-classes class="FrameworkClasses"/>
			<doc-sources path-element="${flexlib}/projects/feathers/feathers/source"/>
			<doc-sources path-element="${flexlib}/projects/feathers-mxml/source"/>

			<!-- source path for asdoc -->
			<compiler.source-path path-element="${flexlib}/projects/core/src"/>
			<compiler.source-path path-element="${flexlib}/projects/framework/src"/>
			<!--<compiler.source-path path-element="${flexlib}/projects/feathers/feathers/source"/>
			<compiler.source-path path-element="${flexlib}/projects/feathers-mxml/source"/>-->

			<library-path/>
			<external-library-path dir="${env.AIR_HOME}/frameworks/libs/air">
				<include name="airglobal.swc"/>
			</external-library-path>
			<external-library-path dir="${flexlib}/libs">
				<include name="framework.swc" />
				<include name="starling.swc" />
			</external-library-path>

			<jvmarg line="${asdoc.jvm.args}"/>

			<define name="CONFIG::debug" value="false"/>
			<define name="CONFIG::release" value="true"/>
			<define name="CONFIG::FLASH_10_1" value="false"/>
			<define name="CONFIG::LOGGING" value="false"/>
			<define name="CONFIG::performanceInstrumentation" value="false"/>            
		</asdoc>
	</target>
</project>
