From 1c68d3c5a35a1c52202d857965cc7258ecabdc02 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sat, 16 Jan 2016 17:00:15 +0000 Subject: [PATCH] commandref_join.pl: Patch from Markus (Forum #47550) git-svn-id: https://svn.fhem.de/fhem/trunk@10524 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/commandref_join.pl | 72 ++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/fhem/contrib/commandref_join.pl b/fhem/contrib/commandref_join.pl index 7ad6f3b8d..a8a05b60e 100755 --- a/fhem/contrib/commandref_join.pl +++ b/fhem/contrib/commandref_join.pl @@ -10,25 +10,40 @@ use warnings; # $Id$ my $noWarnings = grep $_ eq '-noWarnings', @ARGV; +my ($verify) = grep $_ =~ /\.pm$/ , @ARGV; + use constant TAGS => qw{ul li code b i u table tr td}; +sub generateModuleCommandref($$;$); + my %mods; my @modDir = ("FHEM"); -foreach my $modDir (@modDir) { - opendir(DH, $modDir) || die "Cant open $modDir: $!\n"; - while(my $l = readdir DH) { - next if($l !~ m/^\d\d_.*\.pm$/); - my $of = $l; - $l =~ s/.pm$//; - $l =~ s/^[0-9][0-9]_//; - $mods{$l} = "$modDir/$of"; - } -} -$mods{configDB} = "configDB.pm" if(-f "configDB.pm"); - - my @lang = ("EN", "DE"); +if(!$verify) { + foreach my $modDir (@modDir) { + opendir(DH, $modDir) || die "Cant open $modDir: $!\n"; + while(my $l = readdir DH) { + next if($l !~ m/^\d\d_.*\.pm$/); + my $of = $l; + $l =~ s/.pm$//; + $l =~ s/^[0-9][0-9]_//; + $mods{$l} = "$modDir/$of"; + } + } + $mods{configDB} = "configDB.pm" if(-f "configDB.pm"); +} else { # check for syntax only + my $modname = $verify; + $modname =~ s/^.*[\/\\](?:\d\d_)?(.+).pm$/$1/; + $mods{$modname} = $verify; + foreach my $lang (@lang) { + generateModuleCommandref($modname, $lang); + } + exit; +} + + + foreach my $lang (@lang) { my $suffix = ($lang eq "EN" ? "" : "_$lang"); my $docIn = "docs/commandref_frame$suffix.html"; @@ -67,7 +82,24 @@ foreach my $lang (@lang) { # Copy the doc part from the module foreach my $mod (sort keys %mods) { + generateModuleCommandref($mod,$lang, \*OUT); + } + + # Copy the tail + print OUT '',"\n"; + while(my $l = ) { + print OUT $l; + } + close(OUT); +} + +############################# +# read a module file and check/print the commandref +sub generateModuleCommandref($$;$) +{ + my ($mod, $lang, $fh) = @_; my $tag; + my $suffix = ($lang eq "EN" ? "" : "_$lang"); my %tagcount= (); my %llwct = (); # Last line with closed tag open(MOD, $mods{$mod}) || die("Cant open $mods{$mod}:$!\n"); @@ -90,7 +122,7 @@ foreach my $lang (@lang) { $skip = 1; } elsif(!$skip) { - print OUT $l; + print $fh $l if($fh); $docCount++; $hasLink = ($l =~ m/

$mod