[master] c521864 Let the synopsis be generated from the option table files
Martin Blix Grydeland
martin at varnish-cache.org
Thu Jun 13 12:41:24 CEST 2013
commit c521864292f2119632c8b834650144d41c61ff2b
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Wed May 29 11:42:24 2013 +0200
Let the synopsis be generated from the option table files
diff --git a/bin/varnishlog/Makefile.am b/bin/varnishlog/Makefile.am
index 2380fb9..d9971fc 100644
--- a/bin/varnishlog/Makefile.am
+++ b/bin/varnishlog/Makefile.am
@@ -25,18 +25,23 @@ varnishlog_LDADD = \
noinst_PROGRAMS = varnishlog_opt2rst
varnishlog_opt2rst_CFLAGS = -DOPT2RST_INC="varnishlog_options.h"
varnishlog_opt2rst_SOURCES = \
+ varnishlog_options.h \
$(top_builddir)/lib/libvarnishtools/opt2rst.c
-BUILT_SOURCES = varnishlog_options.rst
+BUILT_SOURCES = varnishlog_options.rst varnishlog_synopsis.rst
-EXTRA_DIST = varnishlog_options.rst
+EXTRA_DIST = varnishlog_options.rst varnishlog_synopsis.rst
+MAINTAINERCLEANFILES = $(EXTRA_DIST)
-varnishlog_options.rst: varnishlog_opt2rst
- ./varnishlog_opt2rst > $@
+varnishlog_options.rst: varnishlog_options.h | varnishlog_opt2rst
+ ./varnishlog_opt2rst options > $@
+varnishlog_synopsis.rst: varnishlog_options.h | varnishlog_opt2rst
+ ./varnishlog_opt2rst synopsis > $@
varnishlog.1: \
$(top_srcdir)/doc/sphinx/reference/varnishlog.rst \
- varnishlog_options.rst
+ varnishlog_options.rst \
+ varnishlog_synopsis.rst
if HAVE_RST2MAN
${RST2MAN} $< $@
else
diff --git a/doc/sphinx/reference/varnishlog.rst b/doc/sphinx/reference/varnishlog.rst
index 3e761f8..a41e56d 100644
--- a/doc/sphinx/reference/varnishlog.rst
+++ b/doc/sphinx/reference/varnishlog.rst
@@ -19,9 +19,8 @@ Display Varnish logs
SYNOPSIS
========
-varnishlog [-a] [-b] [-c] [-C] [-d] [-D] [-i tag] [-I [tag:]regex] [-k
-keep] [-n varnish_name] [-P file] [-r file] [--raw] [-s num] [-S] [-u]
-[-v] [-V] [-w file] [-x tag] [-X [tag:]regex] <query expression>
+.. include:: ../../../bin/varnishlog/varnishlog_synopsis.rst
+varnishlog |synopsis| <query expression>
OPTIONS
=======
diff --git a/lib/libvarnishtools/opt2rst.c b/lib/libvarnishtools/opt2rst.c
index ab854ef..3ad60db 100644
--- a/lib/libvarnishtools/opt2rst.c
+++ b/lib/libvarnishtools/opt2rst.c
@@ -27,6 +27,7 @@
* SUCH DAMAGE.
*/
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -75,15 +76,27 @@ print_opt(const struct vopt_full *opt)
printf("\n\n");
}
+static void
+usage(void)
+{
+ fprintf(stderr, "Usage: opt2rst {synopsis|options}\n");
+ exit(1);
+}
+
int
main(int argc, char * const *argv)
{
int i;
- (void)argc;
- (void)argv;
- for (i = 0; i < sizeof vopt_full / sizeof vopt_full[0]; i++)
- print_opt(&vopt_full[i]);
+ if (argc != 2)
+ usage();
+ if (!strcmp(argv[1], "synopsis"))
+ printf(".. |synopsis| replace:: %s\n", vopt_synopsis);
+ else if (!strcmp(argv[1], "options"))
+ for (i = 0; i < sizeof vopt_full / sizeof vopt_full[0]; i++)
+ print_opt(&vopt_full[i]);
+ else
+ usage();
return (0);
}
More information about the varnish-commit
mailing list