buildframework/helium/tools/common/docs.ant.xml
changeset 648 d5a8d436d33b
parent 645 b8d81fa19e7d
equal deleted inserted replaced
647:53d1ab72f5bc 648:d5a8d436d33b
    89     
    89     
    90     <!-- Generates an Ant XML database file showing only public content.
    90     <!-- Generates an Ant XML database file showing only public content.
    91     @scope private    
    91     @scope private    
    92     -->    
    92     -->    
    93     <target name="docs-database">
    93     <target name="docs-database">
       
    94         <mkdir dir="${basedir}/build"/>
    94         <hlm:database output="${public.database.file}" scope="public" filesetonly="true">
    95         <hlm:database output="${public.database.file}" scope="public" filesetonly="true">
    95             <fileset dir=".">
    96             <fileset dir=".">
    96                 <include name="**/*.ant.xml"/>
    97                 <include name="**/*.ant.xml"/>
    97                 <include name="**/build.xml"/>
    98                 <include name="**/build.xml"/>
    98             </fileset>
    99             </fileset>
   115         </fmpp>
   116         </fmpp>
   116         <for param="dot.file" parallel="true" threadCount="${number.of.threads}">
   117         <for param="dot.file" parallel="true" threadCount="${number.of.threads}">
   117             <fileset dir="${doc.temp.dir}/api/helium" includes="*.dot"/>
   118             <fileset dir="${doc.temp.dir}/api/helium" includes="*.dot"/>
   118             <sequential>
   119             <sequential>
   119                 <echo>Processing dot file: @{dot.file}</echo>
   120                 <echo>Processing dot file: @{dot.file}</echo>
   120                 <exec executable="dot" dir="${doc.temp.dir}/api/helium">
   121                 <exec executable="dot" dir="${doc.temp.dir}/api/helium" failonerror="true">
   121                     <arg line="-Tcmap @{dot.file} -O"/>
   122                     <arg line="-Tcmap @{dot.file} -O"/>
   122                 </exec>
   123                 </exec>
   123                 <exec executable="dot" dir="${doc.build.dir}/api">
   124                 <exec executable="dot" dir="${doc.build.dir}/api" failonerror="true">
   124                     <arg line="-Tpng @{dot.file} -O"/>
   125                     <arg line="-Tpng @{dot.file} -O"/>
   125                 </exec>
   126                 </exec>
   126             </sequential>
   127             </sequential>
   127         </for>
   128         </for>
   128         <move todir="${doc.build.dir}/api/helium" overwrite="true">
   129         <move todir="${doc.build.dir}/api/helium" overwrite="true">
   166     <target name="helium-apidocs" depends="clean-helium-apidocs,docs-database,
   167     <target name="helium-apidocs" depends="clean-helium-apidocs,docs-database,
   167                     helium-api-dependency-images,helium-api-rst-docs"/>
   168                     helium-api-dependency-images,helium-api-rst-docs"/>
   168 
   169 
   169     
   170     
   170     <!-- Generate API documentation from the source code. -->
   171     <!-- Generate API documentation from the source code. -->
   171     <target name="apidocs" depends="helium-apidocs"/>
   172     <target name="apidocs" depends="helium-apidocs" unless="env.HLM_SUBCON">
   172     
   173         <exec executable="cmd" osfamily="windows" dir="${helium.dir}/nokia_builder" failonerror="true">
       
   174             <arg line="/C bld doc" />
       
   175         </exec>
       
   176     </target>
   173     
   177     
   174     <!-- Macro to generate HTML docs from rst. -->
   178     <!-- Macro to generate HTML docs from rst. -->
   175     <macrodef name="rstPrepMacro" uri="http://www.nokia.com/helium">
   179     <macrodef name="rstPrepMacro" uri="http://www.nokia.com/helium">
   176         <attribute name="destdir"/>
   180         <attribute name="destdir"/>
   177         <element name="resources-elements" implicit="yes"/>
   181         <element name="resources-elements" implicit="yes"/>
   230                 <available file="${nokia.python.tools}/sphinxfixsearch.diff"/>
   234                 <available file="${nokia.python.tools}/sphinxfixsearch.diff"/>
   231                 <then>
   235                 <then>
   232                     <patch reverse="true" patchfile="${nokia.python.tools}/sphinxfixsearch.diff" originalfile="${sphinx.lib.dir}/search.py"/>
   236                     <patch reverse="true" patchfile="${nokia.python.tools}/sphinxfixsearch.diff" originalfile="${sphinx.lib.dir}/search.py"/>
   233                 </then>
   237                 </then>
   234             </if>
   238             </if>
       
   239             <copy todir="@{output}" overwrite="true">
       
   240                 <fileset dir="@{src}">
       
   241                     <include name="**/*.zip"/>
       
   242                 </fileset>
       
   243             </copy>
   235         </sequential>
   244         </sequential>
   236     </macrodef>
   245     </macrodef>
   237     
   246     
   238     
   247     
   239     <!-- Generate search index for apis -->
   248     <!-- Generate search index for apis -->
   259                 out.close()
   268                 out.close()
   260                 
   269                 
   261             try:
   270             try:
   262                 rstfile = codecs.open(rstfilename, 'r', 'utf8')
   271                 rstfile = codecs.open(rstfilename, 'r', 'utf8')
   263                 rstfile.read()
   272                 rstfile.read()
   264             except:
   273             except UnicodeError:
   265                 print rstfilename + ' has invalid unicode'
   274                 print rstfilename + ' has invalid unicode'
   266                 rstfile.close()
   275                 rstfile.close()
   267                 os.remove(rstfilename)
   276                 os.remove(rstfilename)
   268         </hlm:python>
   277         </hlm:python>
   269         
   278         
   311 
   320 
   312         <resources id="textdoc.all.paths">
   321         <resources id="textdoc.all.paths">
   313             <!-- default doc content is always processed first -->
   322             <!-- default doc content is always processed first -->
   314             <path>
   323             <path>
   315                 <pathelement path="${helium.dir}/doc/default"/>
   324                 <pathelement path="${helium.dir}/doc/default"/>
   316                 <pathelement path="${helium.dir}/doc/src/manual"/>
       
   317             </path>
   325             </path>
   318             <resources refid="textdoc.paths"/>
   326             <resources refid="textdoc.paths"/>
   319         </resources>
   327         </resources>
   320         <hlm:rstPrepMacro destdir="${doc.temp.dir}">
   328         <hlm:rstPrepMacro destdir="${doc.temp.dir}">
   321             <resources refid="textdoc.all.paths"/>    
   329             <resources refid="textdoc.all.paths"/>    
   329                 <include name="**/*.dot"/>
   337                 <include name="**/*.dot"/>
   330                 <exclude name="api/helium/**/*.dot"/>
   338                 <exclude name="api/helium/**/*.dot"/>
   331             </fileset>
   339             </fileset>
   332             <sequential>
   340             <sequential>
   333                 <echo>Building dot file: @{dot.file}</echo>
   341                 <echo>Building dot file: @{dot.file}</echo>
   334                 <exec executable="dot">
   342                 <exec executable="dot" failonerror="true">
   335                     <arg line="-Tpng @{dot.file} -O"/>
   343                     <arg line="-Tpng @{dot.file} -O"/>
   336                 </exec>
   344                 </exec>
   337             </sequential>
   345             </sequential>
   338         </for>
   346         </for>
   339     </target>
   347     </target>
   373     <!-- Cleans all documentation. -->
   381     <!-- Cleans all documentation. -->
   374     <target name="clean-docs" depends="clean-helium-apidocs,clean-textdocs"/>
   382     <target name="clean-docs" depends="clean-helium-apidocs,clean-textdocs"/>
   375     
   383     
   376     
   384     
   377     <!-- generate all the user documentation for helium -->
   385     <!-- generate all the user documentation for helium -->
   378     <target name="docs" depends="clean-docs,apidocs,textdocs"/>
   386     <target name="docs" depends="clean-docs,apidocs,textdocs,docs-check-links"/>
   379 
   387 
       
   388     <!-- Check links in docs -->
       
   389     <target name="docs-check-links">
       
   390         <hlm:python failonerror="true">
       
   391 <![CDATA[
       
   392 import os
       
   393 error = ''
       
   394 for root, dirs, files in os.walk(r'${doc.build.dir}', topdown=False):
       
   395     for fname in files:
       
   396         if '.htm' in fname:
       
   397             filename = os.path.abspath(os.path.join(root, fname))
       
   398             f = open(filename)
       
   399             for line in f:
       
   400                 if ' src="' in line:
       
   401                     line1 = line.split('src="')[1]
       
   402                     line1 = line1.split('"')[0]
       
   403                     os.chdir(root)
       
   404                     if line1 and not os.path.exists(line1) and not ':' in line1 and not '$' in line1:
       
   405                         error = error + filename + ' has a broken link ' + line1 + '\n'
       
   406                 if ' href="' in line:
       
   407                     line = line.split('href="')[1]
       
   408                     line = line.split('"')[0]
       
   409                     if '#' in line:
       
   410                         line = line.split('#')[0]
       
   411                     if '?' in line:
       
   412                         line = line.split('?')[0]
       
   413                     os.chdir(root)
       
   414                     if line and not os.path.exists(line) and not ':' in line and not '&' in line:
       
   415                         error = error + filename + ' has a broken link ' + line + '\n'
       
   416             f.close()
       
   417 if error != '':
       
   418     raise Exception(error)
       
   419 ]]>
       
   420         </hlm:python>
       
   421     </target>
   380 </project>
   422 </project>