Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0f4c94

Browse files
committed
Added module synopsis support with one (big) caveat: All the modules are
listed in each chapter that has a \localmoduletable. This will be fixed, and everything else seems to be working fine.
1 parent 2903d03 commit a0f4c94

1 file changed

Lines changed: 142 additions & 30 deletions

File tree

Doc/perl/python.perl

Lines changed: 142 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,20 @@ sub make_mod_index_entry{
416416
$THIS_MODULE = '';
417417
$THIS_CLASS = '';
418418

419-
sub my_module_index_helper{
420-
local($word, $_) = @_;
421-
my($str,$br_id) = next_argument_id();
422-
swallow_newline();
419+
sub define_module{
420+
my($word,$name) = @_;
423421
my $section_tag = join('', @curr_sec_id);
424422
$word = "$word " if $word;
425-
$THIS_MODULE = "$str";
423+
$THIS_MODULE = "$name";
426424
make_mod_index_entry("SECTION$section_tag",
427-
"<tt>$str</tt> (${word}module)", 'DEF') . $_;
425+
"<tt>$name</tt> (${word}module)", 'DEF');
426+
}
427+
428+
sub my_module_index_helper{
429+
local($word, $_) = @_;
430+
my $name = next_argument();
431+
swallow_newline();
432+
define_module($word, $name) . $_;
428433
}
429434

430435
sub ref_module_index_helper{
@@ -690,28 +695,31 @@ sub do_cmd_memberlineni{
690695
"<dt><b>$member</b><dd>" . $_;
691696
}
692697

693-
@col_aligns = ("<td>", "<td>", "<td>");
698+
@col_aligns = ("<td>", "<td>", "<td>", "<td>");
694699

695700
sub setup_column_alignments{
696701
local($_) = @_;
697-
my($a1,$a2,$a3) = split(/[|]/,$_);
698-
my($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
702+
my($a1,$a2,$a3,$a4) = split(/[|]/,$_);
703+
my($th1,$th2,$th3,$th4) = ('<th>', '<th>', '<th>', '<th>');
699704
$col_aligns[0] = (($a1 eq 'c') ? '<td align=center>' : '<td>');
700705
$col_aligns[1] = (($a2 eq 'c') ? '<td align=center>' : '<td>');
701706
$col_aligns[2] = (($a3 eq 'c') ? '<td align=center>' : '<td>');
707+
$col_aligns[3] = (($a4 eq 'c') ? '<td align=center>' : '<td>');
702708
# return the aligned header start tags; only used for \begin{tableiii?}
703709
$th1 = (($a1 eq 'l') ? '<th align=left>'
704710
: ($a1 eq 'r' ? '<th align=right>' : '<th>'));
705711
$th2 = (($a2 eq 'l') ? '<th align=left>'
706712
: ($a2 eq 'r' ? '<th align=right>' : '<th>'));
707713
$th3 = (($a3 eq 'l') ? '<th align=left>'
708714
: ($a3 eq 'r' ? '<th align=right>' : '<th>'));
709-
($th1, $th2, $th3);
715+
$th4 = (($a4 eq 'l') ? '<th align=left>'
716+
: ($a4 eq 'r' ? '<th align=right>' : '<th>'));
717+
($th1, $th2, $th3, $th4);
710718
}
711719

712720
sub do_env_tableii{
713721
local($_) = @_;
714-
my($th1,$th2,$th3) = setup_column_alignments(next_argument());
722+
my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
715723
my $font = next_argument();
716724
my $h1 = next_argument();
717725
my $h2 = next_argument();
@@ -742,7 +750,7 @@ sub do_cmd_lineii{
742750

743751
sub do_env_tableiii{
744752
local($_) = @_;
745-
my($th1,$th2,$th3) = setup_column_alignments(next_argument());
753+
my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
746754
my $font = next_argument();
747755
my $h1 = next_argument();
748756
my $h2 = next_argument();
@@ -768,36 +776,52 @@ sub do_cmd_lineiii{
768776
$sfont = "<$font>";
769777
$efont = "</$font>";
770778
}
771-
my($c1align,$c2align,$c3align) = @col_aligns;
779+
my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
772780
"<tr>$c1align$sfont$c1$efont</td>\n"
773781
. " $c2align$c2</td>\n"
774782
. " $c3align$c3</td>"
775783
. $_;
776784
}
777785

778-
sub do_env_seealso{
779-
"<p><b>See Also:</b></p>\n" . @_[0];
786+
sub do_env_tableiv{
787+
local($_) = @_;
788+
my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
789+
my $font = next_argument();
790+
my $h1 = next_argument();
791+
my $h2 = next_argument();
792+
my $h3 = next_argument();
793+
my $h4 = next_argument();
794+
$font = ''
795+
if ($font eq 'textrm');
796+
$globals{'lineifont'} = $font;
797+
'<table border align=center>'
798+
. "\n <tr>$th1<b>$h1</b></th>"
799+
. "\n $th2<b>$h2</b></th>"
800+
. "\n $th3<b>$h3</b></th>"
801+
. "\n $th4<b>$h4</b></th>"
802+
. $_
803+
. "\n</table>";
780804
}
781805

782-
sub do_cmd_seemodule{
783-
# Insert the right magic to jump to the module definition. This should
784-
# work most of the time, at least for repeat builds....
806+
sub do_cmd_lineiv{
785807
local($_) = @_;
786-
my $key = next_optional_argument();
787-
my $module = next_argument();
788-
my $text = next_argument();
789-
$key = $module
790-
unless $key;
791-
"<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
792-
. "&nbsp;&nbsp;&nbsp;($text)</p>"
808+
my $c1 = next_argument();
809+
my $c2 = next_argument();
810+
my $c3 = next_argument();
811+
my $c4 = next_argument();
812+
my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
813+
if ($font) {
814+
$sfont = "<$font>";
815+
$efont = "</$font>";
816+
}
817+
my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
818+
"<tr>$c1align$sfont$c1$efont</td>\n"
819+
. " $c2align$c2</td>\n"
820+
. " $c3align$c3</td>\n"
821+
. " $c4align$c4</td>"
793822
. $_;
794823
}
795824

796-
sub do_cmd_seetext{
797-
'<p>' . @_[0];
798-
}
799-
800-
801825
sub do_cmd_maketitle {
802826
local($_) = @_;
803827
my $the_title = '';
@@ -837,6 +861,94 @@ sub do_cmd_maketitle {
837861
}
838862

839863

864+
#
865+
# Module synopsis support
866+
#
867+
868+
require SynopsisTable;
869+
870+
$MY_CHAPTER_COUNTER = 0;
871+
872+
sub get_chapter_id{
873+
return $MY_CHAPTER_COUNTER;
874+
}
875+
876+
sub get_synopsis_table{
877+
my $chap = @_;
878+
my $st = $ModuleSynopses{$chap};
879+
if (!$st) {
880+
$st = SynopsisTable->new();
881+
$ModuleSynopses{$chap} = $st;
882+
}
883+
return $st;
884+
}
885+
886+
sub do_cmd_declaremodule{
887+
local($_) = @_;
888+
my $key = next_optional_argument();
889+
my $type = next_argument();
890+
my $name = next_argument();
891+
my $st = get_synopsis_table(get_chapter_id());
892+
#
893+
$key = $name unless $key;
894+
$type = 'built-in' if $type eq 'builtin';
895+
$st->declare($name, $key, $type);
896+
define_module($type, $name);
897+
anchor_label("module-$key",$CURRENT_FILE,$_)
898+
}
899+
900+
sub do_cmd_modulesynopsis{
901+
local($_) = @_;
902+
my $st = get_synopsis_table(get_chapter_id());
903+
$st->set_synopsis($THIS_MODULE, next_argument());
904+
swallow_newline();
905+
$_;
906+
}
907+
908+
sub do_cmd_localmoduletable{
909+
local($_) = @_;
910+
$MY_CHAPTER_COUNTER = $MY_CHAPTER_COUNTER + 1;
911+
my $chap = get_chapter_id();
912+
"<tex2htmllocalmoduletable><$chap>" . $_;
913+
}
914+
915+
sub process_all_localmoduletables{
916+
while (/<tex2htmllocalmoduletable><(\d+)>/) {
917+
my $chap = $1;
918+
my $st = get_synopsis_table($chap);
919+
my $data = $st->tohtml();
920+
s/$&/$data/;
921+
}
922+
}
923+
924+
925+
#
926+
# "See also:" -- references placed at the end of a \section
927+
#
928+
929+
sub do_env_seealso{
930+
"<p><b>See Also:</b></p>\n" . @_[0];
931+
}
932+
933+
sub do_cmd_seemodule{
934+
# Insert the right magic to jump to the module definition. This should
935+
# work most of the time, at least for repeat builds....
936+
local($_) = @_;
937+
my $key = next_optional_argument();
938+
my $module = next_argument();
939+
my $text = next_argument();
940+
$key = $module
941+
unless $key;
942+
"<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
943+
. "&nbsp;&nbsp;&nbsp;($text)</p>"
944+
. $_;
945+
}
946+
947+
sub do_cmd_seetext{
948+
'<p>' . @_[0];
949+
}
950+
951+
840952
#
841953
# Definition list support.
842954
#

0 commit comments

Comments
 (0)