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);
34 eval qq[ sprintf(qq#$_#) ]
40 # generate POD for an applet
46 my $trivial = $usage->{trivial};
47 $trivial =~ s/(?<!\w)(-\w+)/B<$1>/sxg;
49 map { $_ !~ /^\s/ && s/(?<!\w)(-\w+)/B<$1>/g; $_ }
50 split("\n", $usage->{full});
52 # add "\n" prior to certain lines to make indented
56 for (my $i = 0; $i < $len; $i++) {
58 if (($i+1) != $len && $f0[$i] !~ /^\s/ && $f0[$i+1] =~ /^\s/) {
59 next if ($f0[$i] =~ /^$/);
60 push(@f1, "") unless ($f0[$i+1] =~ /^\s*$/s);
63 my $full = join("\n", @f1);
65 # prepare example if one exists
66 my $example = (defined $usage->{example})
67 ? "Example:\n\n$usage->{example}\n\n"
78 "-------------------------------".
83 # FIXME | generate SGML for an applet
94 # the keys are applet names, and
95 # the values will contain hashrefs of the form:
104 # get command-line options
116 if (defined $opt{help}) {
118 "$0 [OPTION]... [FILE]...\n",
128 # collect documenation into %docs
131 open(USAGE, $_) || die("$0: $_: $!");
133 my ($applet, $type, @line);
135 if (/^#define (\w+)_(\w+)_usage/) {
138 @line = continuation($fh);
139 my $doc = $docs{$applet} ||= { };
141 my $text = join("\n", @line);
142 $doc->{$type} = beautify($text);
148 # generate structured documentation
150 my $generator = \&pod_for_usage;
151 if (defined $opt{sgml}) {
152 $generator = \&sgml_for_usage;
155 foreach my $applet (sort keys %docs) {
156 print $generator->($applet, $docs{$applet});
165 autodocifier.pl - generate docs for busybox based on usage.h
169 autodocifier.pl usage.h > something
173 The purpose of this script is to automagically generate documentation
174 for busybox using its usage.h as the original source for content.
175 Currently, the same content has to be duplicated in 3 places in
176 slightly different formats -- F<usage.h>, F<docs/busybox.pod>, and
177 F<docs/busybox.sgml>. This is tedious, so Perl has come to the rescue.
179 This script was based on a script by Erik Andersen (andersen@lineo.com).
187 This displays the help message.
191 Generate POD (this is the default)
199 Be verbose (not implemented)
209 Copyright (c) 2001 John BEPPU. All rights reserved. This program is
210 free software; you can redistribute it and/or modify it under the same
211 terms as Perl itself.
215 John BEPPU <beppu@lineo.com>
219 # $Id: autodocifier.pl,v 1.13 2001/02/26 02:50:11 beppu Exp $