buildframework/helium/tools/common/docs.ant.xml
changeset 1 be27ed110b50
child 179 d8ac696cc51f
equal deleted inserted replaced
0:044383f39525 1:be27ed110b50
       
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 <!-- 
       
     3 ============================================================================ 
       
     4 Name        : docs.ant.xml 
       
     5 Part of     : Helium 
       
     6 
       
     7 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     8 All rights reserved.
       
     9 This component and the accompanying materials are made available
       
    10 under the terms of the License "Eclipse Public License v1.0"
       
    11 which accompanies this distribution, and is available
       
    12 at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    13 
       
    14 Initial Contributors:
       
    15 Nokia Corporation - initial contribution.
       
    16 
       
    17 Contributors:
       
    18 
       
    19 Description:
       
    20 
       
    21 ============================================================================
       
    22 -->
       
    23 <project name="internal.docs" xmlns:hlm="http://www.nokia.com/helium" xmlns:ivy="antlib:org.apache.ivy.ant">
       
    24     <description>
       
    25     Documentation generation targets.
       
    26     </description>
       
    27     
       
    28     <property name="helium.doc.dir" location="${helium.dir}/doc" />
       
    29     
       
    30     <fileset id="python.library.files" dir="${helium.dir}">
       
    31         <include name="extensions/nokia/tools/common/python/lib/**/*.py"/>
       
    32         <include name="tools/common/python/lib/**/*.py"/>
       
    33         <include name="extensions/nokia/tools/dp/iCreatorDP/**/*.py"/>
       
    34     </fileset>
       
    35     
       
    36     <!-- Generate an overview of Helium as HTML tables. -->
       
    37     <target name="overview-to-html">
       
    38         <fmpp sourceFile="${helium.doc.dir}/src/helium_overview.html.ftl"
       
    39               outputFile="${helium.build.dir}/temp/doc/helium_overview.html"
       
    40               replaceExtension="html.ftl, html" expert="true">
       
    41             <data expandProperties="yes">
       
    42                 doc: xml(${helium.doc.dir}/src/helium_overview.xml)
       
    43             </data>
       
    44         </fmpp>
       
    45     </target>
       
    46 
       
    47     
       
    48     <!-- Macro to generate the tools dependency xml output. -->
       
    49     <macrodef name="createToolsTableMacro" uri="http://www.nokia.com/helium">
       
    50         <attribute name="dir"/>
       
    51         <attribute name="failonerror"/>
       
    52         <attribute name="configs"/>
       
    53         <sequential>
       
    54             <ivy:configure file="${tools.ivy.config.file}" override="true"/>
       
    55             <ivy:resolve file="${helium.dir}/config/ivy/ivy.xml" conf="@{configs}" haltonfailure="@{failonerror}"/>
       
    56             <ivy:report todir="@{dir}" outputpattern="tool-dependencies-[conf].xml"
       
    57                         conf="@{configs}" xml="true" graph="false" xsl="false"/>
       
    58         </sequential>
       
    59     </macrodef>
       
    60 
       
    61     
       
    62     <!-- Generates the tools dependency xml output. used in the retrieving Helium section to list the tools used within Helium-->
       
    63     <target name="tools-rst-table">
       
    64         <hlm:createToolsTableMacro dir="${helium.build.dir}/doc/ivy" failonerror="false" 
       
    65             configs="core,ido"/>
       
    66         <fmpp sourceFile="${helium.doc.dir}/src/manual/tool-dependencies.rst.ftl" includes="*.dot.ftl"
       
    67               outputFile="${helium.build.dir}/temp/doc/nokia/tool-dependencies.rst_include"
       
    68               replaceExtension="dot.ftl, dot">
       
    69             <data expandProperties="yes">
       
    70                 doc: xml(${helium.build.dir}/doc/ivy/tool-dependencies-ido.xml)
       
    71             </data>
       
    72         </fmpp>
       
    73     </target>
       
    74     
       
    75     
       
    76     <!-- Create a complete dependency graph of Helium libraries. 
       
    77         
       
    78     Currently this does not work correctly but it is useful for future testing of repreport. -->
       
    79     <target name="libraries-dependencies">
       
    80         <ivy:settings file="${tools.ivy.config.file}"/>
       
    81         <!--<ivy:resolve file="${helium.dir}/config/ivy/ivy.xml" conf="" haltonfailure="false"/>-->
       
    82         <delete file="@{dir}/ivy-repository-report.xml"/>
       
    83         <ivy:repreport todir="${helium.build.dir}/doc/ivy" organisation="S60_SAM"
       
    84                     xml="true" graph="false" xsl="false"/>
       
    85         <!--<fmpp sourceFile="${helium.doc.dir}/src/manual/tool-dependencies.rst.ftl" includes="*.dot.ftl"
       
    86               outputFile="${helium.build.dir}/temp/doc/manual/tool-dependencies.rst_include"
       
    87               replaceExtension="dot.ftl, dot">
       
    88             <data expandProperties="yes">
       
    89                 doc: xml(${helium.build.dir}/doc/ivy/tool-dependencies-ido.xml)
       
    90             </data>
       
    91         </fmpp>-->
       
    92     </target>
       
    93     
       
    94     
       
    95     <!-- Generate .rst tables from the property groups in the data model. -->
       
    96     <target name="property-group-tables">
       
    97         <fmpp sourceRoot="${helium.doc.dir}/src" includes="*.dot.ftl" outputRoot="${helium.build.dir}/temp/doc/api/helium"
       
    98               replaceExtension="dot.ftl, dot">
       
    99             <data expandProperties="yes">
       
   100                 doc: xml(${database.file})
       
   101             </data>
       
   102         </fmpp>
       
   103     </target>
       
   104 
       
   105     
       
   106     <!-- Generate Python API documentation using epydoc. -->
       
   107     <target name="python-apidocs">
       
   108         <mkdir dir="${helium.build.dir}/doc/api/python"/>
       
   109         <pathconvert pathsep=" " property="epydoc.python.modules.path">
       
   110             <fileset refid="python.library.files"/>
       
   111         </pathconvert>
       
   112         <echo>Python modules path: ${epydoc.python.modules.path}</echo>
       
   113         <exec osfamily="windows" executable="python" dir="${helium.build.dir}" failonerror="true">        
       
   114             <arg line="${python.tools}\epydoc"/>
       
   115             <arg value="-v"/>
       
   116             <arg value="--config=${helium.dir}\config\epydoc.conf"/>
       
   117             <arg value="--exclude=sgmllib"/>
       
   118             <arg line="${epydoc.python.modules.path}"/>
       
   119         </exec>
       
   120     </target>
       
   121     
       
   122     
       
   123     <!-- Generate Java API documentation using javadoc. -->
       
   124     <target name="java-apidocs" depends="install-cruisecontrol">
       
   125         <path id="classpath-javadoc">
       
   126             <fileset dir="${helium.dir}/external/CruiseControl/lib" includes="*.jar"/>
       
   127             <fileset dir="${helium.dir}/external" includes="**/*.jar"/>
       
   128             <pathelement path="${helium.dir}/external/CruiseControl/webapps/dashboard/WEB-INF/classes"/>
       
   129         </path>
       
   130         <javadoc classpathref="classpath-javadoc" 
       
   131             destdir="${helium.build.dir}/doc/api/java" useexternalfile="true">
       
   132             <packageset dir="tools/common/java/src" defaultexcludes="yes"/>
       
   133             <packageset dir="tools/common/java/test" defaultexcludes="yes"/>
       
   134             <doctitle><![CDATA[<h1>API Documentation</h1>]]></doctitle>
       
   135         </javadoc>
       
   136     </target>
       
   137     
       
   138     
       
   139     <!-- Generate Ant API documentation using antdoclet. -->
       
   140     <target name="antdoclet" description="Generate Ant Task/Types documentation">
       
   141         <path id="doclet-classpath">
       
   142             <pathelement path="${java.class.path}/"/>
       
   143             <pathelement path="${helium.dir}/external/CruiseControl/webapps/dashboard/WEB-INF/classes"/>
       
   144         </path>
       
   145         <mkdir dir="${helium.build.dir}/doc/api/ant"/>
       
   146 
       
   147         <!-- First copy the "static" resources (images, static html files) -->
       
   148         <copy todir="${helium.build.dir}/doc/api/ant" overwrite="true">
       
   149             <fileset dir="${helium.doc.dir}/src/antdoclet/html">
       
   150                 <exclude name="*.vm"/>
       
   151             </fileset>
       
   152         </copy>
       
   153       
       
   154         <!-- Now invoke AntDoclet to generate the "dynamic" content from the templates -->
       
   155         <javadoc access="private" sourcepath="${helium.dir}/tools/common/java/src/"
       
   156                  destdir="${helium.build.dir}/doc/api/ant"
       
   157                  packagenames="com.nokia.ant,com.nokia.ant.filters,com.nokia.ant.types.imaker,com.nokia.ant.types,com.nokia.ant.listerner,com.nokia.ant.taskdefs,com.nokia.ant.taskdefs.ccm.commands,com.nokia.cruisecontrol,com.nokia.cruisecontrol.sourcecontrol,com.nokia.fmpp,nokia.ivy"
       
   158                  docletpathref="doclet-classpath" source="1.6"
       
   159                  useexternalfile="true">
       
   160             <doclet name="com.neuroning.antdoclet.AntDoclet">
       
   161                 <param name="-doctitle" value="${build.name}" />
       
   162                 <param name="-templatesdir" value="${helium.doc.dir}/src/antdoclet/html"/>
       
   163                 <param name="-templates" value="main.vm"/>
       
   164             </doclet>
       
   165         </javadoc>
       
   166         <move file="velocity.log" tofile="build/velocity.log" failonerror="false"/>
       
   167     </target>
       
   168 
       
   169     
       
   170     <!-- Cleans the Helium API documentation. -->
       
   171     <target name="clean-helium-apidoc">
       
   172         <delete dir="${helium.build.dir}/doc/api/helium"/>
       
   173         <delete dir="${helium.build.dir}/temp/doc/api/helium"/>
       
   174     </target>
       
   175     
       
   176     
       
   177     <!-- Creates images of the dependencies for all Ant targets.
       
   178         
       
   179     This includes creating a cmap file that is included in the HTML document,
       
   180     so the boxes in the image are linked to their targets. -->
       
   181     <target name="helium-api-dependency-images">
       
   182         <mkdir dir="${helium.build.dir}/doc/api/helium"/>
       
   183         <fmpp sourceRoot="${helium.doc.dir}/src/api" includes="*.dot.ftl" outputRoot="${helium.build.dir}/temp/doc/api/helium"
       
   184               replaceExtension="dot.ftl, dot">
       
   185             <data expandProperties="yes">
       
   186                 doc: xml(${database.file})
       
   187             </data>
       
   188         </fmpp>
       
   189         <for param="dot.file" parallel="true" threadCount="${number.of.threads}">
       
   190             <fileset dir="${helium.build.dir}/temp/doc/api/helium" includes="*.dot"/>
       
   191             <sequential>
       
   192                 <echo>Processing dot file: @{dot.file}</echo>
       
   193                 <exec executable="dot" dir="${helium.build.dir}/temp/doc/api/helium">
       
   194                     <arg line="-Tcmap @{dot.file} -O"/>
       
   195                 </exec>
       
   196                 <exec executable="dot" dir="${helium.build.dir}/doc/api">
       
   197                     <arg line="-Tpng @{dot.file} -O"/>
       
   198                 </exec>
       
   199             </sequential>
       
   200         </for>
       
   201         <move todir="${helium.build.dir}/doc/api" overwrite="true">
       
   202             <fileset dir="${helium.build.dir}/temp/doc/api" includes="*.dot.png"/>
       
   203         </move>
       
   204     </target>
       
   205     
       
   206     
       
   207     <!-- Builds the HTML files for the Helium API documentation. -->
       
   208     <target name="helium-api-html-docs">
       
   209         <mkdir dir="${helium.build.dir}/doc/api/helium"/>
       
   210         <copy todir="${helium.build.dir}/temp/doc/api/helium" overwrite="true">
       
   211             <fileset dir="${helium.doc.dir}/src/api"/>
       
   212         </copy>
       
   213         <xslt in="${data.model.file}" out="${data.model.parsed}" style="${data.model.xsl}"/>
       
   214         <hlm:parsemodel output="${helium.build.dir}/helium_data_model.xml_parsed" input="${data.model.parsed}"/>
       
   215         <fmpp sourceRoot="${helium.build.dir}/temp/doc/api/helium" excludes="*.dot.ftl,**/*.dot,**/*.cmap,*.bak"
       
   216               outputRoot="${helium.build.dir}/doc/api/helium"
       
   217               replaceExtension="html.ftl, html">
       
   218             <data expandProperties="yes">
       
   219                 ant: antProperties()
       
   220                 doc: xml(${database.file})
       
   221                 data: xml(${helium.build.dir}/helium_data_model.xml_parsed)
       
   222             </data>            
       
   223         </fmpp>
       
   224     </target>
       
   225     
       
   226     
       
   227     <!-- Builds the Helium API documentation. -->
       
   228     <target name="helium-apidocs" depends="clean-helium-apidoc,database,
       
   229         find-python-dependencies,helium-api-dependency-images,helium-api-html-docs"/>
       
   230     
       
   231     <!-- Builds the Helium API documentation for customer. -->
       
   232     <target name="customer-apidocs">
       
   233         <mkdir dir="${helium.build.dir}"/>
       
   234         
       
   235         <antcall target="helium-apidocs">
       
   236             <param name="helium.dir" value="."/>
       
   237             <param name="home.files.only" value="true"/>
       
   238             <param name="database.file" location="${helium.build.dir}/database.xml"/>
       
   239         </antcall>
       
   240         <!--
       
   241         <antform title="login information">
       
   242             <textProperty label="password:" property="noe.password" password="true"/>
       
   243         </antform>
       
   244         
       
   245         <antcall target="upload-docs">
       
   246             <param name="helium.dir" value="."/>
       
   247             <param name="documentation.path.root" value="/var/local/www/helium/doc/${customer}"/>
       
   248         </antcall>
       
   249         -->
       
   250     </target>
       
   251     
       
   252     <!-- Generate documentation from the source code. -->
       
   253     <target name="apidocs" depends="python-apidocs,helium-apidocs,java-apidocs,antdoclet,apidocs-search"/>
       
   254     
       
   255     <!-- Macro to generate html docs from rst. -->
       
   256     <macrodef name="rstMacro" uri="http://www.nokia.com/helium">
       
   257         <attribute name="version" default="${helium.version}"/>
       
   258         <attribute name="src" default="${helium.build.dir}/temp/doc"/>
       
   259         <attribute name="output" default="${helium.build.dir}/doc"/>
       
   260         <sequential>
       
   261             <property name="sphinx.lib.dir" location="${helium.dir}/external/python/lib/2.5/Sphinx-0.5.1-py2.5.egg/sphinx" />
       
   262             <if>
       
   263                 <available file="${nokia.python.tools}/sphinxfixsearch.diff"/>
       
   264                 <then>
       
   265                     <patch patchfile="${nokia.python.tools}/sphinxfixsearch.diff" originalfile="${sphinx.lib.dir}/search.py"/>
       
   266                 </then>
       
   267             </if>
       
   268             <exec executable="python" failonerror="${failonerror}">        
       
   269                 <arg file="${python.dir}/sphinx-build.py"/>
       
   270                 <arg value="-b" />
       
   271                 <arg value="html" />            
       
   272                 <arg value="-D" />
       
   273                 <arg value="version=@{version}" />
       
   274                 <arg value="-D" />
       
   275                 <arg value="release=@{version}" />
       
   276                 <arg file="@{src}" />
       
   277                 <arg file="@{output}" />
       
   278             </exec>
       
   279             <if>
       
   280                 <available file="${nokia.python.tools}/sphinxfixsearch.diff"/>
       
   281                 <then>
       
   282                     <patch reverse="true" patchfile="${nokia.python.tools}/sphinxfixsearch.diff" originalfile="${sphinx.lib.dir}/search.py"/>
       
   283                 </then>
       
   284             </if>
       
   285         </sequential>
       
   286     </macrodef>
       
   287     
       
   288     <!-- Generate rst files for docs -->
       
   289     <target name="prep-textdocs" depends="clean-doc-dir,overview-to-html,tools-rst-table,dependency-diagram,dependency-logs,release-diff,helium-user-graph">
       
   290         <mkdir dir="${helium.build.dir}/doc"/>
       
   291         
       
   292         <delete dir="${helium.build.dir}/doc/.doctrees"/>
       
   293         <delete file="${helium.build.dir}/doc/searchindex.json"/>
       
   294         
       
   295         <copy todir="${helium.build.dir}/doc/images">
       
   296             <fileset dir="${helium.doc.dir}/images"/>
       
   297         </copy>
       
   298 
       
   299         <!-- Temporarily copy the image directory so that doc generation will complete happily. -->
       
   300         <copy todir="${helium.build.dir}/temp/doc/images">
       
   301             <fileset dir="${helium.build.dir}/doc/images"/>
       
   302         </copy>
       
   303         <copy todir="${helium.build.dir}/temp/doc">
       
   304             <fileset dir="${helium.doc.dir}/src">
       
   305                 <include name="**/*.rst"/>
       
   306                 <include name="**/*.css"/>
       
   307                 <include name="**/*.jpg"/>
       
   308                 <include name="**/*.dot"/>
       
   309             </fileset>
       
   310         </copy>
       
   311         <copy todir="${helium.build.dir}/temp/doc/nokia" failonerror="false">
       
   312             <fileset dir="${nokia.dir}/doc/src">
       
   313                 <include name="**/*.rst"/>
       
   314                 <include name="**/*.css"/>
       
   315                 <include name="**/*.jpg"/>
       
   316             </fileset>
       
   317         </copy>
       
   318         
       
   319         <mkdir dir="${helium.build.dir}/temp/doc/minibuilds"/>
       
   320         <copy todir="${helium.build.dir}/temp/doc/minibuilds" failonerror="false">
       
   321             <fileset dir="${helium.dir}/tests/minibuilds/">
       
   322                 <include name="*/doc/**/*"/>
       
   323             </fileset>
       
   324         </copy>
       
   325         
       
   326         <fmpp sourceFile="${helium.doc.dir}/src/quick_start_guide.rst.ftl" outputFile="${helium.build.dir}/temp/doc/quick_start_guide.rst">
       
   327             <data expandProperties="yes">
       
   328                 ant: antProperties()
       
   329             </data>            
       
   330         </fmpp>
       
   331         
       
   332         <fileset id="internal.ref.minibuilds" dir="${helium.build.dir}/temp/doc/minibuilds" includes="*/**/index.rst"/>
       
   333         <fmpp sourceFile="${helium.doc.dir}/src/minibuilds.rst.ftl"
       
   334               outputFile="${helium.build.dir}/temp/doc/minibuilds/index.rst">
       
   335             <data expandProperties="yes">
       
   336                 project: antProject()
       
   337             </data>            
       
   338         </fmpp>
       
   339         <fmpp sourceFile="${helium.doc.dir}/src/index.rst.ftl" outputFile="${helium.build.dir}/temp/doc/index.rst">
       
   340             <data expandProperties="yes">
       
   341                 ant: antProperties()
       
   342             </data>            
       
   343         </fmpp>
       
   344         <fmpp sourceFile="${helium.doc.dir}/src/manual/APIs.rst.ftl" outputFile="${helium.build.dir}/temp/doc/manual/APIs.rst">
       
   345             <data expandProperties="yes">
       
   346                 ant: antProperties()
       
   347             </data>            
       
   348         </fmpp>
       
   349         <fmpp sourceFile="${helium.doc.dir}/src/manual/stages.rst.ftl" outputFile="${helium.build.dir}/temp/doc/manual/stages.rst">
       
   350             <data expandProperties="yes">
       
   351                 ant: antProperties()
       
   352             </data>            
       
   353         </fmpp>
       
   354         
       
   355         <copy todir="${helium.build.dir}/temp/doc">
       
   356             <fileset dir="${helium.doc.dir}/src">
       
   357                 <include name="conf.py"/>
       
   358                 <include name=".static"/>
       
   359                 <include name=".templates/**"/>
       
   360                 <include name="*.jpg"/>
       
   361             </fileset>
       
   362         </copy>
       
   363 
       
   364         <!-- Including Helium antlib doc -->
       
   365         <mkdir dir="${helium.build.dir}/temp/doc/helium-antlib"/>
       
   366         <copy todir="${helium.build.dir}/temp/doc/helium-antlib" failonerror="false">
       
   367             <fileset dir="${helium.dir}/external/helium-antlib/doc/src">
       
   368                 <include name="**/*.rst"/>
       
   369                 <include name="**/*.css"/>
       
   370                 <include name="**/*.jpg"/>
       
   371             </fileset>
       
   372         </copy>
       
   373         
       
   374         <for param="dot.file">
       
   375             <fileset dir="${helium.build.dir}/temp/doc/manual" includes="*.dot"/>
       
   376             <sequential>
       
   377                 <exec executable="dot">
       
   378                     <arg line="-Tpng @{dot.file} -O"/>
       
   379                 </exec>
       
   380             </sequential>
       
   381         </for>
       
   382     </target>
       
   383     
       
   384     <!-- Generate HTML documentation from .rst documents with Sphinx.
       
   385     
       
   386     All doc .rst files should be generated or copied into build/temp/doc before being processed into HTML.    
       
   387     -->
       
   388     <target name="textdocs" depends="prep-textdocs">        
       
   389         <hlm:rstMacro />
       
   390         
       
   391         <copy file="${database.file}" todir="${helium.build.dir}/doc"/>
       
   392         <copy file="${helium.build.dir}/temp/doc/default.css" todir="${helium.build.dir}/doc/_static" overwrite="true"/>
       
   393         <copy file="${helium.build.dir}/temp/doc/helium_pallot_small.jpg" todir="${helium.build.dir}/doc/_static" overwrite="true"/>
       
   394         <copy todir="${helium.build.dir}/doc" overwrite="true">
       
   395             <fileset dir="${helium.doc.dir}/src">
       
   396                 <include name="**/*.zip"/>
       
   397             </fileset>
       
   398         </copy>
       
   399     </target>
       
   400     
       
   401     <!-- Generate search index for apis -->
       
   402     <target name="apidocs-search">
       
   403         <hlm:python>
       
   404 import html2rest
       
   405 import os
       
   406 import codecs
       
   407 #import traceback
       
   408 for root, dirs, files in os.walk(r'${helium.build.dir}/doc/api', topdown=False):
       
   409     for fname in files:
       
   410         if '.html' in fname:
       
   411             filename = os.path.abspath(os.path.join(root, fname))
       
   412             rstfilename = filename.replace('.html', '.rst')
       
   413             try:
       
   414                 out = open(rstfilename, 'w')
       
   415                 html2rest.html2rest(html2rest.readsoup(filename), out)
       
   416             except:
       
   417                 #traceback.print_exc()
       
   418                 print filename + ' failed to be converted to rst'
       
   419             finally:
       
   420                 out.close()
       
   421                 
       
   422             try:
       
   423                 rstfile = codecs.open(rstfilename, 'r', 'utf8')
       
   424                 rstfile.read()
       
   425             except:
       
   426                 print rstfilename + ' has invalid unicode'
       
   427                 rstfile.close()
       
   428                 os.remove(rstfilename)
       
   429         </hlm:python>
       
   430         
       
   431         <move todir="${helium.build.dir}/temp_search/doc" overwrite="true">
       
   432             <fileset dir="${helium.build.dir}/doc/api">
       
   433                 <include name="**/*.rst"/>
       
   434             </fileset>
       
   435         </move>
       
   436         
       
   437         <move todir="${helium.build.dir}/doc/api_backup" overwrite="true">
       
   438             <fileset dir="${helium.build.dir}/doc/api"/>
       
   439         </move>
       
   440         
       
   441         <copy file="${helium.doc.dir}/src/api/apisearchindex.rst" tofile="${helium.build.dir}/temp_search/doc/index.rst"/>
       
   442         
       
   443         <copy todir="${helium.build.dir}/temp_search/doc">
       
   444             <fileset dir="${helium.doc.dir}/src">
       
   445                 <include name="conf.py"/>
       
   446                 <include name=".static"/>
       
   447                 <include name=".templates/**"/>
       
   448                 <include name="*.jpg"/>
       
   449             </fileset>
       
   450         </copy>
       
   451         
       
   452         <hlm:rstMacro src="${helium.build.dir}/temp_search/doc" output="${helium.build.dir}/doc/api"/>
       
   453         
       
   454         <move todir="${helium.build.dir}/doc/api" overwrite="true">
       
   455             <fileset dir="${helium.build.dir}/doc/api_backup"/>
       
   456         </move>
       
   457     </target>
       
   458     
       
   459     <!-- Generate all documentation. -->
       
   460     <target name="add-policies-to-docs" unless="env.HLM_SUBCON">
       
   461         <hlm:updatePolicy policy="7" filename="distribution.policy.S60">         
       
   462             <dirset dir="${helium.dir}" includes="${helium.build.dir}/doc/**/*"/>        
       
   463         </hlm:updatePolicy>   
       
   464     </target>
       
   465     
       
   466     
       
   467     <!-- Creates XML and .rst documents describing the difference between
       
   468     this version of Helium and the previous major release. -->
       
   469     <target name="release-diff" depends="database" unless="env.HLM_SUBCON">
       
   470         <mkdir dir="${helium.build.dir}/doc"/>
       
   471         <property name="last.major.release.database.url" value="${documentation.url.root}/${last.major.helium.version}/database.xml"/>
       
   472         <hlm:python>
       
   473 import urllib
       
   474 import helium.documentation
       
   475 
       
   476 old_db_file = urllib.urlopen(r'${last.major.release.database.url}')
       
   477 writer = helium.documentation.APIDeltaWriter(old_db_file, r'${database.file}')
       
   478 writer.write(r'${helium.build.dir}/doc/api_changes.xml')
       
   479         </hlm:python>
       
   480         <fmpp sourceFile="${helium.doc.dir}/src/api_changes.rst.ftl" outputFile="${helium.build.dir}/temp/doc/api_changes.rst">
       
   481             <data expandProperties="yes">
       
   482                 doc: xml(${helium.build.dir}/doc/api_changes.xml)
       
   483                 old_release: ${last.major.helium.version}
       
   484                 new_release: ${helium.version}
       
   485             </data>
       
   486         </fmpp>
       
   487     </target>
       
   488     
       
   489     <!-- Generate docs for Symbian Foundataion -->
       
   490     <target name="docs-sf">
       
   491         <delete dir="${helium.build.dir}"/>
       
   492         <antcall target="helium-subcon-release"/>
       
   493         <unzip src="${helium.build.dir}/helium_${helium.version}_subcon.zip" dest="${helium.build.dir}/helium_${helium.version}_subcon" overwrite="true" />
       
   494         <!---->
       
   495         <exec executable="cmd" dir="${helium.build.dir}/helium_${helium.version}_subcon/helium">
       
   496             <env key="HELIUM_HOME" value="${helium.build.dir}/helium_${helium.version}_subcon/helium"/>
       
   497             <env key="PYTHONPATH" value="${env.PYTHONPATH}"/>
       
   498             <env key="ANT_ARGS" value="${env.ANT_ARGS}"/>
       
   499             <arg line="/C hlm.bat"/>
       
   500             <arg value="docs"/>
       
   501             <arg value="-Dpython.tools=${python.tools}"/>
       
   502             <arg value="-Dsf=true"/>
       
   503         </exec>
       
   504     </target>
       
   505     
       
   506     <!-- generate all the user documentation for helium -->
       
   507     <target name="docs" depends="clean-doc-dir,database,apidocs,textdocs,add-policies-to-docs"/>
       
   508     
       
   509     <!-- Clean old build/doc dir. -->
       
   510     <target name="clean-doc-dir">
       
   511         <delete dir="build/doc"/>
       
   512         <delete dir="build/temp/doc"/>        
       
   513     </target>
       
   514     
       
   515     <!-- Connect to home drive if it is not connected for .netrc file. -->
       
   516     <target name="check-home-drive">
       
   517         <exec executable="cmd">
       
   518             <arg value="/c"/>
       
   519             <arg value="${helium.dir}/tools/common/bin/check_home_drv.bat"/>
       
   520             <arg value=">nul"/>
       
   521         </exec>
       
   522     </target>
       
   523     
       
   524     <!-- Upload generated HTML docs to the Helium server. -->
       
   525     <target name="upload-docs" depends="check-home-drive">
       
   526         <property name="documentation.path" value="${documentation.path.root}"/>
       
   527         <property name="docs.zip" value="${helium.build.dir}/helium-docs.zip"/>
       
   528 
       
   529         <!-- Python API docs. -->
       
   530         <delete file="${docs.zip}"/>
       
   531         <zip destfile="${docs.zip}">
       
   532             <fileset dir="${helium.build.dir}/doc" includes="**/*"/>
       
   533         </zip>
       
   534         <sshexec host="${documentation.host}"
       
   535                  username="${user.name}"
       
   536                  keyfile="${env.HOME}/.ssh/id_rsa_openssh.ppk"
       
   537                  trust="true"
       
   538                  command="mkdir -p ${documentation.path}"/>
       
   539         <scp todir="${user.name}@${documentation.host}:${documentation.path}"
       
   540           keyfile="${env.HOME}/.ssh/id_rsa_openssh.ppk"
       
   541           passphrase=""
       
   542           trust="true"
       
   543           sftp="true"
       
   544           file="${docs.zip}"/>
       
   545         <sshexec host="${documentation.host}"
       
   546                  username="${user.name}"
       
   547                  keyfile="${env.HOME}/.ssh/id_rsa_openssh.ppk"
       
   548                  trust="true"
       
   549                  command="cd ${documentation.path}; unzip -u -o helium-docs.zip"/>
       
   550     </target>
       
   551     
       
   552     
       
   553     <!-- Upload generated HTML docs to the Helium server. -->
       
   554     <target name="upload-release-docs">
       
   555         <property name="documentation.path" value="${documentation.path.root}/${helium.version}"/>
       
   556         <antcall target="upload-docs"/>
       
   557     </target>
       
   558     
       
   559     
       
   560   <!-- create slides from images -->
       
   561     <target name="slides">
       
   562         <mkdir dir="${helium.build.dir}/slides"/>
       
   563     
       
   564         <copy todir="${helium.build.dir}/slides">
       
   565             <fileset dir="${helium.doc.dir}/slides"/>
       
   566         </copy>
       
   567 
       
   568         <copy todir="${helium.build.dir}/slides/images">
       
   569             <fileset dir="${helium.doc.dir}/slides/images"/>
       
   570         </copy>
       
   571     
       
   572         <for param="document">
       
   573             <fileset dir="${helium.build.dir}/slides" includes="**/*.rst"/>
       
   574             <sequential>
       
   575                 <propertyregex property="document.no.ext" input="@{document}" regexp="\.rst$" replace="" override="true"/>
       
   576                 <if>
       
   577                     <not>
       
   578                         <uptodate srcfile="@{document}" targetfile="${document.no.ext}.html"/>
       
   579                     </not>
       
   580                     <then>
       
   581                         <echo>Building doc: @{document}</echo>
       
   582                         <exec executable="python" dir="${helium.doc.dir}" failonerror="${failonerror}">
       
   583                             <arg value="${nokia.python.tools}/rst2s5.py"/>
       
   584                             <arg value="@{document}"/>
       
   585                             <arg value="${document.no.ext}.html"/>
       
   586                         </exec>
       
   587                     </then>
       
   588                 </if>
       
   589             </sequential>
       
   590         </for>
       
   591     </target>
       
   592 
       
   593         
       
   594     <!-- Generate HTML documentation from .rst documents.
       
   595     
       
   596     TODO: Remove this old method. -->
       
   597     <target name="textdocs-old" depends="overview-to-html">
       
   598         <mkdir dir="${helium.build.dir}/doc"/>
       
   599         <copy todir="${helium.build.dir}/doc-old">
       
   600             <fileset dir="${helium.doc.dir}/src" excludes="cover.rst"/>
       
   601             <fileset dir="${nokia.dir}/doc/src"/>
       
   602         </copy>
       
   603         
       
   604         <copy todir="${helium.build.dir}/doc-old/images">
       
   605             <fileset dir="${helium.doc.dir}/images"/>
       
   606         </copy>
       
   607         
       
   608         <for param="document">
       
   609             <fileset dir="${helium.build.dir}/doc-old">
       
   610                 <include name="**/*.rst" />
       
   611                 <exclude name="index.rst" /><!-- index.rst is the top-level doc for new-style docs -->
       
   612             </fileset>
       
   613             <sequential>
       
   614                 <propertyregex property="document.no.ext" input="@{document}" regexp="\.rst$" replace="" override="true"/>
       
   615                 <if>
       
   616                     <not>
       
   617                         <uptodate srcfile="@{document}" targetfile="${document.no.ext}.html"/>
       
   618                     </not>
       
   619                     <then>
       
   620                         <echo>Building doc: @{document}</echo>                        
       
   621                         <exec executable="python" dir="${helium.doc.dir}" failonerror="${failonerror}">
       
   622                             <!--<env key="PYTHONPATH" value="${helium.dir}\${python25.lib};tools\common\python\lib"/>-->
       
   623                             <arg value="${nokia.python.tools}\rst2html.py"/>
       
   624                             <arg line="--traceback --no-toc-backlinks"/>
       
   625                             <!-- -stylesheet-path nokia_style.css -->
       
   626                             <arg value="@{document}"/>
       
   627                             <arg value="${document.no.ext}.html"/>
       
   628                         </exec>
       
   629                     </then>
       
   630                 </if>
       
   631             </sequential>
       
   632         </for>
       
   633     </target>
       
   634     
       
   635     
       
   636     <!-- Search Python internal module used in helium -->
       
   637     <target name="find-python-dependencies" depends="database">    
       
   638         <hlm:assertPropertySet property="helium.dir" message="Property helium.dir is not defined." />
       
   639         <hlm:assertPropertySet property="database.file" message="Property database.file is not defined."/>
       
   640         <hlm:python>
       
   641 from __future__ import with_statement
       
   642 import re
       
   643 import os
       
   644 import string
       
   645 import amara
       
   646 import codecs
       
   647 import ant
       
   648 
       
   649 setpath = r'${helium.dir}'+'/tools'
       
   650 
       
   651 print "Searching under "+setpath
       
   652 
       
   653 dbPath = r'${database.file}'
       
   654 dbPath = 'file:///'+ dbPath.replace('\\','/')
       
   655 dbPrj = amara.parse(dbPath)
       
   656 
       
   657 for root, dirs, files in os.walk(setpath, topdown=False):
       
   658     for fname in files:
       
   659         filePattern = re.compile('.ant.xml$')
       
   660         fileMatch = filePattern.search(fname)
       
   661         modulelist = []
       
   662         if (fileMatch):
       
   663             filePath = os.path.abspath(os.path.join(root, fname))
       
   664             with open(filePath) as f:
       
   665                 filePathAmara = 'file:///'+ filePath.replace('\\','/')
       
   666                 curPrj=amara.parse(filePathAmara)
       
   667                 for line in f:
       
   668                     linePattern = re.compile('^import')
       
   669                     lineMatch = linePattern.search(line)
       
   670                     if ((lineMatch) and (line.find('.')==-1)):
       
   671                         newLine = line.replace('import','')
       
   672                         newLine = newLine.replace(',','')
       
   673                         moduleArray = newLine.split()
       
   674                         for curModule in moduleArray:
       
   675                             try:
       
   676                                 importModule = __import__(curModule)
       
   677                                 modulePath=importModule.__file__
       
   678                                 if (modulePath.find('\\helium\\tools')!= -1):
       
   679                                     for projectList in dbPrj.antDatabase.project:
       
   680                                         if (projectList.name==curPrj.project.name):
       
   681                                             if not (curModule in modulelist):
       
   682                                                 print " Python module : " +curModule
       
   683                                                 moduleElement = projectList.pythonDependency.xml_create_element(u'module', content=u''+curModule)
       
   684                                                 projectList.pythonDependency.xml_append(moduleElement)
       
   685                                             modulelist = modulelist + [curModule]
       
   686                             except Exception, e:
       
   687                                 error ="yes"
       
   688 
       
   689 
       
   690 file_object = codecs.open(r'${database.file}', 'w', "utf_8")
       
   691 file_object.write(dbPrj.xml(indent=u"yes"))
       
   692 file_object.close()
       
   693     
       
   694         </hlm:python>
       
   695     </target>
       
   696     
       
   697     
       
   698     <!-- Reads the Java libraries and extracts a list of their versions. -->
       
   699     <target name="library-versions">    
       
   700         <script language="jython" setbeans="false">
       
   701 import java.io
       
   702 import java.util.jar
       
   703 antlibsDir = java.io.File('external/antlibs')
       
   704 print antlibsDir
       
   705 jarFiles = antlibsDir.listFiles()
       
   706 for jar in jarFiles:
       
   707     if jar.getName().endswith('jar'):
       
   708         jarFile = java.util.jar.JarFile(jar)
       
   709         manifest = jarFile.getManifest()
       
   710         attributes = manifest.getMainAttributes()
       
   711         implementationVersion = attributes.getValue('Implementation-Version')
       
   712         print jar.getName() + ': ' + str(implementationVersion)
       
   713         </script>
       
   714     </target>
       
   715     
       
   716     <!-- Generates a subcon dependancy diagram based on Egg and Jars files -->
       
   717     <target name="dependency-diagram-subcon">
       
   718         <fileset id="subcon.jar.files" dir="${helium.dir}">
       
   719             <include name="external/antlibs/*.jar"/>
       
   720             <include name="external/jep/**/*.jar"/>
       
   721             <include name="external/helium-antlib/bin/**/*.jar"/>
       
   722             <include name="tools/**/*.jar"/>
       
   723         </fileset>
       
   724         <antcall target="dependency-diagram">
       
   725             <reference refid="subcon.jar.files" torefid="jar.files"/>
       
   726             <param name="python.exclude.dir" value="${helium.dir}\external\python\lib\2.5\internal"/>
       
   727             <param name="dependency.grph" value="${helium.build.dir}/doc/images/dependencies_subcon.grph"/>
       
   728             <param name="subcon" value="true"/>
       
   729         </antcall>
       
   730     </target>
       
   731     
       
   732     <fileset id="jar.files" dir="${helium.dir}">
       
   733         <include name="external/antlibs/**/*.jar"/>
       
   734         <include name="external/jep/**/*.jar"/>
       
   735         <include name="external/helium-antlib/**/*.jar"/>
       
   736         <include name="tools/**/*.jar"/>
       
   737         <include name="extensions/nokia/external/antlibs/**/*.jar"/>
       
   738     </fileset>
       
   739     
       
   740     <!-- Generates a dependancy diagram based on Egg and Jars files -->
       
   741     <target name="dependency-diagram">
       
   742         <mkdir dir="${helium.build.dir}/doc/images"/>
       
   743         <mkdir dir="${temp.build.dir}"/>
       
   744         <property name="dependency.grph" value="${helium.build.dir}/doc/images/dependencies.grph"/>
       
   745         
       
   746         <!---->
       
   747         <copy todir="${temp.build.dir}/dependencylibs" flatten="true">
       
   748             <fileset refid="jar.files"/>
       
   749         </copy>
       
   750         
       
   751         <hlm:antdependency outputFile="${temp.build.dir}/antdependencies.grph">
       
   752             <fileset dir="${temp.build.dir}/dependencylibs" includes="*.jar"/>
       
   753         </hlm:antdependency>
       
   754         
       
   755         <taskdef name="jaranalyzer" classname="com.kirkk.analyzer.textui.JarAnalyzerTask"/>
       
   756         <jaranalyzer srcdir="${temp.build.dir}/dependencylibs" destfile="${dependency.grph}" summaryclass="com.kirkk.analyzer.textui.DOTSummary"/>
       
   757         
       
   758         <loadfile srcfile="${temp.build.dir}/antdependencies.grph" property="antdependencies"/>
       
   759         <replace file="${dependency.grph}" token="}" value="${antdependencies}}"/>
       
   760         
       
   761         <antcall target="dependency-grouping"/>
       
   762         
       
   763         <exec executable="dot">
       
   764             <arg line="-Tpng -Grankdir=LR -Nshape=box -Nfontsize=9 -Nwidth=0.3 -Nheight=0.2 ${dependency.grph} -O"/>
       
   765         </exec>
       
   766         
       
   767         <delete dir="${temp.build.dir}/dependencylibs"/>
       
   768         
       
   769     </target>
       
   770     
       
   771     <!-- Private: -->
       
   772     <target name="dependency-grouping">
       
   773         <property name="dependency.grph" value="${helium.build.dir}/doc/images/dependencies.grph"/>
       
   774         <mkdir dir="${helium.build.dir}/doc/images"/>
       
   775         <property name="python.internal.dir" value="${nokia.dir}\external\python\lib\2.5"/>
       
   776         <property name="subcon" value=""/>
       
   777         <property name="ivy.xml.file" value="${helium.dir}/config/ivy/ivy.xml"/>
       
   778         <hlm:python>
       
   779 import os
       
   780 import dependancygraph
       
   781 
       
   782 dependancygraph.createGraph(r'${ivy.xml.file}', r'${dependency.grph}', r'${python.dir}', r'${python.internal.dir}', r'${subcon}')
       
   783         </hlm:python>
       
   784         <!--
       
   785         <exec executable="dot">
       
   786             <arg line="-Tpng -Grankdir=LR -Nshape=box -Nfontsize=9 -Nwidth=0.3 -Nheight=0.2 ${dependency.egg.grph} -O"/>
       
   787         </exec>
       
   788         -->
       
   789     </target>
       
   790     
       
   791     <!-- Generates a dependancy diagram of ant projects to helium external files -->
       
   792     <target name="dependency-external">
       
   793         <property name="dependency.external.grph" value="${helium.build.dir}/doc/images/dependencies_external.grph"/>
       
   794         <copy file="${database.file}" tofile="${database.file}.parsed" overwrite="true">
       
   795             <filterchain>
       
   796                 <expandproperties/>
       
   797             </filterchain>
       
   798         </copy>
       
   799         <hlm:python>
       
   800 import os
       
   801 import dependancygraph
       
   802 
       
   803 dependancygraph.externalDependancies(r'${database.file}.parsed', r'${dependency.external.grph}')
       
   804         </hlm:python>
       
   805         <!---->
       
   806         <exec executable="dot">
       
   807             <arg line="-Tpng -Grankdir=LR -Nshape=box -Nfontsize=9 -Nwidth=0.3 -Nheight=0.2 ${dependency.external.grph} -O"/>
       
   808         </exec>
       
   809         
       
   810     </target>
       
   811     
       
   812     <!-- Private: Convert db file -->
       
   813     <target name="dependency-db-convert" depends="database">
       
   814         <copy file="${database.file}" tofile="${database.file}.parsed" overwrite="true">
       
   815             <filterchain>
       
   816                 <expandproperties/>
       
   817             </filterchain>
       
   818         </copy>
       
   819     </target>
       
   820     
       
   821     <!-- Generates a dependancy diagram of log files -->
       
   822     <target name="dependency-logs">
       
   823         <property name="dependency.external.grph" value="${helium.build.dir}/doc/images/dependencies_log.grph"/>
       
   824         
       
   825         <antcall target="dependency-db-convert" inheritAll="false">
       
   826             <param name="build.drive" value="build.drive"/>
       
   827             <param name="build.id" value="build.id"/>
       
   828             <param name="build.log.dir" value="/output/logs"/>
       
   829         </antcall>
       
   830         
       
   831         <hlm:python>
       
   832 import os
       
   833 import dependancygraph
       
   834 
       
   835 dependancygraph.findLogFiles(r'${database.file}.parsed', r'${dependency.external.grph}')
       
   836         </hlm:python>
       
   837         <!---->
       
   838         <exec executable="dot">
       
   839             <arg line="-Tpng -Grankdir=LR -Nshape=box -Nfontsize=9 -Nwidth=0.3 -Nheight=0.2 ${dependency.external.grph} -O"/>
       
   840         </exec>
       
   841         
       
   842     </target>
       
   843     
       
   844     <!-- Download data listening logs and extract data -->
       
   845     <target name="parse-datalistening">
       
   846         <exec executable="python" dir="${helium.dir}/tools/common/python/lib" failonerror="${failonerror}">
       
   847             <arg value="parsedatalistening.py"/>
       
   848         </exec>
       
   849     </target>
       
   850 
       
   851     <!-- Creates user flow diagram -->
       
   852     <target name="helium-user-graph">
       
   853         <mkdir dir="${helium.build.dir}/doc/api"/>
       
   854         <fmpp sourcefile="${helium.doc.dir}/src/user-graph.dot.ftl" outputfile="${helium.build.dir}/temp/doc/user-graph.dot">
       
   855             <data expandProperties="yes">
       
   856               ant: antProperties()
       
   857             </data>
       
   858         </fmpp>
       
   859         <for param="dot.file">
       
   860             <fileset dir="${helium.build.dir}/temp/doc" includes="user-graph.dot"/>
       
   861             <sequential>
       
   862                 <echo>Processing dot file: @{dot.file}</echo>
       
   863                 <exec executable="dot" dir="${helium.build.dir}/temp/doc/">
       
   864                     <arg line="-Tcmap @{dot.file} -O"/>
       
   865                 </exec>
       
   866                 <exec executable="dot" dir="${helium.build.dir}/doc/api">
       
   867                     <arg line="-Tpng @{dot.file} -O"/>
       
   868                 </exec>
       
   869             </sequential>
       
   870         </for>
       
   871         <move todir="${helium.build.dir}/doc/images" overwrite="true">
       
   872             <fileset dir="${helium.build.dir}/temp/doc" includes="user-graph.dot.png"/>
       
   873         </move>
       
   874     </target>
       
   875 
       
   876 </project>