mirror of https://github.com/ecmwf/eccodes.git
Added bufr_encode_flight example. Also dont add a tab for example if lang missing
This commit is contained in:
parent
ebd512b166
commit
f8ff633b48
|
@ -21,6 +21,7 @@ GRIB (
|
||||||
BUFR (
|
BUFR (
|
||||||
bufr_attributes
|
bufr_attributes
|
||||||
bufr_clone
|
bufr_clone
|
||||||
|
bufr_encode_flight
|
||||||
bufr_expanded
|
bufr_expanded
|
||||||
bufr_get_keys
|
bufr_get_keys
|
||||||
bufr_keys_iterator
|
bufr_keys_iterator
|
||||||
|
|
|
@ -4,7 +4,7 @@ use Getopt::Long;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
#--------------------------------------------------
|
#--------------------------------------------------
|
||||||
#
|
#
|
||||||
#--------------------------------------------------
|
#--------------------------------------------------
|
||||||
|
|
||||||
#The root page of examples in confluence!!!
|
#The root page of examples in confluence!!!
|
||||||
|
@ -29,7 +29,7 @@ my %langDir = ("f" => "F90",
|
||||||
"p" => "python");
|
"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" );
|
die "Env var CONF should point to confluence.sh script" if ( $CONF eq "" || ! -f "$CONF" );
|
||||||
|
|
||||||
my $inRootDir;
|
my $inRootDir;
|
||||||
|
@ -42,7 +42,7 @@ my $confSpace="ECC";
|
||||||
GetOptions("inDir=s" => \$inRootDir,
|
GetOptions("inDir=s" => \$inRootDir,
|
||||||
"confSpace=s" => \$confSpace)
|
"confSpace=s" => \$confSpace)
|
||||||
or die("Error in command line arguments\n");
|
or die("Error in command line arguments\n");
|
||||||
|
|
||||||
print "confluence space=".$confSpace."\n";
|
print "confluence space=".$confSpace."\n";
|
||||||
|
|
||||||
#----------------------------------
|
#----------------------------------
|
||||||
|
@ -71,14 +71,14 @@ unless ( -d $htmlDir ) {
|
||||||
#---------------------------------------------------
|
#---------------------------------------------------
|
||||||
|
|
||||||
foreach my $cType (keys %allExamples) {
|
foreach my $cType (keys %allExamples) {
|
||||||
|
|
||||||
print "----------------------------------------\n";
|
print "----------------------------------------\n";
|
||||||
print " Processing examples for: $cType\n";
|
print " Processing examples for: $cType\n";
|
||||||
print "----------------------------------------\n";
|
print "----------------------------------------\n";
|
||||||
|
|
||||||
#Get the examples
|
#Get the examples
|
||||||
my @examples=@{$allExamples{$cType}};
|
my @examples=@{$allExamples{$cType}};
|
||||||
|
|
||||||
if($#examples+1 == 0) {
|
if($#examples+1 == 0) {
|
||||||
die "No examples are defined!\n";
|
die "No examples are defined!\n";
|
||||||
}
|
}
|
||||||
|
@ -89,57 +89,57 @@ foreach my $cType (keys %allExamples) {
|
||||||
|
|
||||||
my $parentPage=parentPageTitle($cType);
|
my $parentPage=parentPageTitle($cType);
|
||||||
makeParentPage($rootPage,$parentPage,$htmlDir,$cType,@examples);
|
makeParentPage($rootPage,$parentPage,$htmlDir,$cType,@examples);
|
||||||
|
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
# Loop for the examples
|
# Loop for the examples
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
|
|
||||||
foreach my $name (@examples) {
|
foreach my $name (@examples) {
|
||||||
|
|
||||||
my $fOut=$htmlDir."/".$cType."_".$name.".html";
|
my $fOut=$htmlDir."/".$cType."_".$name.".html";
|
||||||
open(OUT,">$fOut") or die "$fOut: $!";
|
open(OUT,">$fOut") or die "$fOut: $!";
|
||||||
|
|
||||||
#Description
|
#Description
|
||||||
print OUT "<h3>Description</h3>";
|
print OUT "<h3>Description</h3>";
|
||||||
print OUT "This example shows: <i>".getDescription($name)."</i>\n";
|
print OUT "This example shows: <i>".getDescription($name)."</i>\n";
|
||||||
|
|
||||||
#Create a tab container
|
#Create a tab container
|
||||||
print OUT "<h3>Source code</h3>";
|
print OUT "<h3>Source code</h3>";
|
||||||
print OUT "<ac:structured-macro ac:name=\"auitabs\"><ac:parameter ac:name=\"direction\">horizontal</ac:parameter><ac:rich-text-body>";
|
print OUT "<ac:structured-macro ac:name=\"auitabs\"><ac:parameter ac:name=\"direction\">horizontal</ac:parameter><ac:rich-text-body>";
|
||||||
|
|
||||||
#Add a tab for each language
|
#Add a tab for each language
|
||||||
foreach my $i (@langKeys) {
|
foreach my $i (@langKeys) {
|
||||||
|
|
||||||
my $tabName=$langName{$i};
|
my $tabName=$langName{$i};
|
||||||
my $fName=$name.".".$langSuffix{$i};
|
my $fName=$name.".".$langSuffix{$i};
|
||||||
my $fPath=$inRootDir."/".$langDir{$i}."/".$fName;
|
my $fPath=$inRootDir."/".$langDir{$i}."/".$fName;
|
||||||
my $lType=$langType{$i};
|
my $lType=$langType{$i};
|
||||||
|
|
||||||
#Read sourcode into html format
|
#Read sourcode into html format
|
||||||
my $c=getSourceCode($fName,$fPath,$lType);
|
my $c=getSourceCode($fName,$fPath,$lType);
|
||||||
|
|
||||||
#If there is a source creates a tab for it
|
#If there is a source creates a tab for it
|
||||||
#if(length($c) > 0) {
|
if(length($c) > 0) {
|
||||||
print OUT "<ac:structured-macro ac:name=\"auitabspage\"><ac:parameter ac:name=\"title\">".$tabName."</ac:parameter>
|
print OUT "<ac:structured-macro ac:name=\"auitabspage\"><ac:parameter ac:name=\"title\">".$tabName."</ac:parameter>
|
||||||
<ac:rich-text-body>".$c."</ac:rich-text-body></ac:structured-macro>";
|
<ac:rich-text-body>".$c."</ac:rich-text-body></ac:structured-macro>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Close tab container
|
#Close tab container
|
||||||
print OUT "</ac:rich-text-body></ac:structured-macro>";
|
print OUT "</ac:rich-text-body></ac:structured-macro>";
|
||||||
|
|
||||||
close OUT;
|
close OUT;
|
||||||
|
|
||||||
#Upload the file to confluence
|
#Upload the file to confluence
|
||||||
my $pageTitle=examplePageTitle($name);
|
my $pageTitle=examplePageTitle($name);
|
||||||
loadToConf($fOut,$pageTitle,$parentPage);
|
loadToConf($fOut,$pageTitle,$parentPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#===========================================================
|
#===========================================================
|
||||||
#===========================================================
|
#===========================================================
|
||||||
#
|
#
|
||||||
# FUNCTIONS
|
# FUNCTIONS
|
||||||
#
|
#
|
||||||
#===========================================================
|
#===========================================================
|
||||||
#===========================================================
|
#===========================================================
|
||||||
|
@ -167,9 +167,9 @@ sub read_examples {
|
||||||
if ($line =~ /.*#/) {next;}
|
if ($line =~ /.*#/) {next;}
|
||||||
|
|
||||||
#print $line."\n";
|
#print $line."\n";
|
||||||
|
|
||||||
$line =~ s/\"//g;
|
$line =~ s/\"//g;
|
||||||
|
|
||||||
my ($a)=($line =~ /(\S+)\s*\(/);
|
my ($a)=($line =~ /(\S+)\s*\(/);
|
||||||
if($a and $a !~ /\!/) {
|
if($a and $a !~ /\!/) {
|
||||||
$actType=$a;
|
$actType=$a;
|
||||||
|
@ -177,24 +177,23 @@ sub read_examples {
|
||||||
#$res{$actType};
|
#$res{$actType};
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $line =~ /\)/) {
|
if( $line =~ /\)/) {
|
||||||
$actType="";
|
$actType="";
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(length($actType) > 0) {
|
if(length($actType) > 0) {
|
||||||
my ($b) =($line =~ /(\S+)/);
|
my ($b) =($line =~ /(\S+)/);
|
||||||
#print "ex: ".$b."\n";
|
#print "ex: ".$b."\n";
|
||||||
if($b) {
|
if($b) {
|
||||||
push(@{$res{$actType}},$b);
|
push(@{$res{$actType}},$b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close IN;
|
close IN;
|
||||||
|
|
||||||
return %res;
|
return %res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,11 +202,10 @@ sub read_examples {
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
sub parentPageTitle {
|
sub parentPageTitle {
|
||||||
|
|
||||||
my ($codeType) = @_;
|
my ($codeType) = @_;
|
||||||
|
return $codeType." examples";
|
||||||
return $codeType." examples";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#--------------------------------------------------------
|
#--------------------------------------------------------
|
||||||
# Create parent page for a given type of examples
|
# Create parent page for a given type of examples
|
||||||
|
@ -215,23 +213,23 @@ sub parentPageTitle {
|
||||||
|
|
||||||
sub makeParentPage {
|
sub makeParentPage {
|
||||||
my ($rootPage,$pageTitle,$outDir,$cType,@xmp) = @_;
|
my ($rootPage,$pageTitle,$outDir,$cType,@xmp) = @_;
|
||||||
|
|
||||||
my $f=$outDir."/parent_".$cType."html";
|
my $f=$outDir."/parent_".$cType."html";
|
||||||
|
|
||||||
open(OUT,">$f") or die "$f: $!";
|
open(OUT,">$f") or die "$f: $!";
|
||||||
|
|
||||||
my $str="<table><tbody>";
|
my $str="<table><tbody>";
|
||||||
$str=$str."<tr><th>Example</th><th>Description</th></tr>";
|
$str=$str."<tr><th>Example</th><th>Description</th></tr>";
|
||||||
|
|
||||||
foreach my $xm (@xmp) {
|
foreach my $xm (@xmp) {
|
||||||
$str=$str."<tr><td>".linkToPage($xm,examplePageTitle($xm))."</td><td>".getDescription($xm)."</td></tr>";
|
$str=$str."<tr><td>".linkToPage($xm,examplePageTitle($xm))."</td><td>".getDescription($xm)."</td></tr>";
|
||||||
}
|
}
|
||||||
$str=$str."</tbody></table>";
|
$str=$str."</tbody></table>";
|
||||||
|
|
||||||
print OUT $str;
|
print OUT $str;
|
||||||
|
|
||||||
close OUT;
|
close OUT;
|
||||||
|
|
||||||
#Load it to confluence
|
#Load it to confluence
|
||||||
loadToConf($f,$pageTitle,$rootPage);
|
loadToConf($f,$pageTitle,$rootPage);
|
||||||
}
|
}
|
||||||
|
@ -239,35 +237,33 @@ sub makeParentPage {
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Genarate the page title for a given example
|
# Genarate the page title for a given example
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
sub examplePageTitle {
|
sub examplePageTitle {
|
||||||
|
|
||||||
my ($exName) = @_;
|
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) = @_;
|
my ($name,$lang) = @_;
|
||||||
return $inRootDir."/".$langDir{$lang}."/".$name.".".$langSuffix{$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 {
|
sub hasExample {
|
||||||
|
|
||||||
my ($name,$lang) = @_;
|
my ($name,$lang) = @_;
|
||||||
my $f=examplePath($name,$lang);
|
my $f=examplePath($name,$lang);
|
||||||
if( -e $f ) {return 1};
|
if( -e $f ) {return 1};
|
||||||
|
|
||||||
print "$f no!!!\n";
|
print "$f no!!!\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,25 +272,24 @@ sub hasExample {
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
||||||
sub getSourceCode {
|
sub getSourceCode {
|
||||||
|
|
||||||
my ($title,$fPath,$lang) = @_;
|
my ($title,$fPath,$lang) = @_;
|
||||||
|
|
||||||
my $codeTxt;
|
my $codeTxt;
|
||||||
|
|
||||||
print $fPath."\n";
|
print $fPath."\n";
|
||||||
|
|
||||||
my $str;
|
my $str;
|
||||||
|
|
||||||
if($lang eq "") {
|
if($lang eq "") {
|
||||||
$codeTxt=fortran_file_to_string($fPath);
|
$codeTxt=fortran_file_to_string($fPath);
|
||||||
#return "<p /><code><ac:macro ac:name=\"html\"><ac:plain-text-body><![CDATA[".$codeTxt."]]></ac:plain-text-body></ac:macro></code>";
|
#return "<p /><code><ac:macro ac:name=\"html\"><ac:plain-text-body><![CDATA[".$codeTxt."]]></ac:plain-text-body></ac:macro></code>";
|
||||||
return "<p /><pre>".$codeTxt."</pre>";
|
return "<p /><pre>".$codeTxt."</pre>";
|
||||||
} else {
|
} else {
|
||||||
open(IN,"<$fPath") or return ""; # die "$fPath: $!";
|
open(IN,"<$fPath") or return ""; # die "$fPath: $!";
|
||||||
$codeTxt=join("", <IN>);
|
$codeTxt=join("", <IN>);
|
||||||
close IN;
|
close IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
$str="
|
$str="
|
||||||
<ac:structured-macro ac:name=\"code\">
|
<ac:structured-macro ac:name=\"code\">
|
||||||
<ac:parameter ac:name=\"title\">".$title."</ac:parameter>
|
<ac:parameter ac:name=\"title\">".$title."</ac:parameter>
|
||||||
|
@ -302,7 +297,7 @@ sub getSourceCode {
|
||||||
<ac:parameter ac:name=\"language\">".$lang."</ac:parameter>
|
<ac:parameter ac:name=\"language\">".$lang."</ac:parameter>
|
||||||
<ac:plain-text-body><![CDATA[".$codeTxt."]]></ac:plain-text-body>
|
<ac:plain-text-body><![CDATA[".$codeTxt."]]></ac:plain-text-body>
|
||||||
</ac:structured-macro>";
|
</ac:structured-macro>";
|
||||||
|
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,17 +306,15 @@ sub getSourceCode {
|
||||||
#--------------------------------------------------------
|
#--------------------------------------------------------
|
||||||
|
|
||||||
sub getDescription {
|
sub getDescription {
|
||||||
|
|
||||||
my ($name) = @_;
|
my ($name) = @_;
|
||||||
|
|
||||||
my $lang="c";
|
my $lang="c";
|
||||||
|
|
||||||
my $res;
|
my $res;
|
||||||
|
|
||||||
if(hasExample($name,$lang)== 1) {
|
if(hasExample($name,$lang)== 1) {
|
||||||
my $f=examplePath($name,$lang);
|
my $f=examplePath($name,$lang);
|
||||||
|
|
||||||
my $found=0;
|
my $found=0;
|
||||||
open (IN,"<$f") or return "";
|
open (IN,"<$f") or return "";
|
||||||
while (defined (my $line = <IN>)) {
|
while (defined (my $line = <IN>)) {
|
||||||
#First row
|
#First row
|
||||||
|
@ -331,28 +324,28 @@ sub getDescription {
|
||||||
my ($r)=($line =~ /\*\s*Description:\s*(.+)/);
|
my ($r)=($line =~ /\*\s*Description:\s*(.+)/);
|
||||||
if(length($r) > 2) {
|
if(length($r) > 2) {
|
||||||
$res=$r;
|
$res=$r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
my ($r)=($line =~ /\*\s+(.+)/);
|
my ($r)=($line =~ /\*\s+(.+)/);
|
||||||
if(length($r) > 2) {
|
if(length($r) > 2) {
|
||||||
$res=$res." ".$r;
|
$res=$res." ".$r;
|
||||||
} else {
|
} else {
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#print $f."\n";
|
#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 {
|
sub loadToConf {
|
||||||
|
|
||||||
my ($fHtml,$title,$parentPage) = @_;
|
my ($fHtml,$title,$parentPage) = @_;
|
||||||
|
|
||||||
system("$CONF -a addPage --noConvert --replace --space \"$confSpace\" --title \"$title\" --parent \"$parentPage\" --file $fHtml");
|
system("$CONF -a addPage --noConvert --replace --space \"$confSpace\" --title \"$title\" --parent \"$parentPage\" --file $fHtml");
|
||||||
}
|
}
|
||||||
|
|
||||||
#---------------------------------------
|
#---------------------------------------
|
||||||
# Create link to a page
|
# Create link to a page
|
||||||
#---------------------------------------
|
#---------------------------------------
|
||||||
|
|
||||||
sub linkToPage {
|
sub linkToPage {
|
||||||
|
|
||||||
my ($page,$label) = @_;
|
my ($page,$label) = @_;
|
||||||
|
|
||||||
my $str="<ac:link>
|
my $str="<ac:link>
|
||||||
<ri:page ri:content-title=\"".$page."\"/>
|
<ri:page ri:content-title=\"".$page."\"/>
|
||||||
<ac:plain-text-link-body>
|
<ac:plain-text-link-body>
|
||||||
|
@ -383,13 +375,11 @@ sub linkToPage {
|
||||||
</ac:link>";
|
</ac:link>";
|
||||||
|
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub makeInfo {
|
sub makeInfo {
|
||||||
|
|
||||||
my ($text) = @_;
|
my ($text) = @_;
|
||||||
|
|
||||||
return "<ac:structured-macro ac:name=\"info\"><ac:parameter ac:name=\"icon\">false</ac:parameter>".
|
return "<ac:structured-macro ac:name=\"info\"><ac:parameter ac:name=\"icon\">false</ac:parameter>".
|
||||||
"<ac:rich-text-body>".$text."</ac:rich-text-body></ac:structured-macro>";
|
"<ac:rich-text-body>".$text."</ac:rich-text-body></ac:structured-macro>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue