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#$_#) ] }
42 # generate POD for an applet
48 my $trivial = $usage->{trivial};
49 $trivial =~s/(?<!\w)(-\w+)/B<$1>/sxg;
52 map { $_ !~ /^\s/ && s/(?<!\w)(-\w+)/B<$1>/g; $_ }
53 split("\n", $usage->{full});
55 # add "\n" prior to certain lines to make indented
58 for (my $i = 0; $i < $len; $i++) {
60 if (($i+1) != $len && $f0[$i] !~ /^\s/ && $f0[$i+1] =~ /^\s/) {
61 next if ($f0[$i] =~ /^$/);
62 push(@f1, "") unless ($f0[$i+1] =~ /^\s*$/s);
66 my $full = join("\n", @f1);
68 "-------------------------------\n".
79 # generate SGML for an applet
90 # the keys are applet names, and
91 # the values will contain hashrefs of the form:
99 # get command-line options
110 if (defined $opt{help}) {
112 "$0 [OPTION]... [FILE]...\n",
121 # collect documenation into %docs
123 open(USAGE, $_) || die("$0: $!");
125 my ($applet, $type, @line);
128 if (/^#define (\w+)_(\w+)_usage/) {
131 @line = continuation($fh);
132 my $doc = $docs{$applet} ||= { };
134 my $text = join("\n", @line);
135 $doc->{$type} = beautify($text);
141 my $generator = \&pod_for_usage;
142 if (defined $opt{sgml}) {
143 $generator = \&sgml_for_usage;
146 foreach my $name (sort keys %docs) {
147 print $generator->($name, $docs{$name});
156 autodocifier.pl - generate docs for busybox based on usage.h
160 autodocifier.pl usage.h > something
164 The purpose of this script is to automagically generate documentation
165 for busybox using its usage.h as the original source for content.
166 Currently, the same content has to be duplicated in 3 places in
167 slightly different formats -- F<usage.h>, F<docs/busybox.pod>, and
168 F<docs/busybox.sgml>. This is tedious, so Perl has come to the rescue.
170 This script was based on a script by Erik Andersen (andersen@lineo.com).
178 This displays the help message.
182 Generate POD (this is the default)
190 Be verbose (not implemented)
200 Copyright (c) 2001 John BEPPU. All rights reserved. This program is
201 free software; you can redistribute it and/or modify it under the same
202 terms as Perl itself.
206 John BEPPU <beppu@lineo.com>
210 # $Id: autodocifier.pl,v 1.10 2001/02/23 17:55:03 beppu Exp $