[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev [PATCH to 2.8.4dev1] improvements to cfg2html.pl
From: |
Vlad Harchev |
Subject: |
lynx-dev [PATCH to 2.8.4dev1] improvements to cfg2html.pl |
Date: |
Sun, 7 May 2000 14:55:59 +0500 (SAMST) |
Here is a patch to cfg2html.pl script and makefile.in
I tweaked cfg2html.pl, and now its behaviour is controled by the values of
the following variables at the top of it:
$order,$dont_show_unavailable_options,$mark_unavailable_options
* output descriptions of all settings in body.html either in original or in
alphabetical mode (sorted by default, to request original order
change the '$order="sorted";' to '$order="unsorted";'
* It's possible to suppress mentioning in all generated html files settings
support for which was disabled at compile time (this is not default).
Set $dont_show_unavailable_options to 1 if you don't want to see unavailable
settings.
* If suppression of unavailable settings is turned off (the default), then
it's possible to mark all unavailable options with asterisks in *toc.html
and by appending verbose text in body.html (default). If you don't want to
mark unavailable options, set $mark_unavailable_options to 0.
Note: this could slowdown generation of html files a little (but by no more
than twice). Also, LYReadCFG.i will be generated by preprocessing LYReadCFG.c
(it's 700K on my Linux). Also, file named 'tmp007' 1.5K big will be left in
the top of build directory (where top makefile resides) - for some unknown
reason for me.
Currently you have to edit values of variables in scripts/cfg2html.pl by
hand. It would be nice if yet another option for configure was implemented,
like --cfg-html-options={all|avail},{sorted|unsorted},{mark|dontmark} so its
argument is passed to cfg2html.pl for parsing it. I.e.
--cfg-html-options=all,sorted,mark
will mean output all options, put them in sorted order and mark unavailable.
Tested with perl 5.005_03.
Best regards,
-Vlad
diff -ru lynx2.8.4dev.1-was/makefile.in lynx2.8.4dev.1/makefile.in
--- lynx2.8.4dev.1-was/makefile.in Sun May 7 11:49:41 2000
+++ lynx2.8.4dev.1/makefile.in Sun May 7 14:30:00 2000
@@ -360,7 +360,10 @@
install-help : help_files.sed $(HELPDIR)
(cd $(HELPDIR) && WD=`pwd` && HEAD=`echo $$WD|sed -e
's@/lynx_help$$@@'` && test $$WD != $$HEAD && rm -rf *)
@LYNXCFG_MAKE@ @echo 'Making htmlized lynx.cfg'
address@hidden@ cd src && make LYReadCFG.i
@LYNXCFG_MAKE@ @-rm -f alphatoc.html body.html cattoc.html
address@hidden@ sed -n -e '/Config_Type *Config_Table/,/{0, *0, *0}/ p'
src/LYReadCFG.i | \
address@hidden@ sed -e 's/ *{ *"\([^"]*\)".*/\1/' | \
@LYNXCFG_MAKE@ perl $(srcdir)/scripts/cfg2html.pl $(srcdir)/lynx.cfg
@echo Translating/copying html files
@cat help_files.sed > $(HELPDIR)/help_files.sed
diff -ru lynx2.8.4dev.1-was/scripts/cfg2html.pl
lynx2.8.4dev.1/scripts/cfg2html.pl
--- lynx2.8.4dev.1-was/scripts/cfg2html.pl Sun May 7 11:49:40 2000
+++ lynx2.8.4dev.1/scripts/cfg2html.pl Sun May 7 14:18:50 2000
@@ -22,6 +22,38 @@
require "getopts.pl";
+#these variables control the way files are generated:
+$order="sorted";#if it's "sorted", then entries in body.html will be sorted,
+ #or in natural order otherwise
+
+#if this is 1, then any of generated files won't have any trace of unavailable
+#options (this includes cattoc.html, alphatoc.html)
+$dont_show_unavailable_options=0;
+
+#the value of this variable is considered only if
+#$dont_show_unavailable_options is 0. If $mark_unavailable_options is 1,
+#then unavailable options will be marked in a special way.
+$mark_unavailable_options=1;
+
+
address@hidden = <STDIN>;
+%settings_avail = ();
+foreach $l (@settings_) {
+ chop $l;
+ if ($l =~ /^[a-zA-Z_][a-zA-Z_0-9]*$/) {
+ $settings_avail{uc $l} = 1;
+ };
+};
+
+#this sub tells whether the support for the given setting was enabled at
+#compile time.
+sub ok {
+ local ($nm) = @_;
+ local ($ret) = defined($settings_avail{uc $nm})+0;
+ $ret;
+};
+
+
if ( $#ARGV < 0 ) {
&doit("lynx.cfg");
} else {
@@ -31,6 +63,7 @@
}
exit (0);
+
# process a Lynx configuration-file
sub doit {
local ($name) = @_;
@@ -83,7 +116,7 @@
if ( $input[$n] =~ /^\.h2\s*[A-Z][A-Z0-9_]*$/ ) {
$minor[$m] = $input[$n];
$minor[$m] =~ s/^.h2\s*//;
- $m++;
+ $m++ if (ok($minor[$m]) ||
!$dont_show_unavailable_options);
}
}
@minor = sort @minor;
@@ -104,14 +137,23 @@
printf FP "<h2><a name=%s>%s</a></h2>\n", $d, $d;
$c=$d;
}
- printf FP "<a href=\"body.html#%s\">%s</a> \n",
$minor[$n], $minor[$n];
+ local ($avail = ok($minor[$n]));
+ local ($mark = !$avail && $mark_unavailable_options ? "*" : "");
+ if (!$dont_show_unavailable_options || $avail) {
+ printf FP "<a href=\"body.html#%s\">%s</a> \n",
$minor[$n], $minor[$n] . $mark;
+ };
}
- print FP <<'EOF';
+ $str = <<'EOF'
<p>
<a href=cattoc.html>To list of settings by category</a>
+EOF
+. (!$dont_show_unavailable_options && $mark_unavailable_options ?
+"<p>Support for all settings suffixed with '*' was disabled at compile time." :
+ "") . << 'EOF'
</body>
</html>
EOF
+ ;print FP $str;
close(FP);
}
@@ -148,6 +190,14 @@
$next = 0;
$left = 0;
undef %keys;
+
+ local (@optnames);
+ local (%optname_to_fname);#this maps optname to fname - will be used
+ #for alpabetical output of the content
+ local ($curfilename = "tmp000");#will be incremented each time
+ local ($tmpdir = "./");#temp files will be created there
+ close(FP);
+
for $n (0..$#input) {
if ( $next ) {
$next--;
@@ -190,6 +240,14 @@
} elsif ( $c =~ /^$/ ) {
if ( $m > 1 ) {
for $j (1..$#h2) {
+ close(FP);++$curfilename;
+ push @optnames,$curfilename;
+ open(FP,">$tmpdir/$curfilename") || do {
+ print STDERR "Can't open tmpfile:
$!\n";
+ return;
+ };
+ $optname_to_fname{$h2[$j]} =
$curfilename;
+
printf FP "<hr>\n";
printf FP "<h2><kbd><a
name=\"%s\">%s</a></kbd>\n", $h2[$j], $h2[$j];
if ( $h1 ne "" ) {
@@ -205,6 +263,14 @@
$first = 1;
} elsif ( $c =~ /^[#A-Za-z]/ && $m != 0 ) {
if ( $first ) {
+ close(FP);++$curfilename;
+ push @optnames,$curfilename;
+ open(FP,">$tmpdir/$curfilename") || do {
+ print STDERR "Can't open tmpfile: $!\n";
+ return;
+ };
+ $optname_to_fname{$h2[0]} = $curfilename;
+
if ( $any ) {
printf FP "<hr>\n";
}
@@ -230,8 +296,9 @@
# and convert simple expressions:
$c =~ s/&/&/g;
$c =~ s/>/>/g;
- $c =~ s/</</g;
- $c =~ s/'([^ ])'/`<strong>$1<\/strong>'/g;
+ $c =~ s/</</g;
+ #hvv - something wrong was with next statement
+ $c =~ s/'([^ ])'/"<strong>$1<\/strong>"/g;
# Do a line-break each time the margin changes. We
# could get fancier, but HTML doesn't really support
@@ -294,6 +361,36 @@
}
}
}
+ close(FP);
+ #how we have to collect files with description of needed lynx.cfg
+ #options in the proper (natural or sorted) order.
+ open(FP,">$output") || do {
+ print STDERR "Can't open $output: $!\n";
+ return;
+ };
+ {
+ local (@ordered = ($order eq "sorted" ? (sort
keys(%optname_to_fname)) : @optnames));
+ foreach $l (@ordered) {
+ local ($fnm = $tmpdir . "/" . $optname_to_fname{$l});
+ open(FP1,"<$fnm") || do {
+ print STDERR "Can't open $fnm: $!\n";
+ return;
+ };
+ local ($avail = ok($l));
+ if (!$dont_show_unavailable_options || $avail) {
+ local(@lines) = <FP1>;
+ print FP @lines;
+ if (!$avail && $mark_unavailable_options) {
+ print FP << 'EOF';
+<p>Support for this setting was disabled at compile-time.
+EOF
+ };
+ };
+ close(FP1);
+ };
+ unlink map { $optname_to_fname{$_}; } @ordered;
+ }
+
print FP <<'EOF';
</body>
</html>
@@ -308,6 +405,7 @@
local (@index);
local ($n, $m, $c, $d, $found, $h1);
local ($output="cattoc.html");
+
open(FP,">$output") || do {
print STDERR "Can't open $output: $!\n";
return;
@@ -358,7 +456,8 @@
if ( $m >= 0 && $input[$n] =~ /^\.h2\s/ ) {
$c = $input[$n];
$c =~ s/^.h2\s*//;
- $index{$major[$m]} .= $c . "\n";
+ $index{$major[$m]} .= $c . "\n"
+ if (!$dont_show_unavailable_options || ok($c));
}
}
@major = sort @major;
@@ -372,7 +471,7 @@
printf FP "<h2><a name=\"%s\">%s</a></h2>\n",
$cats{$major[$n]}, $major[$n];
if ($descs{$major[$n]} !~ /^$/) {
printf FP "<h3>Description</h3>\n%s\n",
$descs{$major[$n]};
- }
+ }
$c = $index{$major[$n]};
if ( $c ne "" ) {
@c = split(/\n/, $c);
@@ -380,17 +479,24 @@
printf FP "<p>Here is a list of settings that belong to
this category\n";
printf FP "<ul>\n";
for $m (0..$#c) {
- printf FP "<li><a
href=\"body.html#%s\">%s</a>\n", $c[$m], $c[$m];
+ local($avail = ok($c[$m]));
+ local($mark = !$avail &&
$mark_unavailable_options ? "*" : "");
+ printf FP "<li><a
href=\"body.html#%s\">%s</a>\n", $c[$m], $c[$m] . $mark;
}
printf FP "</ul>\n";
}
}
- print FP <<'EOF';
+ $str = <<'EOF'
<p>
<a href=alphatoc.html>To list of settings by name</a>
+EOF
+. (!$dont_show_unavailable_options && $mark_unavailable_options ?
+"<p>Support for all settings suffixed with '*' was disabled at compile time." :
+ "") . << 'EOF'
</body>
</html>
EOF
+ ;print FP $str;
close(FP);
return @cats;
}
; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lynx-dev [PATCH to 2.8.4dev1] improvements to cfg2html.pl,
Vlad Harchev <=