﻿<!-- Documents the FooAPI class library with VS2005 style documentation-->
<!-- The running machine should have : SandCastle 2.2.64 , HTML Help Workshop installed -->
<target name="Document.FooAPI" verbose="true">
  <echo message="Starting the Sandcastle Documentation ..."/>
  <mkdir dir="${sandcastle.workingdir}" />
  <delete>
    <fileset basedir="${sandcastle.workingdir}">
      <include name="**\*" />
    </fileset>
  </delete>
  <!-- Copy configuration file, and hard code references -->
  <copy file="${sandcastle.dir}/Presentation/vs2005/Configuration/Sandcastle.config"
        tofile="${sandcastle.workingdir}/Sandcastle.config" overwrite="true">
    <filterchain>
      <replacestring from="&quot;.\comments.xml" to="&quot;..\${XYZFoo.dll.dir}\*.xml" />
    </filterchain>
  </copy>

  <!-- Run MRefBuilder (introspection on assemblies) to create basic Reflection XML -->
  <exec program="${sandcastle.mrefbuilder.exe}" workingdir="${sandcastle.workingdir}">
    <arg value="..\${XYZFoo.dll.dir}/XYZ.FooAPI.dll" />
    <arg value="/out:reflection.org1.xml" />
    <arg value="/dep:..\Foo.Lib/*.dll" />
  </exec>

  <!-- Create final Reflection XML -->
  <!-- Regroup overloads -->
  <exec program="${sandcastle.xsltransform.exe}" workingdir="${sandcastle.workingdir}">
    <arg value="reflection.org1.xml" />
    <arg value="/xsl:&quot;${sandcastle.applyvsdocmodel.xsl}&quot;" />
    <arg value="/out:reflection.org2.xml" />
  </exec>
  <!-- Create filenames for html documents -->
  <exec program="${sandcastle.xsltransform.exe}" workingdir="${sandcastle.workingdir}">
    <arg value="reflection.org2.xml" />
    <arg value="/xsl:&quot;${sandcastle.addfriendlyfilenames.xsl}&quot;" />
    <arg value="/out:reflection.xml" />
  </exec>

  <!-- Create Manifest (list of Topics) -->
  <exec program="${sandcastle.xsltransform.exe}" workingdir="${sandcastle.workingdir}">
    <arg value="/xsl:&quot;${sandcastle.reflectiontomanifest.xsl}&quot;" />
    <arg value="reflection.xml" />
    <arg value="/out:manifest.xml" />
  </exec>

  <!-- Create Output Environment -->
  <mkdir dir="${sandcastle.output.dir}" />
  <mkdir dir="${sandcastle.output.dir}/html" />
  <copy todir="${sandcastle.output.dir}">
    <fileset basedir="${sandcastle.dir}/Presentation/vs2005">
      <include name="icons/*" />
      <include name="scripts/*" />
      <include name="styles/*" />
    </fileset>
  </copy>

  <!-- Run BuildAssembler (create html topic files) -->
  <exec program="${sandcastle.buildassembler.exe}" workingdir="${sandcastle.workingdir}" >
    <arg value="manifest.xml" />
    <arg value="/config:Sandcastle.config" />
  </exec>

  <!-- Create html Help project -->
  <exec program="${sandcastle.xsltransform.exe}" workingdir="${sandcastle.workingdir}">
    <arg value="/xsl:&quot;${sandcastle.reflectiontochmproject.xsl}&quot;" />
    <arg value="reflection.xml" />
    <arg value="/out:&quot;.\Output\test.hhp&quot;" />
  </exec>
  <!-- Create html Help project Table Of Contents -->
  <exec program="${sandcastle.xsltransform.exe}" workingdir="${sandcastle.workingdir}" >
    <arg value="/xsl:&quot;${sandcastle.reflectiontochmtoc.xsl}&quot;" />
    <arg value=".\reflection.xml" />
    <arg value="/out:&quot;.\Output\toc.xml&quot;" />
  </exec>
  <!-- Create chm toc (hhc) from toc-->
  <exec program="${sandcastle.xsltransform.exe}" workingdir="${sandcastle.workingdir}" >
    <arg value="/xsl:&quot;${sandcastle.toctochmtoc.xsl}&quot;" />
    <arg value=".\Output\toc.xml" />
    <arg value="/out:&quot;.\Output\test.hhc&quot;" />
  </exec>

  <!-- Reflection to chm index (hhx)-->
  <exec program="${sandcastle.xsltransform.exe}" workingdir="${sandcastle.workingdir}" >
    <arg value="/xsl:&quot;${sandcastle.reflectiontochmindex.xsl}&quot;" />
    <arg value=".\reflection.xml" />
    <arg value="/out:&quot;.\Output\test.hhk&quot;" />
  </exec>

  <!-- Generate CHM file -->
  <exec program="${hhc.exe}"
        commandline=".\test.hhp"
        workingdir="${sandcastle.output.dir}"
        failonerror="false"/>
  <echo message="Documentation completed..."/>
</target>
