diff options
author | Karl Berry <karl@freefriends.org> | 2008-06-09 20:12:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2008-06-09 20:12:47 +0000 |
commit | c2ded34c4ac6a32fbed94b870481aaf9667fc227 (patch) | |
tree | cc7b9d209a306f44bc962ea8d7357307b9460ca9 /Master/tlpkg/bin/tl-update-docindex | |
parent | 07b1dd24a6c6ca7ac335c56b3cc3127bd7910619 (diff) |
move autoupdate scripts to new tools bindir
git-svn-id: svn://tug.org/texlive/trunk@8623 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/bin/tl-update-docindex')
-rwxr-xr-x | Master/tlpkg/bin/tl-update-docindex | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/Master/tlpkg/bin/tl-update-docindex b/Master/tlpkg/bin/tl-update-docindex new file mode 100755 index 00000000000..4e7630686f4 --- /dev/null +++ b/Master/tlpkg/bin/tl-update-docindex @@ -0,0 +1,167 @@ +#!/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/../../Master") || 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 <<END_HEADER; +<html> +<body> +<h1>TeX Live documentation</h2> + +<a name="packagedoc"></a> +<h2>1. Package documentation</h2> + +<p>This section lists links to all HTML and PDF files for packages (in +the <a href="texmf/">texmf</a> and <a href="texmf-dist/">texmf-dist</a> +directories), sorted by package name. + +<p><a href="#guidedoc">Jump to guide documentation</a>. +END_HEADER + + &do_package_list (); + + print <<END_BETWEEN; +<a name="guidedoc"></a> +<h2>2. Guide documentation</h2> + +<p>This section lists links to all guides, that is, packages consisting +only of documentation (in the <a href="texmf-doc/">texmf-doc</a> +directory), sorted by language. + +<p><a href="#packagedoc">Jump to package documentation</a>. +END_BETWEEN + + &do_guide_list (); + + chomp (my $date = `date`); + print <<END_TRAILER; +<hr> +<small>Generated $date by $progname.</small> +</body></html> +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<p>Languages:\n<ul>\n"; + print map { qq!<li><a href="#$_">$_</a>\n! } @langs; + print "</ul>\n"; + + $count = 0; # for subsection numbers + for my $lang (@langs) { + $count++; + print qq!<a name="#$lang"></a>\n!; + print qq!<h3>2.$count <a href="texmf-doc/doc/$lang/">$lang</a></h3>\n!; + + &do_filelist ("find texmf-doc/doc/$lang $FIND_POST"); + } +} + + + +# Process all files resulting from OPENCMD. +# +sub do_filelist +{ + my ($opencmd) = @_; + + print "\n<ol>\n"; + my $prevdir = ""; + my @entries = (); + + $FILELIST = $opencmd; + open (FILELIST) || die "open($FILELIST) failed: $!"; + while (<FILELIST>) { + 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</ol>\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!<li><b><a href="$dir">$nicename</a>!; + + # 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 "</b><small>\n"; + + for my $e (@entries) { + (my $basename = $e) =~ s,.*/,,; + print qq! <a href="$e">$basename</a>\n!; + } + + print " </small>\n\n"; +} |