diff options
author | John Beppu <beppu@lbox.org> | 2001-02-26 02:50:11 +0000 |
---|---|---|
committer | John Beppu <beppu@lbox.org> | 2001-02-26 02:50:11 +0000 |
commit | d11578f9167a5bc10cf77544cc1d64965d3f8f2b (patch) | |
tree | d632015e9fd9c6cad4497a232f48b87e3ffd9e30 | |
parent | 2bf658d5cd4460a0e0a8a8f3c8dc3b71be05d1ba (diff) | |
download | busybox-w32-d11578f9167a5bc10cf77544cc1d64965d3f8f2b.tar.gz busybox-w32-d11578f9167a5bc10cf77544cc1d64965d3f8f2b.tar.bz2 busybox-w32-d11578f9167a5bc10cf77544cc1d64965d3f8f2b.zip |
- changed the way POD is generated such that the dashed
line appears at the bottom instead of the top. The
indentation semantics of POD make the first item in
the (=over,=back) block look weird the other way.
- implemented a way to encode example usage into usage.h
One would define a macro called "${applet}_example_usage"
which would expand to the example text.
- The example usage is considered optional, but trivial and
full usage are not.
Here's an example using chown.
---- before
#define chown_trivial_usage \
"[OPTION]... OWNER[<.|:>[GROUP] FILE..."
#define chown_full_usage \
"Change the owner and/or group of each FILE to OWNER and/or GROUP.\n" \
"\nOptions:\n" \
"\t-R\tChanges files and directories recursively."
#define chown_example_usage \
"\t$ ls -l /tmp/foo\n" \
"\t-r--r--r-- 1 andersen andersen 0 Apr 12 18:25 /tmp/foo\n" \
"\t$ chown root /tmp/foo\n" \
"\t$ ls -l /tmp/foo\n" \
"\t-r--r--r-- 1 root andersen 0 Apr 12 18:25 /tmp/foo\n" \
"\t$ chown root.root /tmp/foo\n" \
"\tls -l /tmp/foo\n" \
"\t-r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo\n"
---- after
=item I<chown>
chown [OPTION]... OWNER[<.|:>[GROUP] FILE...
Change the owner and/or group of each FILE to OWNER and/or GROUP.
Options:
-R Changes files and directories recursively.
Example:
$ ls -l /tmp/foo
-r--r--r-- 1 andersen andersen 0 Apr 12 18:25 /tmp/foo
$ chown root /tmp/foo
$ ls -l /tmp/foo
-r--r--r-- 1 root andersen 0 Apr 12 18:25 /tmp/foo
$ chown root.root /tmp/foo
ls -l /tmp/foo
-r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo
-------------------------------
-rwxr-xr-x | docs/autodocifier.pl | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/docs/autodocifier.pl b/docs/autodocifier.pl index 6822db51e..2d5e04a2e 100755 --- a/docs/autodocifier.pl +++ b/docs/autodocifier.pl | |||
@@ -30,6 +30,7 @@ sub beautify { | |||
30 | s/^\s*//; | 30 | s/^\s*//; |
31 | s/"//g; | 31 | s/"//g; |
32 | s/%/%%/g; | 32 | s/%/%%/g; |
33 | s/\$/\\\$/g; | ||
33 | eval qq[ sprintf(qq#$_#) ] | 34 | eval qq[ sprintf(qq#$_#) ] |
34 | } @line | 35 | } @line |
35 | ); | 36 | ); |
@@ -43,7 +44,7 @@ sub pod_for_usage { | |||
43 | 44 | ||
44 | # make options bold | 45 | # make options bold |
45 | my $trivial = $usage->{trivial}; | 46 | my $trivial = $usage->{trivial}; |
46 | $trivial =~s/(?<!\w)(-\w+)/B<$1>/sxg; | 47 | $trivial =~ s/(?<!\w)(-\w+)/B<$1>/sxg; |
47 | my @f0 = | 48 | my @f0 = |
48 | map { $_ !~ /^\s/ && s/(?<!\w)(-\w+)/B<$1>/g; $_ } | 49 | map { $_ !~ /^\s/ && s/(?<!\w)(-\w+)/B<$1>/g; $_ } |
49 | split("\n", $usage->{full}); | 50 | split("\n", $usage->{full}); |
@@ -59,16 +60,22 @@ sub pod_for_usage { | |||
59 | push(@f1, "") unless ($f0[$i+1] =~ /^\s*$/s); | 60 | push(@f1, "") unless ($f0[$i+1] =~ /^\s*$/s); |
60 | } | 61 | } |
61 | } | 62 | } |
62 | |||
63 | my $full = join("\n", @f1); | 63 | my $full = join("\n", @f1); |
64 | |||
65 | # prepare example if one exists | ||
66 | my $example = (defined $usage->{example}) | ||
67 | ? "Example:\n\n$usage->{example}\n\n" | ||
68 | : ""; | ||
69 | |||
64 | return | 70 | return |
65 | "-------------------------------\n". | 71 | "=item I<$name>". |
66 | "\n". | 72 | "\n\n" . |
67 | "=item $name". | ||
68 | "\n\n". | ||
69 | "$name $trivial". | 73 | "$name $trivial". |
70 | "\n\n". | 74 | "\n\n" . |
71 | $full. | 75 | $full . |
76 | "\n\n" . | ||
77 | $example. | ||
78 | "-------------------------------". | ||
72 | "\n\n" | 79 | "\n\n" |
73 | ; | 80 | ; |
74 | } | 81 | } |
@@ -121,7 +128,7 @@ if (defined $opt{help}) { | |||
121 | # collect documenation into %docs | 128 | # collect documenation into %docs |
122 | 129 | ||
123 | foreach (@ARGV) { | 130 | foreach (@ARGV) { |
124 | open(USAGE, $_) || die("$0: $!"); | 131 | open(USAGE, $_) || die("$0: $_: $!"); |
125 | my $fh = *USAGE; | 132 | my $fh = *USAGE; |
126 | my ($applet, $type, @line); | 133 | my ($applet, $type, @line); |
127 | while (<$fh>) { | 134 | while (<$fh>) { |
@@ -209,4 +216,4 @@ John BEPPU <beppu@lineo.com> | |||
209 | 216 | ||
210 | =cut | 217 | =cut |
211 | 218 | ||
212 | # $Id: autodocifier.pl,v 1.12 2001/02/24 14:44:25 beppu Exp $ | 219 | # $Id: autodocifier.pl,v 1.13 2001/02/26 02:50:11 beppu Exp $ |