6 # collect lines continued with a '\' into an array
16 last unless (/\\\s*$/);
21 # regex && eval away unwanted strings from documentation
24 $text =~ s/USAGE_\w+\([\s]*?(".*?").*?\)/$1/sg;
25 $text =~ s/"[\s]*"//sg;
26 my @line = split("\n", $text);
29 map { qq[ sprintf(qq#$_#) ] }
41 # generate POD for an applet
46 my $trivial = $usage->{trivial};
47 $trivial =~s/(?<!\w)(-\w+)/B<$1>/sxg;
50 map { $_ !~ /^\s/ && s/(?<!\w)(-\w+)/B<$1>/g; $_ }
51 split("\n", $usage->{full});
54 "-------------------------------\n".
65 # generate SGML for an applet
73 # the keys are applet names, and
74 # the values will contain hashrefs of the form:
82 # get command-line options
93 if (defined $opt{help}) {
95 "$0 [OPTION]... [FILE]...\n",
104 # collect documenation into %docs
106 open(USAGE, $_) || die("$0: $!");
108 my ($applet, $type, @line);
111 if (/^#define (\w+)_(\w+)_usage/) {
114 @line = continuation($fh);
115 my $doc = $docs{$applet} ||= { };
117 my $text = join("\n", @line);
118 $doc->{$type} = beautify($text);
125 #print Data::Dumper->Dump([\%docs], [qw(docs)]);
127 foreach my $name (sort keys %docs) {
128 print pod_for_usage($name, $docs{$name});
137 autodocifier.pl - generate docs for busybox based on usage.h
141 autodocifier.pl usage.h > something
145 The purpose of this script is to automagically generate documentation
146 for busybox using its usage.h as the original source for content.
147 Currently, the same content has to be duplicated in 3 places in
148 slightly different formats -- F<usage.h>, F<docs/busybox.pod>, and
149 F<docs/busybox.sgml>. Duplicating the same content in these 3 places
150 is tedious, so Perl has come to the rescue.
152 This script was based on an original work by
153 Erik Andersen (andersen@lineo.com).
157 these control my behaviour
163 This displays the help message.
169 files that I manipulate
173 Copyright (c) 2001 John BEPPU. All rights reserved. This program is
174 free software; you can redistribute it and/or modify it under the same
175 terms as Perl itself.
179 John BEPPU <beppu@lineo.com>
183 # $Id: autodocifier.pl,v 1.3 2001/02/23 02:54:31 beppu Exp $