<?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 environment="env"/>
    <available file="${basedir}/../../sdk"
        type="dir"
        property="ROYALE_HOME"
        value="${basedir}/../../sdk" />
	
	<property name="ROYALE_HOME" value="${basedir}/../../../royale-compiler"/>
	<property name="lenient" value="true"/>
	<property name="royalelib" location="${basedir}/../frameworks"/>

    <property name="doc_output" location="${basedir}/../asdoc-output"   />
    <property name="project_home" location="${basedir}/../"/>

    <property file="${ROYALE_HOME}/env.properties"/>
	<property file="${ROYALE_HOME}/build.properties"/>
	
	<echo message="ROYALE_HOME = ${ROYALE_HOME}" />
	<echo message="royalelib = ${royalelib}" />
	<echo message="doc_output = ${doc_output}" />
    <echo message="compiler.source-path = ${project_home}/js/out/as/classes" />
    <echo message="compiler.source-path = ${project_home}/js/out/as/constants" />
    <echo message="compiler.source-path = ${project_home}/js/out/as/functions" />
    <echo message="compiler.source-path = ${project_home}/js/out/as/interfaces" />
    <echo message="compiler.source-path = ${project_home}/js/out/as/typedefs" />
	
	<target name="main" depends="clean,doc" description="Clean build of all ASDocs"/>

	<target name="clean" description="Cleans all ASDocs">
		<delete dir="${doc_output}"/>
	</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="${ROYALE_HOME}">
                <include name="js/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="Apache Royale API Reference"
               main-title="${release} API Reference "
               footer="${manifest.Implementation-Vendor}" >
               
            <load-config filename="${project_home}/asdoc/asdoc-config.xml" />
               
            <!-- source path for asdoc -->
			<compiler.source-path path-element="${project_home}/js/out/as/classes"/>
			<compiler.source-path path-element="${project_home}/js/out/as/constants"/>
			<compiler.source-path path-element="${project_home}/js/out/as/functions"/>
			<compiler.source-path path-element="${project_home}/js/out/as/interfaces"/>
			<compiler.source-path path-element="${project_home}/js/out/as/typedefs"/>
			
			<!-- namespaces to include in asdoc 
 			<doc-namespaces uri="library://ns.apache.org/royale/basic"/>
			-->
			
			<!-- classes to include in asdoc -->
			<doc-sources path-element="${project_home}/js/out/as/classes"/>
			<doc-sources path-element="${project_home}/js/out/as/constants"/>
			<doc-sources path-element="${project_home}/js/out/as/functions"/>
			<doc-sources path-element="${project_home}/js/out/as/interfaces"/>
			<doc-sources path-element="${project_home}/js/out/as/typedefs"/>
			 
			<!-- namespace declaration for asdoc 
			<namespace uri="library://ns.apache.org/royale/basic" manifest="${project_home}/Binding/basic-manifest.xml" />
			-->
			
			<library-path/>

			<jvmarg line="${asdoc.jvm.args}"/>

			<define name="CONFIG::debug" value="false"/>
			<define name="CONFIG::release" value="true"/>
            <define name="CONFIG::LOGGING" value="false"/>
			<define name="CONFIG::performanceInstrumentation" value="false"/>        
		</asdoc>
	</target>
</project>
