mirror of
https://git.busybox.net/busybox
synced 2026-01-31 16:43:21 +00:00
In the generated `docs/busybox.pod` file, add a link for each command in the big command list that goes to that command's description, like a compact table of contents. This seems to only affect the generated HTML version of the usage page. To add `id` attributes to each usage section title, each command now uses `=head2` instead of `=item` for their section heading. To add links to each command in the list, the list was unindented so that it could use rich text, and each command was marked as code text (C<>) so they are styled in monospace. These changes mean that the HTML and mandoc command list will expand to fit the available width of the viewport, rather than wrapping at a fixed line-length. The plain text version retains its existing wrapping behavior. Because of the new code text formatting, `--quotes=none` was added to the pod2man and pod2text invocations in Makefile.custom to prevent the command list from quoting every single command. Signed-off-by: Noelle Leigh <noelle@noelle.dev> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
120 lines
2.6 KiB
C
120 lines
2.6 KiB
C
/* vi: set sw=4 ts=4: */
|
|
/*
|
|
* Copyright (C) 2009 Denys Vlasenko.
|
|
*
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
|
*/
|
|
#include <unistd.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
#include "autoconf.h"
|
|
|
|
#define SKIP_applet_main
|
|
#define ALIGN1 /* nothing, just to placate applet_tables.h */
|
|
#define ALIGN2 /* nothing, just to placate applet_tables.h */
|
|
#include "applet_tables.h"
|
|
|
|
/* Since we can't use platform.h, have to do this again by hand: */
|
|
#if ENABLE_NOMMU
|
|
# define BB_MMU 0
|
|
# define USE_FOR_NOMMU(...) __VA_ARGS__
|
|
# define USE_FOR_MMU(...)
|
|
#else
|
|
# define BB_MMU 1
|
|
# define USE_FOR_NOMMU(...)
|
|
# define USE_FOR_MMU(...) __VA_ARGS__
|
|
#endif
|
|
|
|
#include "usage.h"
|
|
#define MAKE_USAGE(aname, usage) { aname, usage },
|
|
static struct usage_data {
|
|
const char *aname;
|
|
const char *usage;
|
|
} usage_array[] = {
|
|
#include "applets.h"
|
|
};
|
|
|
|
static int compare_func(const void *a, const void *b)
|
|
{
|
|
const struct usage_data *ua = a;
|
|
const struct usage_data *ub = b;
|
|
return strcmp(ua->aname, ub->aname);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int col, len2;
|
|
|
|
int i;
|
|
int num_messages = sizeof(usage_array) / sizeof(usage_array[0]);
|
|
|
|
if (num_messages == 0)
|
|
return 0;
|
|
|
|
qsort(usage_array,
|
|
num_messages, sizeof(usage_array[0]),
|
|
compare_func);
|
|
|
|
col = 0;
|
|
for (i = 0; i < num_messages; i++) {
|
|
len2 = strlen(usage_array[i].aname) + 2;
|
|
if (col >= 76 - len2) {
|
|
printf(",\n");
|
|
col = 0;
|
|
}
|
|
if (col == 0) {
|
|
col = 6;
|
|
} else {
|
|
printf(", ");
|
|
}
|
|
if (usage_array[i].usage[0] != NOUSAGE_STR[0]) {
|
|
/*
|
|
* If the applet usage string will be included in the final document
|
|
* optimistically link to its header (which is just the applet name).
|
|
*/
|
|
printf("L<C<%1$s>|/\"%1$s\">", usage_array[i].aname);
|
|
} else {
|
|
/* Without a usage string, just output the applet name with no link. */
|
|
printf("C<%s>", usage_array[i].aname);
|
|
}
|
|
col += len2;
|
|
}
|
|
printf("\n\n");
|
|
|
|
printf("=head1 COMMAND DESCRIPTIONS\n\n");
|
|
|
|
for (i = 0; i < num_messages; i++) {
|
|
if (usage_array[i].aname[0] >= 'a' && usage_array[i].aname[0] <= 'z'
|
|
&& usage_array[i].usage[0] != NOUSAGE_STR[0]
|
|
) {
|
|
/* This is the heading that will be linked from the command list. */
|
|
printf("=head2 %s\n\n", usage_array[i].aname);
|
|
if (usage_array[i].usage[0])
|
|
printf("%s %s\n\n", usage_array[i].aname, usage_array[i].usage);
|
|
else
|
|
printf("%s\n\n", usage_array[i].aname);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* TODO: we used to make options bold with B<> and output an example too:
|
|
|
|
=item B<cat>
|
|
|
|
cat [B<-u>] [FILE]...
|
|
|
|
Concatenate FILE(s) and print them to stdout
|
|
|
|
Options:
|
|
-u Use unbuffered i/o (ignored)
|
|
|
|
Example:
|
|
$ cat /proc/uptime
|
|
110716.72 17.67
|
|
|
|
*/
|