#! /usr/bin/perl # # Configuration and generation of .doc-base.ocamldoc-apiref # # Copyright © 2009 Mehdi Dogguy # # License: GPL-2+ # See `/usr/share/common-licenses/GPL'. ###################################################################### use Getopt::Long; sub usage() { print << "EOF"; Usage: $0 [options] packages --help|-h|-? Print this help message --packages Package name --prefix Prefix (default is: /usr/share/doc) --html-directory Directory name where the generated file will go --index-file Manual entry file (default is: index.html) EOF exit(1); } sub generate_doc_base($$$$) { my ($prefix, $html, $pkg, $index) = @_; open(DOCBASE, "> debian/$pkg.doc-base.ocamldoc-apiref") || die("cannot find debian/$pkg.doc-base.ocamldoc-apiref\n"); print DOCBASE << "EOF"; Document: $pkg-ocamldoc-api-reference Title: $pkg OCamldoc API Reference Abstract: API reference manual for $pkg (generated via OCamldoc) Section: Programming/OCaml Format: HTML Index: $prefix/$pkg/$html/$index Files: $prefix/$pkg/$html/* EOF close DOCBASE; } sub html_directory($$) { my ($pkg, $html) = @_; print "$prefix/$pkg/$html\n"; exit; } if ( @ARGV > 0 ) { GetOptions('help|h|?' => \$help, 'doc-base-generate' => \$docbase, 'packages=s' => \$pkg, 'prefix=s' => \$prefix, 'html-directory=s' => \$html, 'index-file=s' => \$index, ); } my @packages = split(/ /, $pkg); usage() if ($help || @packages == 0); $html="html/api" if !$html; $index="index.html" if !$index; $prefix="/usr/share/doc" if !$prefix; for my $pkg (@packages) { generate_doc_base($prefix, $html, $pkg, $index); }