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_NOT\w+\(.*?"\s*\)//sxg;
25 $text =~ s/USAGE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
27 my @line = split("\n", $text);
30 map { qq[ sprintf(qq#$_#) ] }
39 print STDERR "-- d\n";
44 # generate POD for an applet
49 my $trivial = $usage->{trivial};
50 $trivial =~s/(?<!\w)(-\w+)/B<$1>/sxg;
54 map { $_ !~ /^\s/ && s/(?<!\w)(-\w+)/B<$1>/g; $_ }
55 split("\n", $usage->{full}));
58 "-------------------------------\n".
69 # generate SGML for an applet
77 # the keys are applet names, and
78 # the values will contain hashrefs of the form:
86 # get command-line options
97 if (defined $opt{help}) {
99 "$0 [OPTION]... [FILE]...\n",
108 # collect documenation into %docs
110 open(USAGE, $_) || die("$0: $!");
112 my ($applet, $type, @line);
115 if (/^#define (\w+)_(\w+)_usage/) {
118 @line = continuation($fh);
119 my $doc = $docs{$applet} ||= { };
121 my $text = join("\n", @line);
122 $doc->{$type} = beautify($text);
129 #print Data::Dumper->Dump([\%docs], [qw(docs)]);
131 foreach my $name (sort keys %docs) {
132 print pod_for_usage($name, $docs{$name});
141 autodocifier.pl - generate docs for busybox based on usage.h
145 autodocifier.pl usage.h > something
149 The purpose of this script is to automagically generate documentation
150 for busybox using its usage.h as the original source for content.
151 Currently, the same content has to be duplicated in 3 places in
152 slightly different formats -- F<usage.h>, F<docs/busybox.pod>, and
153 F<docs/busybox.sgml>. This is tedious, so Perl has come to the rescue.
155 This script was based on a script by Erik Andersen (andersen@lineo.com).
159 these control my behaviour
165 This displays the help message.
171 files that I manipulate
175 Copyright (c) 2001 John BEPPU. All rights reserved. This program is
176 free software; you can redistribute it and/or modify it under the same
177 terms as Perl itself.
181 John BEPPU <beppu@lineo.com>
185 # $Id: autodocifier.pl,v 1.6 2001/02/23 16:15:34 beppu Exp $