From: <mic...@us...> - 2008-08-25 06:11:42
|
Revision: 5269 http://octave.svn.sourceforge.net/octave/?rev=5269&view=rev Author: michaelschmid Date: 2008-08-25 06:11:50 +0000 (Mon, 25 Aug 2008) Log Message: ----------- docu improvements added doc/docReadme added doc/latex/perl added doc/latex/perl/analyzeOctaveSource.pm added doc/latex/perl/createTestDocu.pl Added Paths: ----------- trunk/octave-forge/main/nnet/doc/docReadme trunk/octave-forge/main/nnet/doc/latex/perl/ trunk/octave-forge/main/nnet/doc/latex/perl/analyzeOctaveSource.pm trunk/octave-forge/main/nnet/doc/latex/perl/createTestDocu.pl Added: trunk/octave-forge/main/nnet/doc/docReadme =================================================================== --- trunk/octave-forge/main/nnet/doc/docReadme (rev 0) +++ trunk/octave-forge/main/nnet/doc/docReadme 2008-08-25 06:11:50 UTC (rev 5269) @@ -0,0 +1,29 @@ +The directory nnet/doc contains two subdirectories. +1. latex: This includes five (5) subdirectories. All of them + are used to create the newest version of the documentation. + + asymptote: Includes asy-scripts to create graphics, used in + subdirectory users/octave/neuroToolbox/graphics. For pdf output + the graphic files must be in pdf format. For dvi output, the + graphics must be in eps format. That's why I create each time + both types. Used asymptote is version: 1.42 win version + + common: Contains some .tex files which are used in both documentations. + developer as users guide. + + developers: Contains .tex files with a lot of informations about + how I did the most parts of this package. Not all of them are + completly written ... :-( + + perl: Contains two files. The first one is a "modul" to put somewhere + in a lib directory in the perl installation. This file end with .pm. + The second file (createTestDocu.pl) is a short perl script to generate + some .tex files for the developer guide which contains all the test + cases programmed in the function files. In the file createTestDocu.pl + must be changed some variables to the local system likewise it must be + copied to the "developers" directory! + + users: The user's guide. The official documentation to the neural network + package! + +2. pdf: Contains documentation generated of the latex directory. Added: trunk/octave-forge/main/nnet/doc/latex/perl/analyzeOctaveSource.pm =================================================================== --- trunk/octave-forge/main/nnet/doc/latex/perl/analyzeOctaveSource.pm (rev 0) +++ trunk/octave-forge/main/nnet/doc/latex/perl/analyzeOctaveSource.pm 2008-08-25 06:11:50 UTC (rev 5269) @@ -0,0 +1,66 @@ +package analyzeOctaveSource; + +use File::Find; + +sub new { + my $Objekt = shift; + my $Referenz = {}; + bless($Referenz,$Objekt); + return($Referenz); +} + +sub readDirTree{ + my $Objekt = shift; + my $Dir = shift; + my $fileExt = shift; + my $File; + # read directory + my @dirArray = (); + + find sub { push @dirArray, $File::Find::name }, $Dir; + + # remove all files except with file ending $fileExt + @DirArray = grep /.+\.$fileExt/ , @DirArray; + my $nFiles = @dirArray; + if ($nFiles==0){ + print "No Octave files found.\n"; + print "Octave files must end with *.m\n"; + die " ==========================\n"; + } + return @dirArray; +} + +sub searchFilesContainTestLines{ + my $Objekt = shift; + my @dirArray = shift; + + # + my $fileName = ""; + my @fileContent = (); + my @fileArray = (); + my @temp = (); + my $nTemp = ""; + + foreach (@dirArray){ + # open file and search for lines beginning with + # !% + if (-d $_){ + # if directory, do nothing + }else{ + open(FILE,$_) or die "File $_ not found!\n"; + @fileContent = <FILE>; + close FILE; + @temp = grep /^!%/, @fileContent; + $nTemp = @temp; + if ($nTemp>0){ + @fileArray = $_ + } + } + } + + return @fileArray; +} + + +1; + Added: trunk/octave-forge/main/nnet/doc/latex/perl/createTestDocu.pl =================================================================== --- trunk/octave-forge/main/nnet/doc/latex/perl/createTestDocu.pl (rev 0) +++ trunk/octave-forge/main/nnet/doc/latex/perl/createTestDocu.pl 2008-08-25 06:11:50 UTC (rev 5269) @@ -0,0 +1,145 @@ +#!/usr/bin/perl -w + +use strict; +use diagnostics;# Force verbose warning diagnostics. +use warnings; +use English; + +# +# Modules from the Standard Perl Library. + + +# +# Own modules +use analyzeOctaveSource; + + +#--- DEFINE VARIABLES ------------------------------- +my $Dir = "U:\\DATEN\\octave\\octnnettb\\nnet-0.1.3\\inst"; +my $fileExt = "m"; +my $testDir = "U:\\DATEN\\octave\\octnnettb\\documentation\\latex\\developers\\tests"; +my $relTestDir = "tests/"; +my $testFileExt = "tex"; +my $mainLatexTestFile = "test.tex"; +my $chapter = "Test"; +#--- END DEFINE VARIABLES --------------------------- + + +my @filesArray = (); +my @filesName = (); +my $fileName = ""; +my $savePath = ""; +my $nTestLines = 0; +my $m = 0; + +# analyze directory structure +my $obj = analyzeOctaveSource->new(); +my @DirArray = $obj->readDirTree($Dir,$fileExt); + +# analyze file structure +my $nFiles = @DirArray; +if ($nFiles>=1){ # if $nFiles==0 readDirTree will die + # if we are in this branch, we should check the files + # to found those which content tests (lines beginning with + # !% ) + foreach (@DirArray){ + # open file and search for lines beginning with + # !% + if (-d $_){ + # if directory, do nothing + }else{ + print "$_\n"; + sleep(0.1); + + open(FILE,$_) or die "File $_ not found!\n"; + my @fileContent = <FILE>; + chomp(@fileContent); + $nTestLines = @fileContent; + my @temp = grep /^%!/, @fileContent; + my $nTemp = @temp; + if ($nTemp>0){ # this means, + # test lines are available + # now create latex files without header + # take the same name like the *.m file + # and save in specified directory $testDir + # with file extens in $testFileExt + # use verbatim environment + @filesName = split(/\//, $_); + $fileName = $filesName[$#filesName]; + # now remove file extension .m + @filesName = split(/\./,$fileName); + $savePath = ("$testDir" . "\\\\" . "$filesName[0]." . "$testFileExt"); + open(OUTFILE, ">$savePath"); + my $i = 0; + print OUTFILE "\\begin{verbatim}\n"; + while ($i < $nTestLines){ + if ($fileContent[$i]=~/^%!/){ + print OUTFILE "$fileContent[$i]\n"; + } + $i++; + } # END while ($i <= $#fileContent) + print OUTFILE "\\end{verbatim}\n"; + close OUTFILE; + + ## now set entries in the main test latex file .. + my $mainTestFile = ("$testDir" . "\\\\" . "$mainLatexTestFile"); + if ($m==0){ + open(TESTFILE,">$mainTestFile") or die "Could not found file $mainTestFile!\n"; + print TESTFILE "\\chapter{$chapter}\n\n"; + # test if back slash needed + my $tempString = ""; + my $oldString = $filesName[0]; + if ($filesName[0]=~/_/){ + my $pos = 0; #temp Position + my $posBefore = 0; + while ($pos < (length $filesName[0]) and $pos != -1){ + $pos = index($filesName[0], "_", $pos); + if ($pos != -1 ){ + $tempString = substr($filesName[0],$posBefore,$pos) . "\\" . substr($filesName[0],$pos,length $filesName[0]); + $posBefore = $pos; + $pos++; + } + }# END while ($pos < ...) + $filesName[0] = $tempString; + } + + print TESTFILE "\\section{$filesName[0]}\n"; + $tempString = $relTestDir . $oldString; + print TESTFILE "\\input{$tempString}\n"; + }else{ + open(TESTFILE,">>$mainTestFile") or die "Could not found file $mainTestFile!\n"; + # test if back slash needed + my $tempString = ""; + my $oldString = $filesName[0]; + if ($filesName[0]=~/_/){ + my $pos = 0; #temp Position + my $posBefore = 0; + while ($pos < (length $filesName[0]) and $pos != -1){ + $pos = index($filesName[0], "_", $pos); + if ($pos != -1 ){ + $tempString = substr($filesName[0],$posBefore,$pos) . "\\" . substr($filesName[0],$pos,length $filesName[0]); + $pos++; + } + }# END while ($pos < ...) + $filesName[0] = $tempString; + } + + print TESTFILE "\\section{$filesName[0]}\n"; + $tempString = $relTestDir . $oldString; + print TESTFILE "\\input{$tempString}\n"; + } + $m++; + close TESTFILE; + + + }# END if($nTemp>0) + close FILE; + + }# END if(-d $_) + + }# END foreach (@DirArray) + +}else{ # if $nFiles==0 + print "No file found with valid file extension: .$fileExt.\n"; + die; +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |