MOOS 0.2375
|
00001 ################################################################## 00002 # rough and ready python script to build all latex documentation 00003 # call this by running "python MakeDocumentation" 00004 # NB this is a script to help pnewman maintain the documentation 00005 # and as such is at the moment only runnable on linux 00006 ################################################################## 00007 00008 import os , shutil 00009 path = "." 00010 sResultFile = 'buildresult' 00011 00012 def MakePDF(dirname, FileName): 00013 print "making latex in "+ dirname + "from" +FileName 00014 InitialDir = os.getcwd() 00015 NewDir = os.path.join(os.getcwd(),dirname) 00016 os.chdir(NewDir); 00017 00018 if os.path.exists(sResultFile): 00019 print "removing existing results file..\n" 00020 os.remove(sResultFile); 00021 00022 sTee = ' | tee -a '+ sResultFile; 00023 sLatexCmd = 'latex ' + FileName + sTee; 00024 sPDFCmd = 'dvipdf ' + os.path.splitext(FileName)[0] + sTee; 00025 os.system(sLatexCmd); 00026 os.system(sLatexCmd); 00027 os.system(sPDFCmd); 00028 os.chdir(InitialDir); 00029 00030 00031 def MakeDoxygenDocs(SourcePath): 00032 00033 00034 DoxyFile = 'Template.doxy'; 00035 TmpDoxy = 'MOOS.doxy' 00036 ProjectName = os.path.basename(SourcePath); 00037 Destination = SourcePath.replace(os.pardir,os.path.join(os.pardir,'Docs','Source')); 00038 00039 print 'Making Doxygen documentation for %s in %s ' % (SourcePath,Destination); 00040 00041 file = open(DoxyFile, "r") #Opens the file in read-mode 00042 text = file.read() #Reads the file and assigns the value to a variable 00043 file.close() #Closes the file (read session) 00044 00045 text = text.replace('$PROJECTNAME',ProjectName); 00046 text = text.replace('$DOCDIR',Destination); 00047 text = text.replace('$SOURCEDIR',SourcePath); 00048 00049 file = open(TmpDoxy, "w") #Opens the file again, this time in write-mode 00050 file.write(text) 00051 file.close() #Closes the file (write session) 00052 00053 sDoxygenCommand = 'doxygen %s' % TmpDoxy; 00054 # finally call doxygen.. 00055 os.system(sDoxygenCommand); 00056 00057 #need to copy header image file to html directory.. 00058 shutil.copy('resources/moose7.gif',os.path.join(Destination,'html')); 00059 00060 #make latex... 00061 here = os.getcwd(); 00062 os.chdir(os.path.join(Destination,'latex')); 00063 os.system('make'); 00064 os.system('dvipdf refman.dvi %s.pdf' % (ProjectName)); 00065 os.chdir(here); 00066 00067 00068 #make latex on each of the directories 00069 for directory in os.walk(path): 00070 if directory[0].endswith("latex") and directory[0]!='Legacy' and directory[2].count('doxygen.sty')==0: 00071 for File in directory[2]: 00072 if File.endswith(".tex"): 00073 MakePDF(directory[0],File) 00074 00075 00076 00077 #make doxygen files 00078 sourcepath = '../'; 00079 DoxygenDirs = ["MOOSLIB", "MOOSGenLib"]; 00080 for directory in os.walk(sourcepath): 00081 00082 bn = os.path.basename(directory[0]); 00083 parts = directory[0].split(os.sep); 00084 00085 if(bn in DoxygenDirs and len(parts)>1 and parts[1] != 'Docs' ): 00086 MakeDoxygenDocs(directory[0]); 00087 00088 00089 00090 # print a listing of the outcomes 00091 print "Any Errors in compilation are stated here..." 00092 os.system('find -name '+ sResultFile + ' -print | xargs grep Error'); 00093 print "Any warnings in compilation are stated here..." 00094 os.system('find -name '+ sResultFile + ' -print | xargs grep Warning'); 00095