Commit 85e6bd28 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Change output format of parameter dump to rst

If varnishd is compiled with -DDIAGNOSTIC and run with -x dumprst
(previously -x dumpmdoc) it will dump the paramer definitions in rst
(previously mdoc) format, suitable for including into the varnishd
reference documentation.
parent 921a3518
......@@ -68,7 +68,7 @@ void MCF_ParamSync(void);
void MCF_ParamInit(struct cli *);
void MCF_ParamSet(struct cli *, const char *param, const char *val);
#ifdef DIAGNOSTICS
void MCF_DumpMdoc(void);
void MCF_DumpRst(void);
#endif
/* mgt_shmem.c */
......
......@@ -1083,26 +1083,25 @@ MCF_ParamInit(struct cli *cli)
#ifdef DIAGNOSTICS
void
MCF_DumpMdoc(void)
MCF_DumpRst(void)
{
const struct parspec *pp;
const char *p, *q;
int i;
printf(".Bl -tag -width 4n\n");
for (i = 0; i < nparspec; i++) {
pp = parspec[i];
printf(".It Va %s\n", pp->name);
printf("%s\n", pp->name);
if (pp->units != NULL && *pp->units != '\0')
printf("Units:\n.Dv %s\n.br\n", pp->units);
printf("Default:\n.Dv %s\n.br\n", pp->def);
printf("\t- Units: %s\n", pp->units);
printf("\t- Default: %s\n", pp->def == MAGIC_INIT_STRING ? "magic" : pp->def);
/*
* XXX: we should mark the params with one/two flags
* XXX: that say if ->min/->max are valid, so we
* XXX: can emit those also in help texts.
*/
if (pp->flags) {
printf("Flags:\n.Dv \"");
printf("\t- Flags: ");
q = "";
if (pp->flags & DELAYED_EFFECT) {
printf("%sdelayed", q);
......@@ -1120,23 +1119,26 @@ MCF_DumpMdoc(void)
printf("%sexperimental", q);
q = ", ";
}
printf("\"\n.br\n");
printf("\n");
}
printf(".Pp\n");
printf("\n\t");
for (p = pp->descr; *p; p++) {
if (*p == '\n' && p[1] =='\0')
break;
if (*p == '\n' && p[1] =='\n') {
printf("\n.Pp\n");
printf("\n\n\t");
p++;
} else if (*p == '\n') {
printf("\n.br\n");
printf("\n\t");
} else if (*p == ':' && p[1] == '\n') {
/* Start of definition list, use RSTs code mode for this */
printf("::\n");
} else {
printf("%c", *p);
}
}
printf("\n.Pp\n");
printf("\n\n");
}
printf(".El\n");
printf("\n");
}
#endif /* DIAGNOSTICS */
......@@ -501,8 +501,8 @@ main(int argc, char * const *argv)
exit(0);
case 'x':
#ifdef DIAGNOSTICS
if (!strcmp(optarg, "dumpmdoc")) {
MCF_DumpMdoc();
if (!strcmp(optarg, "dumprst")) {
MCF_DumpRst();
exit (0);
}
#endif /* DIAGNOSTICS */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment