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); ...@@ -68,7 +68,7 @@ void MCF_ParamSync(void);
void MCF_ParamInit(struct cli *); void MCF_ParamInit(struct cli *);
void MCF_ParamSet(struct cli *, const char *param, const char *val); void MCF_ParamSet(struct cli *, const char *param, const char *val);
#ifdef DIAGNOSTICS #ifdef DIAGNOSTICS
void MCF_DumpMdoc(void); void MCF_DumpRst(void);
#endif #endif
/* mgt_shmem.c */ /* mgt_shmem.c */
......
...@@ -1083,26 +1083,25 @@ MCF_ParamInit(struct cli *cli) ...@@ -1083,26 +1083,25 @@ MCF_ParamInit(struct cli *cli)
#ifdef DIAGNOSTICS #ifdef DIAGNOSTICS
void void
MCF_DumpMdoc(void) MCF_DumpRst(void)
{ {
const struct parspec *pp; const struct parspec *pp;
const char *p, *q; const char *p, *q;
int i; int i;
printf(".Bl -tag -width 4n\n");
for (i = 0; i < nparspec; i++) { for (i = 0; i < nparspec; i++) {
pp = parspec[i]; pp = parspec[i];
printf(".It Va %s\n", pp->name); printf("%s\n", pp->name);
if (pp->units != NULL && *pp->units != '\0') if (pp->units != NULL && *pp->units != '\0')
printf("Units:\n.Dv %s\n.br\n", pp->units); printf("\t- Units: %s\n", pp->units);
printf("Default:\n.Dv %s\n.br\n", pp->def); printf("\t- Default: %s\n", pp->def == MAGIC_INIT_STRING ? "magic" : pp->def);
/* /*
* XXX: we should mark the params with one/two flags * XXX: we should mark the params with one/two flags
* XXX: that say if ->min/->max are valid, so we * XXX: that say if ->min/->max are valid, so we
* XXX: can emit those also in help texts. * XXX: can emit those also in help texts.
*/ */
if (pp->flags) { if (pp->flags) {
printf("Flags:\n.Dv \""); printf("\t- Flags: ");
q = ""; q = "";
if (pp->flags & DELAYED_EFFECT) { if (pp->flags & DELAYED_EFFECT) {
printf("%sdelayed", q); printf("%sdelayed", q);
...@@ -1120,23 +1119,26 @@ MCF_DumpMdoc(void) ...@@ -1120,23 +1119,26 @@ MCF_DumpMdoc(void)
printf("%sexperimental", q); printf("%sexperimental", q);
q = ", "; q = ", ";
} }
printf("\"\n.br\n"); printf("\n");
} }
printf(".Pp\n"); printf("\n\t");
for (p = pp->descr; *p; p++) { for (p = pp->descr; *p; p++) {
if (*p == '\n' && p[1] =='\0') if (*p == '\n' && p[1] =='\0')
break; break;
if (*p == '\n' && p[1] =='\n') { if (*p == '\n' && p[1] =='\n') {
printf("\n.Pp\n"); printf("\n\n\t");
p++; p++;
} else if (*p == '\n') { } 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 { } else {
printf("%c", *p); printf("%c", *p);
} }
} }
printf("\n.Pp\n"); printf("\n\n");
} }
printf(".El\n"); printf("\n");
} }
#endif /* DIAGNOSTICS */ #endif /* DIAGNOSTICS */
...@@ -501,8 +501,8 @@ main(int argc, char * const *argv) ...@@ -501,8 +501,8 @@ main(int argc, char * const *argv)
exit(0); exit(0);
case 'x': case 'x':
#ifdef DIAGNOSTICS #ifdef DIAGNOSTICS
if (!strcmp(optarg, "dumpmdoc")) { if (!strcmp(optarg, "dumprst")) {
MCF_DumpMdoc(); MCF_DumpRst();
exit (0); exit (0);
} }
#endif /* DIAGNOSTICS */ #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