<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] Generate menu binding documentation from functions.h



# HG changeset patch
# User Christoph Berg <cb@xxxxxxxx>
# Date 1174485130 -3600
# Node ID 50e1b17e9ef63a90762c5c2f1d45d5c79681d2b2
# Parent  b0172175cc892f982aacc5f930ab58da418dcf6b
Pipe functions.h through cpp -C for the manual generation; factor out
makedoc-defs.h from init.h for use in functions.h.

diff -r b0172175cc89 -r 50e1b17e9ef6 Makefile.am
--- a/Makefile.am       Tue Mar 20 13:39:29 2007 -0700
+++ b/Makefile.am       Wed Mar 21 14:52:10 2007 +0100
@@ -75,7 +75,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
        rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
        _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
        mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head 
Muttrc \
-       makedoc.c stamp-doc-rc README.SSL smime.h\
+       makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
        muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
        ChangeLog ChangeLog.old mkchangelog.sh cvslog2changelog.pl mutt_idna.h \
        snprintf.c regex.c crypt-gpgme.h
@@ -199,7 +199,7 @@ update-doc: stamp-doc-rc
 
 Muttrc: stamp-doc-rc
 
-stamp-doc-rc: $(srcdir)/init.h makedoc Muttrc.head
+stamp-doc-rc: $(srcdir)/init.h $(srcdir)/makedoc-defs.h makedoc Muttrc.head
        -rm -f Muttrc stamp-doc-rc
        sed -e 's,[@]docdir[@],$(docdir),' $(srcdir)/Muttrc.head > Muttrc
        $(CPP) $(AM_CPPFLAGS) $(DEFS) $(CPPFLAGS) -D_MAKEDOC -C \
diff -r b0172175cc89 -r 50e1b17e9ef6 doc/Makefile.am
--- a/doc/Makefile.am   Tue Mar 20 13:39:29 2007 -0700
+++ b/doc/Makefile.am   Wed Mar 21 14:52:10 2007 +0100
@@ -130,13 +130,14 @@ mutt.1: $(srcdir)/mutt.man
 mutt.1: $(srcdir)/mutt.man
        $(EDIT) $(srcdir)/mutt.man > $@
 
-stamp-doc-xml: $(top_srcdir)/makedoc.c $(top_srcdir)/init.h manual.xml.head \
-               $(top_srcdir)/functions.h $(top_srcdir)/OPS* manual.xml.tail \
-               $(top_srcdir)/VERSION $(top_srcdir)/ChangeLog
+stamp-doc-xml: $(top_srcdir)/makedoc.c $(top_srcdir)/makedoc-defs.h 
$(top_srcdir)/init.h \
+               manual.xml.head $(top_srcdir)/functions.h $(top_srcdir)/OPS* 
manual.xml.tail \
+               $(srcdir)/gen-map-doc $(top_srcdir)/VERSION 
$(top_srcdir)/ChangeLog
        $(MAKE) ../makedoc$(EXEEXT) # we do not want to rebuild the 
documentation in tarball builds
-       ( date=`head -n 1 $(top_srcdir)/ChangeLog | LC_ALL=C cut -d ' ' -f 1`; \
-         sed -e "s/@VERSION\@/`cat $(top_srcdir)/VERSION` ($$date)/" 
$(srcdir)/manual.xml.head ;\
-         $(MAKEDOC_CPP) $(top_srcdir)/init.h | ../makedoc -s ;\
-         perl $(srcdir)/gen-map-doc $(top_srcdir)/functions.h 
$(top_srcdir)/OPS* < $(srcdir)/manual.xml.tail \
+       ( date=`head -n 1 $(top_srcdir)/ChangeLog | LC_ALL=C cut -d ' ' -f 1` 
&& \
+         sed -e "s/@VERSION\@/`cat $(top_srcdir)/VERSION` ($$date)/" 
$(srcdir)/manual.xml.head && \
+         $(MAKEDOC_CPP) $(top_srcdir)/init.h | ../makedoc -s && \
+         $(MAKEDOC_CPP) $(top_srcdir)/functions.h | \
+           perl $(srcdir)/gen-map-doc $(srcdir)/manual.xml.tail 
$(top_srcdir)/OPS* \
        ) > manual.xml
        touch stamp-doc-xml
diff -r b0172175cc89 -r 50e1b17e9ef6 doc/gen-map-doc
--- a/doc/gen-map-doc   Tue Mar 20 13:39:29 2007 -0700
+++ b/doc/gen-map-doc   Wed Mar 21 14:52:10 2007 +0100
@@ -2,9 +2,9 @@
 
 use strict;
 
-my (%OPS, %MAP, $map);
+my (%OPS, %MAP, %DOC, $map);
 
-my $functions_h = shift @ARGV;
+my $xml = shift @ARGV;
 
 open F, "cat @ARGV |" or die "OPS*: $!";
 while (<F>) {
@@ -13,10 +13,13 @@ while (<F>) {
 }
 close F;
 
-open F, $functions_h or die "$functions_h: $!";
-while (<F>) {
+while (<STDIN>) {
   if (/^struct binding_t Op.*{ \/\* map: (.*) \*\//) {
     $map = $1;
+    $DOC{$map} = "";
+  }
+  if ($map and /^\s*\*\*\s*(.*)/) {
+    $DOC{$map} .= "$1\n";
   }
   if ($map and /{\s*"(.+)"\s*,\s*(\w+)\s*,\s*(?:"([^"]+)"|(\w+))\s*}/) {
     my ($function, $op, $binding) = ($1, $2, $3 || $4);
@@ -40,16 +43,43 @@ while (<F>) {
     undef $map;
   }
 }
-close F;
 
-while (<STDIN>) {
+open XML, $xml or die "$xml: $!";
+while (<XML>) {
   if (/__print_map\((.*)\)/) {
-    die "map $1 undefined" unless $MAP{$1};
-    print $MAP{$1};
+    my $map = $1;
+    unless ($MAP{$map}) {
+      warn "map $map undefined";
+      next;
+    }
+    print <<EOT;
+<sect2 id="${map}_map">
+<title>$map</title>
+$DOC{$map}
+<para>
+
+<table id="${map}_table">
+<title>Default generic function bindings</title>
+<tgroup cols="3">
+<thead>
+<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
+</thead>
+<tbody>
+$MAP{$map}
+</tbody>
+</tgroup>
+</table>
+
+</para>
+
+</sect2>
+
+EOT
     delete $MAP{$1};
   } else {
     print;
   }
 }
+close XML;
 
-die "unprinted maps: ". join(" ", keys %MAP) if %MAP;
+warn "unprinted maps: ". join(" ", keys %MAP) if %MAP;
diff -r b0172175cc89 -r 50e1b17e9ef6 doc/manual.xml.tail
--- a/doc/manual.xml.tail       Tue Mar 20 13:39:29 2007 -0700
+++ b/doc/manual.xml.tail       Wed Mar 21 14:52:10 2007 +0100
@@ -11,285 +11,19 @@ command.
 command.
 </para>
 
-<sect2 id="generic_map">
-<title>generic</title>
-
-<para>
-The <emphasis>generic</emphasis> menu is not a real menu, but specifies common 
functions
-(such as movement) available in all menus except for 
<emphasis>pager</emphasis> and
-<emphasis>editor</emphasis>.  Changing settings for this menu will affect the 
default
-bindings for all menus (except as noted).
-</para>
-
-<para>
-
-<table id="generic_table">
-<title>Default generic function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(generic)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="index_map">
-<title>index</title>
-
-<para>
-
-<table id="index_table">
-<title>Default index menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(index)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="pager_map">
-<title>pager</title>
-
-<para>
-
-<table id="pager_table">
-<title>Default pager menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(pager)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="alias_map">
-<title>alias</title>
-
-<para>
-
-<table id="alias_table">
-<title>Default alias menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(alias)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="query_map">
-<title>query</title>
-
-<para>
-
-<table id="query_table">
-<title>Default query menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(query)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="attach_map">
-<title>attach</title>
-
-<para>
-
-<table id="attach_table">
-<title>Default attach menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(attach)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="compose_map">
-<title>compose</title>
-
-<para>
-
-<table id="compose_table">
-<title>Default compose menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(compose)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="postpone_map">
-<title>postpone</title>
-
-<para>
-
-<table id="postpone_table">
-<title>Default postpone menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(postpone)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="browser_map">
-<title>browser</title>
-
-<para>
-
-<table id="browser_table">
-<title>Default browser menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(browser)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="pgp_map">
-<title>pgp</title>
-
-<para>
-
-<table id="pgp_table">
-<title>Default pgp menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(pgp)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="smime_map">
-<title>smime</title>
-
-<para>
-
-<table id="smime_table">
-<title>Default smime menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(smime)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="mix_map">
-<title>mix</title>
-
-<para>
-
-<table id="mix_table">
-<title>Default mix menu function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(mix)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
-
-<sect2 id="editor_map">
-<title>editor</title>
-
-<para>
-
-<table id="editor_table">
-<title>Default editor function bindings</title>
-<tgroup cols="3">
-<thead>
-<row><entry>Function</entry><entry>Default 
key</entry><entry>Description</entry></row>
-</thead>
-<tbody>
 __print_map(editor)
-</tbody>
-</tgroup>
-</table>
-
-</para>
-
-</sect2>
 
 </sect1>
 
diff -r b0172175cc89 -r 50e1b17e9ef6 functions.h
--- a/functions.h       Tue Mar 20 13:39:29 2007 -0700
+++ b/functions.h       Wed Mar 21 14:52:10 2007 +0100
@@ -28,9 +28,25 @@
  * - If you need to bind a control char, use the octal value because the \cX
  * construct does not work at this level.
  *
+ * - The magic "map:" comments define how the map will be called in the
+ * manual. Lines starting with "**" will be included in the manual.
+ *
  */
 
+#ifdef _MAKEDOC
+# include "config.h"
+# include "makedoc-defs.h"
+#endif
+
 struct binding_t OpGeneric[] = { /* map: generic */
+  /*
+  ** <para>
+  ** The <emphasis>generic</emphasis> menu is not a real menu, but specifies 
common functions
+  ** (such as movement) available in all menus except for 
<emphasis>pager</emphasis> and
+  ** <emphasis>editor</emphasis>.  Changing settings for this menu will affect 
the default
+  ** bindings for all menus (except as noted).
+  ** </para>
+  */
   { "top-page",                OP_TOP_PAGE,            "H" },
   { "next-entry",      OP_NEXT_ENTRY,          "j" },
   { "previous-entry",  OP_PREV_ENTRY,          "k" },
diff -r b0172175cc89 -r 50e1b17e9ef6 init.h
--- a/init.h    Tue Mar 20 13:39:29 2007 -0700
+++ b/init.h    Wed Mar 21 14:52:10 2007 +0100
@@ -19,6 +19,7 @@
 
 #ifdef _MAKEDOC
 # include "config.h"
+# include "makedoc-defs.h"
 #else
 # include "sort.h"
 #endif
@@ -78,59 +79,6 @@ struct option_t
 
 #ifndef ISPELL
 #define ISPELL "ispell"
-#endif
-
-/* build complete documentation */
-
-#ifdef _MAKEDOC
-# ifndef USE_IMAP
-#  define USE_IMAP
-# endif
-# ifndef MIXMASTER
-#  define MIXMASTER "mixmaster"
-# endif
-# ifndef USE_POP
-#  define USE_POP
-# endif
-# ifndef USE_SMTP
-#  define USE_SMTP
-# endif
-# ifndef USE_SSL_OPENSSL
-#  define USE_SSL_OPENSSL
-# endif
-# ifndef USE_SSL_GNUTLS
-#  define USE_SSL_GNUTLS
-# endif
-# ifndef USE_SSL
-#  define USE_SSL
-# endif
-# ifndef USE_SOCKET
-#  define USE_SOCKET
-# endif
-# ifndef USE_DOTLOCK
-#  define USE_DOTLOCK
-# endif
-# ifndef DL_STANDALONE
-#  define DL_STANDALONE
-# endif
-# ifndef USE_HCACHE
-#  define USE_HCACHE
-# endif
-# ifndef HAVE_DB4
-#  define HAVE_DB4
-# endif
-# ifndef HAVE_GDBM
-#  define HAVE_GDBM
-# endif
-# ifndef HAVE_QDBM
-#  define HAVE_QDBM
-# endif
-# ifndef HAVE_LIBIDN
-#  define HAVE_LIBIDN
-# endif
-# ifndef HAVE_GETADDRINFO
-#  define HAVE_GETADDRINFO
-# endif
 #endif
 
 struct option_t MuttVars[] = {
@@ -2030,7 +1978,7 @@ struct option_t MuttVars[] = {
   ** .pp
   ** Example: set certificate_file=~/.mutt/certificates
   */
-# if defined _MAKEDOC || !defined(USE_SSL_GNUTLS)
+# ifdef USE_SSL_OPENSSL
   { "ssl_usesystemcerts", DT_BOOL, R_NONE, OPTSSLSYSTEMCERTS, 1 },
   /*
   ** .pp
@@ -2050,7 +1998,7 @@ struct option_t MuttVars[] = {
   ** This variables specifies whether to attempt to use SSLv2 in the
   ** SSL authentication process.
   */
-# endif /* defined _MAKEDOC || !defined(USE_SSL_GNUTLS) */
+# endif /* defined USE_SSL_OPENSSL */
   { "ssl_use_sslv3", DT_BOOL, R_NONE, OPTSSLV3, 1 },
   /*
   ** .pp
diff -r b0172175cc89 -r 50e1b17e9ef6 makedoc-defs.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/makedoc-defs.h    Wed Mar 21 14:52:10 2007 +0100
@@ -0,0 +1,54 @@
+/* build complete documentation */
+
+# ifndef CRYPT_BACKEND_GPGME
+#  define CRYPT_BACKEND_GPGME
+# endif
+# ifndef USE_IMAP
+#  define USE_IMAP
+# endif
+# ifndef MIXMASTER
+#  define MIXMASTER "mixmaster"
+# endif
+# ifndef USE_POP
+#  define USE_POP
+# endif
+# ifndef USE_SMTP
+#  define USE_SMTP
+# endif
+# ifndef USE_SSL_OPENSSL
+#  define USE_SSL_OPENSSL
+# endif
+# ifndef USE_SSL_GNUTLS
+#  define USE_SSL_GNUTLS
+# endif
+# ifndef USE_SSL
+#  define USE_SSL
+# endif
+# ifndef USE_SOCKET
+#  define USE_SOCKET
+# endif
+# ifndef USE_DOTLOCK
+#  define USE_DOTLOCK
+# endif
+# ifndef DL_STANDALONE
+#  define DL_STANDALONE
+# endif
+# ifndef USE_HCACHE
+#  define USE_HCACHE
+# endif
+# ifndef HAVE_DB4
+#  define HAVE_DB4
+# endif
+# ifndef HAVE_GDBM
+#  define HAVE_GDBM
+# endif
+# ifndef HAVE_QDBM
+#  define HAVE_QDBM
+# endif
+# ifndef HAVE_LIBIDN
+#  define HAVE_LIBIDN
+# endif
+# ifndef HAVE_GETADDRINFO
+#  define HAVE_GETADDRINFO
+# endif
+

Christoph
-- 
cb@xxxxxxxx | http://www.df7cb.de/

Attachment: signature.asc
Description: Digital signature