[master] 85e6bd2 Change output format of parameter dump to rst

Tollef Fog Heen tfheen at varnish-cache.org
Thu Feb 3 13:15:32 CET 2011


commit 85e6bd286516c7f066f20823c36cc46851a2325d
Author: Tollef Fog Heen <tfheen at varnish-software.com>
Date:   Thu Feb 3 10:41:56 2011 +0100

    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.

diff --git a/bin/varnishd/mgt.h b/bin/varnishd/mgt.h
index 2dd07bd..122d384 100644
--- a/bin/varnishd/mgt.h
+++ b/bin/varnishd/mgt.h
@@ -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 */
diff --git a/bin/varnishd/mgt_param.c b/bin/varnishd/mgt_param.c
index 4ba6554..616b627 100644
--- a/bin/varnishd/mgt_param.c
+++ b/bin/varnishd/mgt_param.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 */
diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c
index a6f1769..78765d2 100644
--- a/bin/varnishd/varnishd.c
+++ b/bin/varnishd/varnishd.c
@@ -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 */



More information about the varnish-commit mailing list