#!/usr/local/bin/perl ################################################################### # Computer Algebra System SINGULAR # # pl2doc.pl: utility to generate doc file out of pl for singular library # #### $Usage = <$out_file") || die"Error: can't open $out_file for writing: $!\n"; print_doc_header(\*LDOC) if $doc; print LDOC "\@c ---content LibInfo---\n"; print LDOC "\@c library version: $version\n"; print LDOC "\@c library file: $library\n"; print LDOC "\@cindex $lib.$so_module\n"; print LDOC "\@cindex ${lib}_$so_module\n"; undef @procs; # will be again defined by OutLibInfo $parsing = "info-string of lib $lib:"; $ref = OutLibInfo(\*LDOC, $info, ! $no_fun); OutRef(\*LDOC, $ref) if $ref; print LDOC "\@c ---end content LibInfo---\n"; ################################################################### # print summary # # print subsubsections for help of procs unless ($no_fun) { if ($db_file && -e $db_file && ! -z $db_file) { my $return; unless ($return = do $db_file) { die "couldn't parse $db_file: $@" if $@; die "couldn't do $db_file: $!" unless defined $return; die "couldn't run $db_file" unless $return; } } # print help and example of each function for ($i = 0; $i <= $#procs; $i++) { # print node and section heading print LDOC "\n\@c ------------------- " . $procs[$i]." -------------\n"; print LDOC "\@node " . $procs[$i].","; print LDOC " ".$procs[$i+1] if ($i < $#procs); print LDOC ","; print LDOC " ".$procs[$i-1] if ($i > 0); print LDOC ", " . $lib ."_lib\n"; print LDOC "\@subsubsection " . $procs[$i] . "\n"; print LDOC "\@cindex ". $procs[$i] . "\n"; if ($db_file && (!defined($CHECKSUMS{$procs[$i]}) || $CHECKSUMS{$procs[$i]} != $chksum{$procs[$i]})) { $CHECKSUMS{$procs[$i]} = $chksum{$procs[$i]}; $CHECKSUMS_CHANGED = 1; } print LDOC "\@c ---content $procs[$i]---\n"; print LDOC "Procedure from library \@code{$lib.lib} (\@pxref{${lib}_lib}).\n\n"; if ($help{$procs[$i]} =~ /^\@/) { print LDOC $help{$procs[$i]}; $ref = ''; } else { print LDOC "\@table \@asis\n"; $table_is_open = 1; # print help $parsing = "help-string of $lib:$procs[$i]:"; $ref = OutInfo(\*LDOC, $help{$procs[$i]}); print LDOC "\@end table\n"; } # print example if ($example{$procs[$i]} && ($ex = &CleanUpExample($lib, $example{$procs[$i]}))) { print LDOC "\@strong{Example:}\n"; print LDOC "\@smallexample\n\@c example$tag\n"; print LDOC $ex; print LDOC "\n\@c example\n\@end smallexample\n"; } OutRef(\*LDOC, $ref) if $ref; print LDOC "\@c ---end content $procs[$i]---\n"; } # save checksums if ($CHECKSUMS_CHANGED) { open(CD, ">$db_file") || die "Can't open '$db_file' for writing: $!"; print CD "%CHECKSUMS = (\n"; for $key (keys %CHECKSUMS) { if ($CHECKSUMS{$key} == "sprintf") { print CD "q{$key}, \"sprintf\",\n"; } else { print CD "q{$key}, $CHECKSUMS{$key},\n"; } } print CD ");\n"; close(CD); } } # # und Tschuess # if ($doc) { print LDOC <