#include <getopt.h>
const char *_lvt_enum_to_name(int lvt_enum);
-
+const size_t _LONG_LINE = 42; /* length of line that neededs .nh .. .hy */
/*
* This file can be compiled by itself as a man page generator.
*/
printf(" ]");
}
- printf("\n\n");
+ printf(".P\n");
}
void print_usage_notes(struct command_name *cname)
if (strchr(str, '|')) {
if (!(line = strdup(str)))
return;
- if ((_was_hyphen = (strlen(line) > 42)))
+ if ((_was_hyphen = (strlen(line) > _LONG_LINE)))
/* TODO: prevent line to end with already printed space */
- printf("\n.nh\n");
+ printf("\\c\n.nh\n\\%%");
_split_line(line, &line_argc, line_argv, '|');
for (i = 0; i < line_argc; i++) {
if (i)
printf("|%s", _was_hyphen ? "\\:" : "");
+
+ if (strncmp(line_argv[i], "[Number]", 8) == 0) {
+ printf("[\\fINumber\\fP]");
+ line_argv[i] += 8;
+ }
+
if (strstr(line_argv[i], "Number"))
printf("\\fI%s\\fP", line_argv[i]);
else
if (cmd->oo_count) {
printf(".RS 4\n");
+ printf(".ad l\n");
if (include_extents) {
/*
* actual val type for extents_ARG has been adjusted
* in opt_names[] according to the command name.
*/
- printf(".ad l\n");
printf("[ \\fB-l\\fP|\\fB--extents\\fP ");
_print_val_man(cname, extents_ARG, opt_names[extents_ARG].val_enum);
printf_hyphen(']');
- printf(".ad b\n");
sep = 1;
}
if (sep)
printf(".br\n");
- printf(".ad l\n");
printf("[ \\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
_print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1, NULL);
}
printf_hyphen(']');
- printf(".ad b\n");
sep = 1;
}
if (sep)
printf(".br\n");
- printf(".ad l\n");
/* space alignment without short opt */
printf("[ ");
_print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1, NULL);
}
printf_hyphen(']');
- printf(".ad b\n");
sep = 1;
}
/* printf(" "); */
}
printf("[ COMMON_OPTIONS ]\n");
+ printf(".ad b\n");
printf(".RE\n");
- printf(".br\n");
}
op_count:
printf(".RE\n");
out:
+ printf(".P\n");
if (!lv_type_bits)
return;
- printf(".br\n");
- printf("\n");
printf(".RS 4\n");
if (lv_type_bits) {
printf("\n");
}
printf(".RE\n");
- printf(".br\n");
+ printf(".P\n");
}
/*
sep = 0;
printf(".RS 4\n");
+ printf(".ad l\n");
/* print those with short opts */
for (i = 0; i < ARG_COUNT; i++) {
if (sep)
printf(".br\n");
- printf(".ad l\n");
for (oo = 0; oo < cmd->oo_count; oo++) {
if (cmd->optional_opt_args[oo].opt != opt_enum)
_print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1, NULL);
}
printf_hyphen(']');
- printf(".ad b\n");
sep = 1;
break;
}
if (sep)
printf(".br\n");
- printf(".ad l\n");
for (oo = 0; oo < cmd->oo_count; oo++) {
if (cmd->optional_opt_args[oo].opt != opt_enum)
_print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1, NULL);
}
printf_hyphen(']');
- printf(".ad b\n");
sep = 1;
break;
}
}
+ printf(".ad b\n");
printf(".RE\n");
- return;
}
static void _print_man_usage_common_cmd(struct command *cmd)
sep = 0;
printf(".RS 4\n");
+ printf(".ad l\n");
/* print those with short opts */
for (i = 0; i < ARG_COUNT; i++) {
if (sep)
printf(".br\n");
- printf(".ad l\n");
for (oo = 0; oo < cmd->oo_count; oo++) {
if (cmd->optional_opt_args[oo].opt != opt_enum)
_print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1, NULL);
}
printf_hyphen(']');
- printf(".ad b\n");
sep = 1;
break;
}
-
}
/* print those without short opts */
if (sep)
printf(".br\n");
- printf(".ad l\n");
for (oo = 0; oo < cmd->oo_count; oo++) {
if (cmd->optional_opt_args[oo].opt != opt_enum)
_print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1, NULL);
}
printf_hyphen(']');
- printf(".ad b\n");
sep = 1;
break;
}
}
+ printf(".ad b\n");
printf(".RE\n");
- printf("\n");
- return;
+ printf(".P\n");
}
/*
int opt_enum, val_enum;
int sep = 0;
int i;
+ int adl = 0;
for (i = 0; i < ARG_COUNT; i++) {
opt_enum = opt_names_alpha[i]->opt_enum;
if (sep)
printf(".br\n");
- printf(".ad l\n");
+
+ if (!adl) {
+ printf(".ad l\n");
+ adl = 1;
+ }
if (opt_names[opt_enum].short_opt) {
printf(" \\fB-%c\\fP|\\fB%s\\fP",
_print_val_man(cname, opt_enum, val_enum);
}
- printf("\n.ad b\n");
-
+ printf("\n");
sep = 1;
}
+
+ if (adl)
+ printf(".ad b\n");
+
}
/*
{
int opt_enum, val_enum;
int i;
+ int adl;
for (i = 0; i < ARG_COUNT; i++) {
opt_enum = opt_names_alpha[i]->opt_enum;
if (!cname->all_options[opt_enum])
continue;
- printf(".HP\n");
+ val_enum = opt_names[opt_enum].val_enum;
- printf(".ad l\n");
+ if (val_names[val_enum].usage &&
+ (strlen(val_names[val_enum].usage) > _LONG_LINE)) {
+ printf(".\n.HP\n");
+ printf(".ad l\n");
+ adl = 1;
+ } else {
+ /* printf(".\n.TP\n");
+ * ATM HTML rendering can't handle HP and TP mixing properly
+ * so still keeping .HP usage for this case
+ * untill some better workaround is found
+ * .TP does not need .br */
+ printf(".\n.HP\n");
+ adl = 0;
+ }
if (opt_names[opt_enum].short_opt) {
printf("\\fB-%c\\fP|\\fB%s\\fP",
printf("\\fB%s\\fP", _man_long_opt_name(cname->name, opt_enum));
}
- val_enum = opt_names[opt_enum].val_enum;
if (!val_names[val_enum].fn) {
/* takes no arg */
if (opt_names[opt_enum].flags & ARG_COUNTABLE)
printf(" ...");
- if (opt_names[opt_enum].desc) {
- printf("\n");
- printf(".br\n");
+ printf("\n");
+ if (adl) {
printf(".ad b\n");
+ }
+ printf(".br\n");
+
+ if (opt_names[opt_enum].desc) {
_print_man_option_desc(cname, opt_enum);
- } else
- printf(".ad b\n");
+ }
}
}
}
if (has_vg_val) {
- printf(".HP\n");
+ printf(".TP\n");
- printf("\\fI%s\\fP", val_names[vg_VAL].name);
- printf("\n");
- printf(".br\n");
+ printf(".I %s\n", val_names[vg_VAL].name);
printf("Volume Group name. See \\fBlvm\\fP(8) for valid names.\n");
if (!strcmp(cname->name, "lvcreate"))
}
if (has_lv_val) {
- printf(".HP\n");
+ printf(".TP\n");
- printf("\\fI%s\\fP", val_names[lv_VAL].name);
- printf("\n");
- printf(".br\n");
+ printf(".I %s\n", val_names[lv_VAL].name);
printf("Logical Volume name. See \\fBlvm\\fP(8) for valid names.\n"
"An LV positional arg generally includes the VG name and LV name, e.g. VG/LV.\n");
}
if (has_pv_val) {
- printf(".HP\n");
+ printf(".TP\n");
- printf("\\fI%s\\fP", val_names[pv_VAL].name);
- printf("\n");
- printf(".br\n");
+ printf(".I %s\n", val_names[pv_VAL].name);
printf("Physical Volume name, a device path under /dev.\n"
"For commands managing physical extents, a PV positional arg\n"
"generally accepts a suffix indicating a range (or multiple ranges)\n"
}
if (has_tag_val) {
- printf(".HP\n");
+ printf(".TP\n");
- printf("\\fI%s\\fP", val_names[tag_VAL].name);
- printf("\n");
- printf(".br\n");
+ printf(".I %s\n", val_names[tag_VAL].name);
printf("Tag name. See \\fBlvm\\fP(8) for information about tag names and using tags\n"
"in place of a VG, LV or PV.\n");
}
if (has_select_val) {
- printf(".HP\n");
+ printf(".TP\n");
- printf("\\fI%s\\fP", val_names[select_VAL].name);
- printf("\n");
- printf(".br\n");
+ printf(".I %s\n", val_names[select_VAL].name);
printf("Select indicates that a required positional parameter can\n"
"be omitted if the \\fB--select\\fP option is used.\n"
"No arg appears in this position.\n");
/* Every command uses a string arg somewhere. */
- printf(".HP\n");
- printf("\\fI%s\\fP", val_names[string_VAL].name);
- printf("\n");
- printf(".br\n");
+ printf(".TP\n");
+ printf(".I %s\n", val_names[string_VAL].name);
printf("See the option description for information about the string content.\n");
/*
* so common that we should probably always print it.
*/
- printf(".HP\n");
- printf("\\fISize\\fP[UNIT]");
- printf("\n");
- printf(".br\n");
+ printf(".TP\n");
+ printf(".IR Size [UNIT]\n");
printf("Size is an input number that accepts an optional unit.\n"
"Input units are always treated as base two values, regardless of\n"
"capitalization, e.g. 'k' and 'K' both refer to 1024.\n"
"The default input unit is specified by letter, followed by |UNIT.\n"
- "UNIT represents other possible input units: \\fBbBsSkKmMgGtTpPeE\\fP.\n"
- "b|B is bytes, s|S is sectors of 512 bytes, k|K is KiB,\n"
- "m|M is MiB, g|G is GiB, t|T is TiB, p|P is PiB, e|E is EiB.\n"
+ "UNIT represents other possible input units:\n"
+ ".BR b | B\nis bytes,\n.BR s | S\nis sectors of 512 bytes,\n.BR k | K\nis KiB,\n"
+ ".BR m | M\nis MiB,\n.BR g | G\nis GiB,\n.BR t | T\nis TiB,\n"
+ ".BR p | P\nis PiB,\n.BR e | E\nis EiB.\n"
"(This should not be confused with the output control --units, where\n"
"capital letters mean multiple of 1000.)\n");
- printf(".SH ENVIRONMENT VARIABLES\n");
+ printf(".\n.SH ENVIRONMENT VARIABLES\n.\n");
printf("See \\fBlvm\\fP(8) for information about environment variables used by lvm.\n"
"For example, LVM_VG_NAME can generally be substituted for a required VG parameter.\n");
}
}
buf[sz] = '\0';
- printf(".SH DESCRIPTION\n%s", buf);
+ printf(".\n.SH DESCRIPTION\n.\n%s", buf);
r = 1;
out_free:
_print_man_usage_common_cmd(prev_cmd);
_print_man_usage_common_lvm(prev_cmd);
- printf(".SH OPTIONS\n");
+ printf(".\n.SH OPTIONS\n.\n");
_print_man_all_options_desc(cname);
- printf(".SH VARIABLES\n");
+ printf(".\n.SH VARIABLES\n.\n");
_print_man_all_positions_desc(cname);
prev_cmd = NULL;
continue;
if (!prev_cmd || strcmp(prev_cmd->name, cmd->name)) {
- printf(".SH NAME\n");
+ printf(".\n.SH NAME\n.\n");
if (cname && cname->desc)
printf("%s \\(em %s\n", lvmname, cname->desc);
else
printf("%s\n", lvmname);
- printf(".\n");
- printf(".SH SYNOPSIS\n");
+ printf(".\n.SH SYNOPSIS\n.\n");
prev_cmd = cmd;
if (!(cname = _find_command_name(cmd->name)))
if (des_file && !_include_description_file(lvmname, des_file))
return 0;
- printf(".SH USAGE\n");
+ printf(".\n.SH USAGE\n.\n");
}
if (cmd->desc) {
_print_man_usage_common_cmd(cmd);
_print_man_usage_common_lvm(cmd);
- printf("\n");
- printf(".SH OPTIONS\n");
+ printf(".\n.SH OPTIONS\n.\n");
_print_man_all_options_desc(cname);
- printf(".SH VARIABLES\n");
+ printf(".\n.SH VARIABLES\n.\n");
_print_man_all_positions_desc(cname);
} else {
- if (cname->variants > 2)
+ if (cname->variants > 2) {
printf("\\(em\n");
+ printf(".P\n");
+ }
}
- printf("\n");
continue;
}
continue;
if (!header) {
- printf(".SH ADVANCED USAGE\n");
+ printf(".\n.SH ADVANCED USAGE\n.\n");
printf("Alternate command forms, advanced command usage, and listing of all valid syntax for completeness.\n");
printf(".P\n");
header = 1;