diff options
Diffstat (limited to 'Master/tlpkg/bin/tl-update-docindex3')
-rwxr-xr-x | Master/tlpkg/bin/tl-update-docindex3 | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/Master/tlpkg/bin/tl-update-docindex3 b/Master/tlpkg/bin/tl-update-docindex3 new file mode 100755 index 00000000000..b00f708174a --- /dev/null +++ b/Master/tlpkg/bin/tl-update-docindex3 @@ -0,0 +1,93 @@ +#!/usr/bin/env perl +# $Id: tl-update-docindex2 15670 2009-10-07 15:28:42Z mpg $ +# Make index file of all HTML and PDF documentation (printed on stdout). +# 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 <<END_HEADER; +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>TeX Live documentation</title> + <style type="text/css"> ol { padding-left: 4em } </style> +</head> +<body> +<h1>TeX Live documentation</h1> + +<p>This document lists links to all HTML and PDF files for packages and guides +contained in TeX Live, sorted by TeX Live package name.</p> +END_HEADER + + # actually print the list + print "\n<ol>\n"; + for my $tlpn ($tlpdb->list_packages) { + my $tlpkg = $tlpdb->get_package($tlpn); + print_pkg_list($tlpkg); + } + print "\n</ol>\n\n"; + + # print footer + chomp (my $date = `LC_ALL=C date`); + print <<END_TRAILER; +<hr /> +<small>Generated $date by $progname.</small> +</body></html> +END_TRAILER + + return 0; +} + +sub print_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; + + # 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; + } + + # now print the list + print "\n<li><b>$name</b>:<small>\n"; + for my $file (@docfiles) { + my $name = basename($file); + my $dfdetails = $tlpkg->{'docfiledata'}{$file}{'details'}; + my $dflanguage = $tlpkg->{'docfiledata'}{$file}{'language'}; + my @foo; + push @foo, $dflanguage if defined($dflanguage); + push @foo, $dfdetails if defined($dfdetails); + print qq! <a href="$file">$name</a>!; + if (@foo) { + print "(", join(",", @foo), ")"; + } + print "\n"; + } + print "</small></li>\n"; +} + |