summaryrefslogtreecommitdiff
path: root/autodoc.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2012-04-08 19:44:11 +0200
committerNicholas Clark <nick@ccl4.org>2013-05-23 14:32:40 +0200
commit7882b24ab46e0bf0639d072e21ab7cf7e0fcd042 (patch)
tree8b74f124c236d1bfce0d8d9054c0defd84fa5eab /autodoc.pl
parent0caa72038c587cd4257f9deda63f99fc6cd42d7e (diff)
downloadperl-7882b24ab46e0bf0639d072e21ab7cf7e0fcd042.tar.gz
Refactor autodoc.pl to use regen_lib.pl to generate file headers & footers.
This reduces duplication of code that generates '-*- buffer-read-only: t -*-', 'ex: set ro:' etc.
Diffstat (limited to 'autodoc.pl')
-rw-r--r--autodoc.pl36
1 files changed, 13 insertions, 23 deletions
diff --git a/autodoc.pl b/autodoc.pl
index e000d5abbc..f727a218cc 100644
--- a/autodoc.pl
+++ b/autodoc.pl
@@ -25,6 +25,13 @@
use strict;
+if (@ARGV) {
+ my $workdir = shift;
+ chdir $workdir
+ or die "Couldn't chdir to '$workdir': $!";
+}
+require 'regen/regen_lib.pl';
+
#
# See database of global and static function prototypes in embed.fnc
# This is used to generate prototype headers under various configurations,
@@ -244,17 +251,11 @@ removed without notice.\n\n$docs" if $flags =~ /x/;
sub output {
my ($podname, $header, $dochash, $missing, $footer) = @_;
- my $filename = "pod/$podname.pod";
- open my $fh, '>', $filename or die "Can't open $filename: $!";
-
- print $fh <<"_EOH_", $header;
--*- buffer-read-only: t -*-
-
-!!!!!!! DO NOT EDIT THIS FILE !!!!!!!
-This file is built by $0 extracting documentation from the C source
-files.
+ my $fh = open_new("pod/$podname.pod", undef,
+ {by => "$0 extracting documentation",
+ from => 'the C source files'});
-_EOH_
+ print $fh $header;
my $key;
# case insensitive sort, with fallback for determinacy
@@ -306,20 +307,9 @@ _EOB_
}
print $fh "=back\n\n";
}
+ print $fh $footer, "=cut\n";
-print $fh $footer, <<'_EOF_';
-=cut
-
- ex: set ro:
-_EOF_
-
- close $fh or die "Can't close $filename: $!";
-}
-
-if (@ARGV) {
- my $workdir = shift;
- chdir $workdir
- or die "Couldn't chdir to '$workdir': $!";
+ read_only_bottom_close_and_rename($fh);
}
open IN, "embed.fnc" or die $!;