From 89f15738aecf9be4ba9e1acb2b3582697b049b9b Mon Sep 17 00:00:00 2001 From: Daniel Elstner Date: Mon, 10 Aug 2009 16:21:29 +0200 Subject: Have mm-common-prepare install the doc utils * configure.ac: Call MM_CONFIG_DOCTOOL_DIR([docs]) to set up the destination directory for mm-common-prepare to copy the documentation utilities to. * docs/doc-install.pl: Delete file. * docs/doc-postprocess.pl: ditto, * docs/tagfile-to-devhelp2.xsl: ditto. --- docs/doc-install.pl | 221 ------------------------------------------- docs/doc-postprocess.pl | 81 ---------------- docs/tagfile-to-devhelp2.xsl | 79 ---------------- 3 files changed, 381 deletions(-) delete mode 100644 docs/doc-install.pl delete mode 100644 docs/doc-postprocess.pl delete mode 100644 docs/tagfile-to-devhelp2.xsl (limited to 'docs') diff --git a/docs/doc-install.pl b/docs/doc-install.pl deleted file mode 100644 index 19515ad3..00000000 --- a/docs/doc-install.pl +++ /dev/null @@ -1,221 +0,0 @@ -package main; - -# Copyright (c) 2009 Openismus GmbH -# -# This file is part of mm-common. -# -# mm-common is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 2 of the License, -# or (at your option) any later version. -# -# mm-common is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with mm-common. If not, see . - -use strict; -use warnings; -use bytes; -use File::Spec; -use Getopt::Long qw(:config no_getopt_compat no_ignore_case require_order bundling); - -# Globals -my $message_prefix; -my %tags_hash; -my $book_base; -my $perm_mode; -my $target_dir; -my $target_nodir = ''; -my $expand_glob = ''; -my $verbose = ''; - -sub path_basename ($) -{ - my ($path) = @_; - my $basename = File::Spec->splitpath($path); - - return $basename; -} - -sub exit_help () -{ - my $script_name = path_basename($0) || 'doc-install.pl'; - - print <<"EOF"; -Usage: perl $script_name [OPTION]... [-T] SOURCE DEST - or: perl $script_name [OPTION]... SOURCE... DIRECTORY - or: perl $script_name [OPTION]... -t DIRECTORY SOURCE... - -Copy SOURCE to DEST or multiple SOURCE files to the existing DIRECTORY, -while setting permission modes. For HTML files, translate references to -external documentation. - -Mandatory arguments to long options are mandatory for short options, too. - --book-base=BASEPATH use reference BASEPATH for Devhelp book - -l, --tag-base=TAGFILE\@BASEPATH use BASEPATH for references from TAGFILE - -m, --mode=MODE override file permission MODE (octal) - -t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY - -T, --no-target-directory treat DEST as normal file - --glob expand SOURCE as filename glob pattern - -v, --verbose enable informational messages - -?, --help display this help and exit -EOF - exit; -} - -sub notice (@) -{ - print($message_prefix, @_, "\n") if ($verbose); -} - -sub warning (@) -{ - print STDERR ($message_prefix, @_, "\n"); -} - -sub error (@) -{ - warning(@_); - exit 1; -} - -# Copy file to destination while translating references on the fly. -# Sniff the content for the file type, as it is always read in anyway. -sub install_file ($$$) -{ - my ($in_name, $out_name, $basename) = @_; - my ($in, $out, $buf); - { - local $/; # slurp mode: read entire file into buffer - - open($in, '<', $in_name) and binmode($in) and defined($buf = <$in>) and close($in) - or error('Failed to read ', $basename, ': ', $!); - } - - if (%tags_hash and $buf =~ m/\A(?> \s*)(?> (?> <[?!][^<]+ )* )\s]/sx) - { - my $count = 0; - my $total = $buf =~ - s!(?<= \s) doxygen="((?> [^:"]+)):((?> [^"]*))" # doxygen="(TAGFILE):(BASEPATH)" - (?> \s+) ((?> href|src) =") \2 ((?> [^"]*)") # (href|src=")BASEPATH(RELPATH") - ! $3 . ((exists $tags_hash{$1}) ? (++$count, $tags_hash{$1}) : $2) . $4 - !egsx; - my $change = $total ? "rewrote $count of $total" - : 'no'; - notice('Translating ', $basename, ' (', $change, ' references)'); - } - elsif (defined($book_base) and $buf =~ m/\A(?> \s*)(?> (?> <[?!][^<]+ )* ) - my $change = $buf =~ s/(]*? \b base=") (?> [^"]*) (?= ")/$1$book_base/sx - ? 'rewrote base path' - : 'base path not set'; - notice('Translating ', $basename, ' (', $change, ')'); - } - else - { - notice('Copying ', $basename); - } - - # Avoid inheriting permissions of existing file - unlink($out_name); - - open($out, '>', $out_name) and binmode($out) and print $out ($buf) and close($out) - or error('Failed to write ', $basename, ': ', $!); - - chmod($perm_mode, $out_name) - or warning('Failed to set ', $basename, ' permissions: ', $!); -} - -# Split TAGFILE@BASEPATH argument into key/value pair -sub split_key_value ($) -{ - my ($mapping) = @_; - my ($name, $path) = split(m'@', $mapping, 2); - - error('Invalid base path mapping: ', $mapping) unless (defined($name) and $name ne ''); - - if (defined $path) - { - notice('Using base path ', $path, ' for tag file ', $name); - return ($name, $path); - } - notice('Not changing base path for tag file ', $name); - return (); -} - -# Define line leader of log messages -$message_prefix = path_basename($0); -$message_prefix =~ s/\.[^.]*$//s if (defined $message_prefix); -$message_prefix = ($message_prefix || 'doc-install') . ': '; - -# Process command-line options -{ - my @tags = (); - my $mode = '0644'; - - GetOptions('book-base=s' => \$book_base, - 'tag-base|l=s' => \@tags, - 'mode|m=s' => \$mode, - 'target-directory|t=s' => \$target_dir, - 'no-target-directory|T' => \$target_nodir, - 'glob' => \$expand_glob, - 'verbose|v' => \$verbose, - 'help|?' => \&exit_help) - or exit 2; - - error('Invalid permission mode: ', $mode) unless ($mode =~ m/^[0-7]+$/s); - - $perm_mode = oct($mode); - %tags_hash = map(split_key_value($_), @tags); -} -notice('Using base path ', $book_base, ' for Devhelp book') if (defined $book_base); - -if ($target_nodir) -{ - error('Conflicting target directory options') if (defined $target_dir); - error('Source and destination filenames expected') unless ($#ARGV == 1); - error('Filename globbing requires target directory') if ($expand_glob); - - install_file($ARGV[0], $ARGV[1], path_basename($ARGV[1])); - exit; -} - -unless (defined $target_dir) -{ - if (!$expand_glob and $#ARGV == 1) - { - my $basename = path_basename($ARGV[1]); - - if (defined($basename) and $basename ne '') - { - install_file($ARGV[0], $ARGV[1], $basename); - exit; - } - } - $target_dir = pop(@ARGV); -} -error('No target directory specified') unless (defined($target_dir) and $target_dir ne ''); - -@ARGV = map(glob, @ARGV) if ($expand_glob); -my %basename_hash = (); - -foreach my $in_name (@ARGV) -{ - my $basename = path_basename($in_name); - my $out_name = File::Spec->catfile($target_dir, $basename); - - # If there are multiple files with the same base name in the list, only - # the first one will be installed. This behavior makes it very easy to - # implement a VPATH search for each individual file. - unless (exists $basename_hash{$basename}) - { - $basename_hash{$basename} = undef; - install_file($in_name, $out_name, $basename); - } -} -exit; diff --git a/docs/doc-postprocess.pl b/docs/doc-postprocess.pl deleted file mode 100644 index 7da75d8e..00000000 --- a/docs/doc-postprocess.pl +++ /dev/null @@ -1,81 +0,0 @@ -package main; - -# Copyright (c) 2009 Daniel Elstner -# -# This file is part of mm-common. -# -# mm-common is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 2 of the License, -# or (at your option) any later version. -# -# mm-common is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with mm-common. If not, see . - -use strict; -use warnings; -use bytes; - -foreach my $filename (map(glob, @ARGV)) -{ - my @outbuf = (); - my $file; - - open($file, '<', $filename); - - while (<$file>) - { - if (/|)template</$1template </; - } - s/ / /g; - - push(@outbuf, $_); - } - close($file); - - # write the whole buffer back - open($file, '>', $filename); - print $file ($_) foreach (@outbuf); - close($file); -} - -exit; diff --git a/docs/tagfile-to-devhelp2.xsl b/docs/tagfile-to-devhelp2.xsl deleted file mode 100644 index 8dd55ec5..00000000 --- a/docs/tagfile-to-devhelp2.xsl +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.1