diff --git a/confluence/examples.par b/confluence/examples.par index 123af181b..4c1891ee2 100644 --- a/confluence/examples.par +++ b/confluence/examples.par @@ -21,6 +21,7 @@ GRIB ( BUFR ( bufr_attributes bufr_clone + bufr_encode_flight bufr_expanded bufr_get_keys bufr_keys_iterator diff --git a/confluence/load_examples.pl b/confluence/load_examples.pl index f526c5977..81c1e10bc 100755 --- a/confluence/load_examples.pl +++ b/confluence/load_examples.pl @@ -4,7 +4,7 @@ use Getopt::Long; use strict; #-------------------------------------------------- -# +# #-------------------------------------------------- #The root page of examples in confluence!!! @@ -29,7 +29,7 @@ my %langDir = ("f" => "F90", "p" => "python"); -my $CONF=$ENV{CONF}; +my $CONF=$ENV{CONF}; die "Env var CONF should point to confluence.sh script" if ( $CONF eq "" || ! -f "$CONF" ); my $inRootDir; @@ -42,7 +42,7 @@ my $confSpace="ECC"; GetOptions("inDir=s" => \$inRootDir, "confSpace=s" => \$confSpace) or die("Error in command line arguments\n"); - + print "confluence space=".$confSpace."\n"; #---------------------------------- @@ -71,14 +71,14 @@ unless ( -d $htmlDir ) { #--------------------------------------------------- foreach my $cType (keys %allExamples) { - + print "----------------------------------------\n"; print " Processing examples for: $cType\n"; print "----------------------------------------\n"; - + #Get the examples - my @examples=@{$allExamples{$cType}}; - + my @examples=@{$allExamples{$cType}}; + if($#examples+1 == 0) { die "No examples are defined!\n"; } @@ -89,57 +89,57 @@ foreach my $cType (keys %allExamples) { my $parentPage=parentPageTitle($cType); makeParentPage($rootPage,$parentPage,$htmlDir,$cType,@examples); - + #-------------------------------- # Loop for the examples #-------------------------------- - + foreach my $name (@examples) { - + my $fOut=$htmlDir."/".$cType."_".$name.".html"; - open(OUT,">$fOut") or die "$fOut: $!"; - + open(OUT,">$fOut") or die "$fOut: $!"; + #Description print OUT "

Description

"; print OUT "This example shows: ".getDescription($name)."\n"; - + #Create a tab container print OUT "

Source code

"; print OUT "horizontal"; - + #Add a tab for each language foreach my $i (@langKeys) { - + my $tabName=$langName{$i}; my $fName=$name.".".$langSuffix{$i}; my $fPath=$inRootDir."/".$langDir{$i}."/".$fName; my $lType=$langType{$i}; - + #Read sourcode into html format my $c=getSourceCode($fName,$fPath,$lType); - - #If there is a source creates a tab for it - #if(length($c) > 0) { - print OUT "".$tabName." + + #If there is a source creates a tab for it + if(length($c) > 0) { + print OUT "".$tabName." ".$c.""; - + } } - + #Close tab container - print OUT ""; + print OUT ""; close OUT; - - #Upload the file to confluence + + #Upload the file to confluence my $pageTitle=examplePageTitle($name); - loadToConf($fOut,$pageTitle,$parentPage); + loadToConf($fOut,$pageTitle,$parentPage); } -} +} #=========================================================== #=========================================================== # -# FUNCTIONS +# FUNCTIONS # #=========================================================== #=========================================================== @@ -167,9 +167,9 @@ sub read_examples { if ($line =~ /.*#/) {next;} #print $line."\n"; - + $line =~ s/\"//g; - + my ($a)=($line =~ /(\S+)\s*\(/); if($a and $a !~ /\!/) { $actType=$a; @@ -177,24 +177,23 @@ sub read_examples { #$res{$actType}; next; } - + if( $line =~ /\)/) { $actType=""; next; } - - if(length($actType) > 0) { + + if(length($actType) > 0) { my ($b) =($line =~ /(\S+)/); #print "ex: ".$b."\n"; if($b) { push(@{$res{$actType}},$b); } - } - + } } - + close IN; - + return %res; } @@ -203,11 +202,10 @@ sub read_examples { #----------------------------------------------------------------------------- sub parentPageTitle { - + my ($codeType) = @_; - - return $codeType." examples"; -} + return $codeType." examples"; +} #-------------------------------------------------------- # Create parent page for a given type of examples @@ -215,23 +213,23 @@ sub parentPageTitle { sub makeParentPage { my ($rootPage,$pageTitle,$outDir,$cType,@xmp) = @_; - + my $f=$outDir."/parent_".$cType."html"; - - open(OUT,">$f") or die "$f: $!"; - + + open(OUT,">$f") or die "$f: $!"; + my $str=""; $str=$str.""; - + foreach my $xm (@xmp) { $str=$str.""; - } - $str=$str."
ExampleDescription
".linkToPage($xm,examplePageTitle($xm))."".getDescription($xm)."
"; - + } + $str=$str.""; + print OUT $str; - + close OUT; - + #Load it to confluence loadToConf($f,$pageTitle,$rootPage); } @@ -239,35 +237,33 @@ sub makeParentPage { #----------------------------------------------------------------------------- # Genarate the page title for a given example #----------------------------------------------------------------------------- - sub examplePageTitle { - + my ($exName) = @_; - - return $exName; -} - + return $exName; +} + #----------------------------------------------------------- -# Get the file path for an example with the given language +# Get the file path for an example with the given language #----------------------------------------------------------- -sub examplePath { +sub examplePath { my ($name,$lang) = @_; return $inRootDir."/".$langDir{$lang}."/".$name.".".$langSuffix{$lang}; } #----------------------------------------------------------- -# Check if the file for a given example exists. +# Check if the file for a given example exists. #----------------------------------------------------------- sub hasExample { - + my ($name,$lang) = @_; my $f=examplePath($name,$lang); if( -e $f ) {return 1}; - + print "$f no!!!\n"; - + return 0; } @@ -276,25 +272,24 @@ sub hasExample { #------------------------------------------------------------ sub getSourceCode { - + my ($title,$fPath,$lang) = @_; - my $codeTxt; - + print $fPath."\n"; - + my $str; - + if($lang eq "") { $codeTxt=fortran_file_to_string($fPath); #return "

"; return "

".$codeTxt."
"; - } else { - open(IN,"<$fPath") or return ""; # die "$fPath: $!"; - $codeTxt=join("", ); + } else { + open(IN,"<$fPath") or return ""; # die "$fPath: $!"; + $codeTxt=join("", ); close IN; } - + $str=" ".$title." @@ -302,7 +297,7 @@ sub getSourceCode { ".$lang." "; - + return $str; } @@ -311,17 +306,15 @@ sub getSourceCode { #-------------------------------------------------------- sub getDescription { - + my ($name) = @_; - my $lang="c"; - my $res; - + if(hasExample($name,$lang)== 1) { my $f=examplePath($name,$lang); - - my $found=0; + + my $found=0; open (IN,"<$f") or return ""; while (defined (my $line = )) { #First row @@ -331,28 +324,28 @@ sub getDescription { my ($r)=($line =~ /\*\s*Description:\s*(.+)/); if(length($r) > 2) { $res=$r; - } - } + } + } } else { my ($r)=($line =~ /\*\s+(.+)/); if(length($r) > 2) { $res=$res." ".$r; } else { last; - } + } } - } - + } + #print $f."\n"; - #print "descr: ".$res."\n"; + #print "descr: ".$res."\n"; } - - return $res; -} + + return $res; +} #==================================================== # -# Generic functions related to confluence +# Generic functions related to confluence # #==================================================== @@ -361,20 +354,19 @@ sub getDescription { #-------------------------------- sub loadToConf { - + my ($fHtml,$title,$parentPage) = @_; - system("$CONF -a addPage --noConvert --replace --space \"$confSpace\" --title \"$title\" --parent \"$parentPage\" --file $fHtml"); -} +} #--------------------------------------- # Create link to a page #--------------------------------------- sub linkToPage { - + my ($page,$label) = @_; - + my $str=" @@ -383,13 +375,11 @@ sub linkToPage { "; return $str; -} +} sub makeInfo { - + my ($text) = @_; - return "false". "".$text.""; -} - +}