mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 10:46:53 +00:00
commandref_join.pl: Patch from Markus (Forum #47550)
git-svn-id: https://svn.fhem.de/fhem/trunk@10524 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6ea591c471
commit
1c68d3c5a3
@ -10,25 +10,40 @@ use warnings;
|
|||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
my $noWarnings = grep $_ eq '-noWarnings', @ARGV;
|
my $noWarnings = grep $_ eq '-noWarnings', @ARGV;
|
||||||
|
my ($verify) = grep $_ =~ /\.pm$/ , @ARGV;
|
||||||
|
|
||||||
use constant TAGS => qw{ul li code b i u table tr td};
|
use constant TAGS => qw{ul li code b i u table tr td};
|
||||||
|
|
||||||
|
sub generateModuleCommandref($$;$);
|
||||||
|
|
||||||
my %mods;
|
my %mods;
|
||||||
my @modDir = ("FHEM");
|
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");
|
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) {
|
foreach my $lang (@lang) {
|
||||||
my $suffix = ($lang eq "EN" ? "" : "_$lang");
|
my $suffix = ($lang eq "EN" ? "" : "_$lang");
|
||||||
my $docIn = "docs/commandref_frame$suffix.html";
|
my $docIn = "docs/commandref_frame$suffix.html";
|
||||||
@ -67,7 +82,24 @@ foreach my $lang (@lang) {
|
|||||||
|
|
||||||
# Copy the doc part from the module
|
# Copy the doc part from the module
|
||||||
foreach my $mod (sort keys %mods) {
|
foreach my $mod (sort keys %mods) {
|
||||||
|
generateModuleCommandref($mod,$lang, \*OUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Copy the tail
|
||||||
|
print OUT '<a name="perl"></a>',"\n";
|
||||||
|
while(my $l = <IN>) {
|
||||||
|
print OUT $l;
|
||||||
|
}
|
||||||
|
close(OUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# read a module file and check/print the commandref
|
||||||
|
sub generateModuleCommandref($$;$)
|
||||||
|
{
|
||||||
|
my ($mod, $lang, $fh) = @_;
|
||||||
my $tag;
|
my $tag;
|
||||||
|
my $suffix = ($lang eq "EN" ? "" : "_$lang");
|
||||||
my %tagcount= ();
|
my %tagcount= ();
|
||||||
my %llwct = (); # Last line with closed tag
|
my %llwct = (); # Last line with closed tag
|
||||||
open(MOD, $mods{$mod}) || die("Cant open $mods{$mod}:$!\n");
|
open(MOD, $mods{$mod}) || die("Cant open $mods{$mod}:$!\n");
|
||||||
@ -90,7 +122,7 @@ foreach my $lang (@lang) {
|
|||||||
$skip = 1;
|
$skip = 1;
|
||||||
|
|
||||||
} elsif(!$skip) {
|
} elsif(!$skip) {
|
||||||
print OUT $l;
|
print $fh $l if($fh);
|
||||||
$docCount++;
|
$docCount++;
|
||||||
$hasLink = ($l =~ m/<a name="$mod"/) if(!$hasLink);
|
$hasLink = ($l =~ m/<a name="$mod"/) if(!$hasLink);
|
||||||
foreach $tag (TAGS) {
|
foreach $tag (TAGS) {
|
||||||
@ -106,8 +138,8 @@ foreach my $lang (@lang) {
|
|||||||
print "*** $lang $mods{$mod}: No document text found\n"
|
print "*** $lang $mods{$mod}: No document text found\n"
|
||||||
if(!$suffix && !$docCount && !$dosMode && $mods{$mod} !~ m,/99_,);
|
if(!$suffix && !$docCount && !$dosMode && $mods{$mod} !~ m,/99_,);
|
||||||
if($suffix && !$docCount && !$dosMode) {
|
if($suffix && !$docCount && !$dosMode) {
|
||||||
if($lang eq "DE") {
|
if($lang eq "DE" && $fh) {
|
||||||
print OUT << "EOF";
|
print $fh <<EOF;
|
||||||
<a name="$mod"></a>
|
<a name="$mod"></a>
|
||||||
<h3>$mod</h3>
|
<h3>$mod</h3>
|
||||||
<ul>
|
<ul>
|
||||||
@ -125,12 +157,4 @@ EOF
|
|||||||
"($tagcount{$tag}, last line ok: $llwct{$tag})\n")
|
"($tagcount{$tag}, last line ok: $llwct{$tag})\n")
|
||||||
if($tagcount{$tag} && !$noWarnings);
|
if($tagcount{$tag} && !$noWarnings);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# Copy the tail
|
|
||||||
print OUT '<a name="perl"></a>',"\n";
|
|
||||||
while(my $l = <IN>) {
|
|
||||||
print OUT $l;
|
|
||||||
}
|
|
||||||
close(OUT);
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user