--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 75757429E4F\r
+ for <notmuch@notmuchmail.org>; Tue, 25 Feb 2014 03:53:36 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id dYtCeUw7yyYc for <notmuch@notmuchmail.org>;\r
+ Tue, 25 Feb 2014 03:53:32 -0800 (PST)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
+ (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 33F0B429E45\r
+ for <notmuch@notmuchmail.org>; Tue, 25 Feb 2014 03:53:32 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1WIGZm-0007xV-Cx; Tue, 25 Feb 2014 07:53:30 -0400\r
+Received: (nullmailer pid 17602 invoked by uid 1000); Tue, 25 Feb 2014\r
+ 11:53:23 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC PATCH v4 2/3] doc: add target rst2man to build man pages using\r
+ rst2man\r
+Date: Tue, 25 Feb 2014 07:53:00 -0400\r
+Message-Id: <1393329181-17404-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.8.5.3\r
+In-Reply-To: <1393329181-17404-1-git-send-email-david@tethera.net>\r
+References: <1393329181-17404-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 25 Feb 2014 11:53:36 -0000\r
+\r
+Many people have docutils installed, but not sphinx. Allow these\r
+people to build the man pages.\r
+---\r
+ Makefile | 2 +-\r
+ doc/conf.py | 2 +-\r
+ doc/rst2man/Makefile | 5 +++++\r
+ doc/rst2man/Makefile.local | 37 ++++++++++++++++++++++++++++++++\r
+ doc/rst2man/prerst2man.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++\r
+ 5 files changed, 97 insertions(+), 2 deletions(-)\r
+ create mode 100644 doc/rst2man/Makefile\r
+ create mode 100644 doc/rst2man/Makefile.local\r
+ create mode 100644 doc/rst2man/prerst2man.py\r
+\r
+diff --git a/Makefile b/Makefile\r
+index 39f0e62..3c7f0be 100644\r
+--- a/Makefile\r
++++ b/Makefile\r
+@@ -5,7 +5,7 @@ all:\r
+ # List all subdirectories here. Each contains its own Makefile.local.\r
+ # Use of '=', without '+=', seems to be required for out-of-tree\r
+ # builds to work.\r
+-subdirs = compat completion doc emacs lib man parse-time-string performance-test util test\r
++subdirs = compat completion doc doc/rst2man emacs lib man parse-time-string performance-test util test\r
+ \r
+ # We make all targets depend on the Makefiles themselves.\r
+ global_deps = Makefile Makefile.config Makefile.local \\r
+diff --git a/doc/conf.py b/doc/conf.py\r
+index d80b2af..9180d86 100644\r
+--- a/doc/conf.py\r
++++ b/doc/conf.py\r
+@@ -21,7 +21,7 @@ release = '0.17'\r
+ \r
+ # List of patterns, relative to source directory, that match files and\r
+ # directories to ignore when looking for source files.\r
+-exclude_patterns = ['_build']\r
++exclude_patterns = ['_build','rst2man']\r
+ \r
+ # The name of the Pygments (syntax highlighting) style to use.\r
+ pygments_style = 'sphinx'\r
+diff --git a/doc/rst2man/Makefile b/doc/rst2man/Makefile\r
+new file mode 100644\r
+index 0000000..0a0815d\r
+--- /dev/null\r
++++ b/doc/rst2man/Makefile\r
+@@ -0,0 +1,5 @@\r
++all:\r
++ $(MAKE) -C ../.. all\r
++\r
++.DEFAULT:\r
++ $(MAKE) -C ../.. $@\r
+diff --git a/doc/rst2man/Makefile.local b/doc/rst2man/Makefile.local\r
+new file mode 100644\r
+index 0000000..bc821fe\r
+--- /dev/null\r
++++ b/doc/rst2man/Makefile.local\r
+@@ -0,0 +1,37 @@\r
++# -*- Makefile -*-\r
++dir := doc/rst2man\r
++\r
++prerst2man := python $(dir)/prerst2man.py $(dir)/.. $(dir)\r
++\r
++%.1 :%.rst\r
++ rst2man $< > $@\r
++\r
++%.5 :%.rst\r
++ rst2man $< > $@\r
++\r
++%.7: %.rst\r
++ rst2man $< > $@\r
++\r
++# actual source files\r
++RST1SRC := $(wildcard doc/man1/*.rst)\r
++RST5SRC := $(wildcard doc/man5/*.rst)\r
++RST7SRC := $(wildcard doc/man7/*.rst)\r
++\r
++RST2MAN1SRC := $(patsubst doc/man1/%,doc/rst2man/man1/%,$(RST1SRC))\r
++RST2MAN5SRC := $(patsubst doc/man5/%,doc/rst2man/man5/%,$(RST5SRC))\r
++RST2MAN7SRC := $(patsubst doc/man7/%,doc/rst2man/man7/%,$(RST7SRC))\r
++\r
++RST2MANSRC := ${RST2MAN1SRC} ${RST2MAN5SRC} ${RST2MAN7SRC}\r
++\r
++MAN1SRC := $(patsubst $(dir)/man1/%.rst,$(dir)/man1/%.1,${RST2MAN1SRC})\r
++MAN5SRC := $(patsubst $(dir)/man5/%.rst,$(dir)/man5/%.5,${RST2MAN5SRC})\r
++MAN7SRC := $(patsubst $(dir)/man7/%.rst,$(dir)/man7/%.7,${RST2MAN7SRC})\r
++MANSRC := ${MAN1SRC} ${MAN5SRC} ${MAN7SRC}\r
++\r
++rst2man: ${MANSRC}\r
++\r
++${RST2MANSRC}: ${RSTSRC}\r
++ mkdir -p doc/rst2man/man1 doc/rst2man/man5 doc/rst2man/man7\r
++ $(prerst2man)\r
++\r
++CLEAN := ${CLEAN} ${RST2MANSRC} ${MANSRC}\r
+diff --git a/doc/rst2man/prerst2man.py b/doc/rst2man/prerst2man.py\r
+new file mode 100644\r
+index 0000000..797dd20\r
+--- /dev/null\r
++++ b/doc/rst2man/prerst2man.py\r
+@@ -0,0 +1,53 @@\r
++from sys import argv\r
++from datetime import date\r
++import re\r
++\r
++sourcedir=argv[1]\r
++outdir=argv[2]\r
++\r
++execfile(sourcedir+"/conf.py");\r
++\r
++\r
++\r
++\r
++def header(file,startdocname, command, description, authors, section):\r
++ file.write("""\r
++{:s}\r
++{:s}\r
++{:s}\r
++\r
++:Date: {:s}\r
++:Version: {:s}\r
++:Manual section: {:d}\r
++:Manual group: {:s}\r
++\r
++""".format(\r
++'-' * len(description),\r
++description,\r
++'-' * len(description),\r
++date.today().isoformat(),release,section,project))\r
++\r
++blankre = re.compile("^\s*$")\r
++for page in man_pages:\r
++ outfile = open(outdir+"/"+page[0]+'.rst','w')\r
++ infile = open(sourcedir+"/"+page[0]+".rst",'r')\r
++\r
++\r
++ # this is a crude hack. We look for the first blank line, and\r
++ # insert the rst2man header there.\r
++ #\r
++ # XXX consider really parsing input\r
++\r
++ count=0\r
++ lines = infile.readlines()\r
++ for line in lines:\r
++ outfile.write(line);\r
++ if (blankre.match(line)):\r
++ break\r
++ count = count + 1\r
++\r
++ del lines[0:count+1]\r
++\r
++ header(outfile,*page)\r
++\r
++ outfile.write("".join(lines))\r
+-- \r
+1.8.5.3\r
+\r