From a0f4c94af6aa7d01910ae143bb51a5b0ea35681e Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Fri, 24 Jul 1998 22:16:04 +0000 Subject: [PATCH] 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. --- Doc/perl/python.perl | 172 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 142 insertions(+), 30 deletions(-) diff --git a/Doc/perl/python.perl b/Doc/perl/python.perl index 3f345398b04..7af19094705 100644 --- a/Doc/perl/python.perl +++ b/Doc/perl/python.perl @@ -416,15 +416,20 @@ sub make_mod_index_entry{ $THIS_MODULE = ''; $THIS_CLASS = ''; -sub my_module_index_helper{ - local($word, $_) = @_; - my($str,$br_id) = next_argument_id(); - swallow_newline(); +sub define_module{ + my($word,$name) = @_; my $section_tag = join('', @curr_sec_id); $word = "$word " if $word; - $THIS_MODULE = "$str"; + $THIS_MODULE = "$name"; make_mod_index_entry("SECTION$section_tag", - "$str (${word}module)", 'DEF') . $_; + "$name (${word}module)", 'DEF'); +} + +sub my_module_index_helper{ + local($word, $_) = @_; + my $name = next_argument(); + swallow_newline(); + define_module($word, $name) . $_; } sub ref_module_index_helper{ @@ -690,15 +695,16 @@ sub do_cmd_memberlineni{ "
$member
" . $_; } -@col_aligns = ("", "", ""); +@col_aligns = ("", "", "", ""); sub setup_column_alignments{ local($_) = @_; - my($a1,$a2,$a3) = split(/[|]/,$_); - my($th1,$th2,$th3) = ('', '', ''); + my($a1,$a2,$a3,$a4) = split(/[|]/,$_); + my($th1,$th2,$th3,$th4) = ('', '', '', ''); $col_aligns[0] = (($a1 eq 'c') ? '' : ''); $col_aligns[1] = (($a2 eq 'c') ? '' : ''); $col_aligns[2] = (($a3 eq 'c') ? '' : ''); + $col_aligns[3] = (($a4 eq 'c') ? '' : ''); # return the aligned header start tags; only used for \begin{tableiii?} $th1 = (($a1 eq 'l') ? '' : ($a1 eq 'r' ? '' : '')); @@ -706,12 +712,14 @@ sub setup_column_alignments{ : ($a2 eq 'r' ? '' : '')); $th3 = (($a3 eq 'l') ? '' : ($a3 eq 'r' ? '' : '')); - ($th1, $th2, $th3); + $th4 = (($a4 eq 'l') ? '' + : ($a4 eq 'r' ? '' : '')); + ($th1, $th2, $th3, $th4); } sub do_env_tableii{ local($_) = @_; - my($th1,$th2,$th3) = setup_column_alignments(next_argument()); + my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); my $font = next_argument(); my $h1 = next_argument(); my $h2 = next_argument(); @@ -742,7 +750,7 @@ sub do_cmd_lineii{ sub do_env_tableiii{ local($_) = @_; - my($th1,$th2,$th3) = setup_column_alignments(next_argument()); + my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); my $font = next_argument(); my $h1 = next_argument(); my $h2 = next_argument(); @@ -768,36 +776,52 @@ sub do_cmd_lineiii{ $sfont = "<$font>"; $efont = ""; } - my($c1align,$c2align,$c3align) = @col_aligns; + my($c1align,$c2align,$c3align) = @col_aligns[0,1,2]; "$c1align$sfont$c1$efont\n" . " $c2align$c2\n" . " $c3align$c3" . $_; } -sub do_env_seealso{ - "

See Also:

\n" . @_[0]; +sub do_env_tableiv{ + local($_) = @_; + my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); + my $font = next_argument(); + my $h1 = next_argument(); + my $h2 = next_argument(); + my $h3 = next_argument(); + my $h4 = next_argument(); + $font = '' + if ($font eq 'textrm'); + $globals{'lineifont'} = $font; + '' + . "\n $th1$h1" + . "\n $th2$h2" + . "\n $th3$h3" + . "\n $th4$h4" + . $_ + . "\n
"; } -sub do_cmd_seemodule{ - # Insert the right magic to jump to the module definition. This should - # work most of the time, at least for repeat builds.... +sub do_cmd_lineiv{ local($_) = @_; - my $key = next_optional_argument(); - my $module = next_argument(); - my $text = next_argument(); - $key = $module - unless $key; - "

Module $module" - . "   ($text)

" + my $c1 = next_argument(); + my $c2 = next_argument(); + my $c3 = next_argument(); + my $c4 = next_argument(); + my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); + if ($font) { + $sfont = "<$font>"; + $efont = ""; + } + my($c1align,$c2align,$c3align,$c4align) = @col_aligns; + "$c1align$sfont$c1$efont\n" + . " $c2align$c2\n" + . " $c3align$c3\n" + . " $c4align$c4" . $_; } -sub do_cmd_seetext{ - '

' . @_[0]; -} - - sub do_cmd_maketitle { local($_) = @_; my $the_title = ''; @@ -837,6 +861,94 @@ sub do_cmd_maketitle { } +# +# Module synopsis support +# + +require SynopsisTable; + +$MY_CHAPTER_COUNTER = 0; + +sub get_chapter_id{ + return $MY_CHAPTER_COUNTER; +} + +sub get_synopsis_table{ + my $chap = @_; + my $st = $ModuleSynopses{$chap}; + if (!$st) { + $st = SynopsisTable->new(); + $ModuleSynopses{$chap} = $st; + } + return $st; +} + +sub do_cmd_declaremodule{ + local($_) = @_; + my $key = next_optional_argument(); + my $type = next_argument(); + my $name = next_argument(); + my $st = get_synopsis_table(get_chapter_id()); + # + $key = $name unless $key; + $type = 'built-in' if $type eq 'builtin'; + $st->declare($name, $key, $type); + define_module($type, $name); + anchor_label("module-$key",$CURRENT_FILE,$_) +} + +sub do_cmd_modulesynopsis{ + local($_) = @_; + my $st = get_synopsis_table(get_chapter_id()); + $st->set_synopsis($THIS_MODULE, next_argument()); + swallow_newline(); + $_; +} + +sub do_cmd_localmoduletable{ + local($_) = @_; + $MY_CHAPTER_COUNTER = $MY_CHAPTER_COUNTER + 1; + my $chap = get_chapter_id(); + "<$chap>" . $_; +} + +sub process_all_localmoduletables{ + while (/<(\d+)>/) { + my $chap = $1; + my $st = get_synopsis_table($chap); + my $data = $st->tohtml(); + s/$&/$data/; + } +} + + +# +# "See also:" -- references placed at the end of a \section +# + +sub do_env_seealso{ + "

See Also:

\n" . @_[0]; +} + +sub do_cmd_seemodule{ + # Insert the right magic to jump to the module definition. This should + # work most of the time, at least for repeat builds.... + local($_) = @_; + my $key = next_optional_argument(); + my $module = next_argument(); + my $text = next_argument(); + $key = $module + unless $key; + "

Module $module" + . "   ($text)

" + . $_; +} + +sub do_cmd_seetext{ + '

' . @_[0]; +} + + # # Definition list support. #