From c0254b173189cdc9fafddf12b719a9ed84edb88a Mon Sep 17 00:00:00 2001 From: Manuel Pégourié-Gonnard Date: Fri, 9 Oct 2009 01:22:26 +0000 Subject: Adopt the new version of tl-update-docindex. git-svn-id: svn://tug.org/texlive/trunk@15712 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/bin/tl-update-docindex | 204 ++++++++++++++++++------------------ 1 file changed, 102 insertions(+), 102 deletions(-) (limited to 'Master/tlpkg/bin/tl-update-docindex') diff --git a/Master/tlpkg/bin/tl-update-docindex b/Master/tlpkg/bin/tl-update-docindex index 03bcffcf03c..8b943095c6e 100755 --- a/Master/tlpkg/bin/tl-update-docindex +++ b/Master/tlpkg/bin/tl-update-docindex @@ -1,124 +1,124 @@ #!/usr/bin/env perl # $Id$ # Make index file of all HTML and PDF documentation (printed on stdout). -# Originally written 2004, Karl Berry. Public domain. - -exit (&main ()); - -sub main -{ - (my $progname = $0) =~ s,^.*/,,; - umask (0); - $ENV{'LC_ALL'} = 'C'; # for the date command used below - - chomp (my $mydir = `dirname $0`); - chdir ("$mydir/../..") || exit 1; # Master - - # shell fragment we use to find doc files in a directory. - $ENV{"_POSIX2_VERSION"} = 0; # POSIX likes to be backward-incompatible - $FIND_POST = " \\( -name \\*.html -o -name \\*.pdf \\) " - . " | tee /tmp/doclist" - . " | sort -f -t/ +2 |"; - - print < +# Originally written 2009, Manuel Pégourié-Gonnard. WTFPL v2. + +BEGIN { + $0 =~ m#(.*)/(.*)#; ($progdir, $progname) = ($1, $2); + unshift @INC, "$progdir/.."; +} + +use warnings FATAL => 'all'; +use Fatal qw(:void open close opendir closedir chdir mkdir); + +use TeXLive::TLPDB; +use File::Basename; + +exit(main()); + +sub main { + my $tlpdb = TeXLive::TLPDB->new('root' => "$progdir/../.."); + die "$progname: unable to load TLPDB\n" unless defined $tlpdb; + + print < + + + TeX Live documentation + +

TeX Live documentation

This document lists links to all HTML and PDF files for packages and guides -contained in TeX Live (in the texmf and texmf-dist directories), sorted by package name.

+contained in TeX Live, sorted by package name.

END_HEADER - &do_package_list (); - - chomp (my $date = `date`); - print < + print_all_pkg($tlpdb); + + # print footer + chomp (my $date = `LC_ALL=C date`); + print < Generated $date by $progname. END_TRAILER - - return 0; -} - - -# Package doc (texmf and texmf-dist), by package. -# -sub do_package_list -{ - &do_filelist ("find texmf/doc texmf-dist/doc $FIND_POST"); + return 0; } +# print the links for letters, then packages +sub print_all_pkg { + my ($tlpdb) = @_; - -# Process all files resulting from OPENCMD. -# -sub do_filelist -{ - my ($opencmd) = @_; - - print "\n
    \n"; - my $prevdir = ""; - my @entries = (); - - $FILELIST = $opencmd; - open (FILELIST) || die "open($FILELIST) failed: $!"; - while () { - chomp; - # collect all files for a given directory - (my $thisdir = $_) =~ s,/[^/]*$,,; - - if ($thisdir eq $prevdir) { - push (@entries, $_); - } else { - &do_directory ($prevdir, @entries) if $prevdir; # avoid first empty - $prevdir = $thisdir; - @entries = ($_); + # @lines is the big list, @letters the list of initials of package names + local (@lines, @letters, $current_letter, $n); + $current_letter = "\0"; + + # first build the output and the list of initials + for my $tlpn (sort {lc $a cmp lc $b} $tlpdb->list_packages) { + my $tlpkg = $tlpdb->get_package($tlpn); + push_pkg_list($tlpkg); } - } - close (FILELIST) || warn "close($FILELIST) failed: $!"; - - &do_directory ($prevdir, @entries); # include last + push @lines, "\n
\n\n"; - print "\n\n"; + # then actually print them + my $access = "\n

" . join(" - ", @letters) . "

\n"; + print $access; + print @lines; + print $access; } +# push the content for a package to the list of lines +sub push_pkg_list { + my ($tlpkg) = @_; + my $name = $tlpkg->name; + my @docfiles = $tlpkg->docfiles; + + # if no adequate documentation is found, print nothing + @docfiles = grep { m/\.(html|pdf)/ } @docfiles; + return if @docfiles == 0; + $n++; # list counter + + # check initial + my $init = uc substr $name, 0, 1; + unless ($init eq $current_letter) { + $current_letter = $init; + # put header in the big list... + push @lines, "\n\n" unless $n == 1; + push @lines, qq#\n

$init

\n#; + push @lines, qq#\n
    \n#; + # ... and a reference in quick access list + push @letters, qq!$init!; + } + + # if there is an index.html file, drop the rest + # currently (2009-10-07) catches: FAQ-en bosisio epspdf fontname jadetex + # metapost ppower4 sttools tds tex4ht + my @index = grep /\/index\.html/, @docfiles; + if (@index == 1) { + #warn "Using index.html for $name\n"; + @docfiles = @index; + } - -# Print doc ENTRIES in DIR. -# -sub do_directory -{ - my ($dir,@entries) = @_; - - # $dir includes the texmf tree, e.g., - # texmf-dist/doc/allrunes - # This is too ugly. We just want to show allrunes, especially since - # that's what we sorted by. - my (undef,undef,$nicename) = split (/\//, $dir, 3); - - print qq!
  1. $nicename!; - - # if we have an index.html or a live.html, make things nicer. - if (grep { m,/(index|live)\.html$, } @entries) { - # first remove all .html's. - @entries = grep { $_ !~ /\.html$/ - || $_ =~ m,/(index|live)\.html, } @entries; - - # if only one entry left, remove it, the directory link suffices. - @entries = () if $entries[0] =~ m,/index\.html$, && @entries == 1; - } - - # if we're going to print anything, insert punctuation. - print ":" if @entries; - print "\n"; - - for my $e (@entries) { - (my $basename = $e) =~ s,.*/,,; - print qq! $basename\n!; - } - - print " \n\n"; + # print package name with shortdesc + my $dir = dirname($docfiles[0]); + push @lines, qq#\n
  2. $name:\n#; + my $shortdesc = $tlpkg->shortdesc; + push @lines, "$shortdesc\n" if defined $shortdesc; + #warn "$name\n" if not defined $shortdesc; + + # now the list of docfiles + my $list; + for my $file (@docfiles) { + my $name = basename($file); + $list .= qq#$name#; + my $dflanguage = $tlpkg->{'docfiledata'}{$file}{'language'}; + $list .= " ($dflanguage)" if defined $dflanguage; + $list .= ",\n"; + } + $list =~ s/,\n$/./; + push @lines, "$list\n
  3. \n"; } + -- cgit v1.2.3