#!/usr/local/bin/perl # $Id: //depot/Master/Tools/mkdocindex#2 $ # Make index file of all HTML and PDF documentation. # Originally written 2004, Karl Berry. Public domain. exit (&main ()); sub main { (my $progname = $0) =~ s,^.*/,,; umask (0); chomp (my $mydir = `dirname $0`); # Tools chdir ("$mydir/..") || exit 1; # Master # shell fragment we use to find doc files in a directory. $FIND_POST = " \\( -name \\*.html -o -name \\*.pdf \\) " . " | sort -f -t/ +3 |"; print <

TeX Live documentation

1. Package documentation

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

Jump to guide documentation. END_HEADER &do_package_list (); print <

2. Guide documentation

This section lists links to all guides, that is, packages consisting only of documentation (in the texmf-doc directory), sorted by language.

Jump to package documentation. END_BETWEEN &do_guide_list (); chomp (my $date = `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"); } # Guide doc (texmf-doc), by language. In order to generate a list of # all the languages at the beginning, we generate everything before # writing anything. # sub do_guide_list { # each subdir in texmf-doc is a language, except general. my @langs = map { s,.*/,,; $_ } glob ("texmf-doc/doc/*"); my @langs = grep { $_ ne "general" } @langs; print "\n

Languages:\n

\n"; $count = 0; # for subsection numbers for my $lang (@langs) { $count++; print qq!\n!; print qq!

2.$count $lang

\n!; &do_filelist ("find texmf-doc/doc/$lang $FIND_POST"); } } # 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 = ($_); } } close (FILELIST) || warn "close($FILELIST) failed: $!"; &do_directory ($prevdir, @entries); # include last print "\n
\n"; } # 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!
  • $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"; }