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,10 +10,17 @@ 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");
|
||||
my @lang = ("EN", "DE");
|
||||
|
||||
if(!$verify) {
|
||||
foreach my $modDir (@modDir) {
|
||||
opendir(DH, $modDir) || die "Cant open $modDir: $!\n";
|
||||
while(my $l = readdir DH) {
|
||||
@ -25,9 +32,17 @@ foreach my $modDir (@modDir) {
|
||||
}
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
my @lang = ("EN", "DE");
|
||||
|
||||
foreach my $lang (@lang) {
|
||||
my $suffix = ($lang eq "EN" ? "" : "_$lang");
|
||||
@ -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 '<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 $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/<a name="$mod"/) if(!$hasLink);
|
||||
foreach $tag (TAGS) {
|
||||
@ -106,8 +138,8 @@ foreach my $lang (@lang) {
|
||||
print "*** $lang $mods{$mod}: No document text found\n"
|
||||
if(!$suffix && !$docCount && !$dosMode && $mods{$mod} !~ m,/99_,);
|
||||
if($suffix && !$docCount && !$dosMode) {
|
||||
if($lang eq "DE") {
|
||||
print OUT << "EOF";
|
||||
if($lang eq "DE" && $fh) {
|
||||
print $fh <<EOF;
|
||||
<a name="$mod"></a>
|
||||
<h3>$mod</h3>
|
||||
<ul>
|
||||
@ -126,11 +158,3 @@ EOF
|
||||
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