--- /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 463CE431FC3\r
+ for <notmuch@notmuchmail.org>; Tue, 28 Jan 2014 08:13:11 -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 sb75CNUeLKah for <notmuch@notmuchmail.org>;\r
+ Tue, 28 Jan 2014 08:13:09 -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 B0B9E431FC0\r
+ for <notmuch@notmuchmail.org>; Tue, 28 Jan 2014 08:13:07 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1W8BHf-00036J-8U; Tue, 28 Jan 2014 12:13:07 -0400\r
+Received: (nullmailer pid 15969 invoked by uid 1000); Tue, 28 Jan 2014\r
+ 16:13:03 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC Patch v2 2/2] doc: add target rst2man to build man pages using\r
+ rst2man\r
+Date: Tue, 28 Jan 2014 12:12:38 -0400\r
+Message-Id: <1390925558-15873-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.8.5.2\r
+In-Reply-To: <1390925558-15873-1-git-send-email-david@tethera.net>\r
+References: <87vbxfkdex.fsf@zancas.localnet>\r
+ <1390925558-15873-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, 28 Jan 2014 16:13:11 -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/rst2man/Makefile | 5 +++++\r
+ doc/rst2man/Makefile.local | 28 ++++++++++++++++++++++++++++\r
+ doc/rst2man/prerst2man.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++\r
+ 4 files changed, 80 insertions(+), 1 deletion(-)\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/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..5bb3e43\r
+--- /dev/null\r
++++ b/doc/rst2man/Makefile.local\r
+@@ -0,0 +1,28 @@\r
++# -*- Makefile -*-\r
++dir := doc/rst2man\r
++\r
++prerst2man := python $(dir)/prerst2man.py $(dir)/.. $(dir)\r
++\r
++MANSRC := $(dir)/notmuch.1 $(dir)/notmuch-search.1 $(dir)/notmuch-search-terms.7\r
++\r
++%.1 : %.rst\r
++ rst2man $< > $@\r
++\r
++%.7: %.rst\r
++ rst2man $< > $@\r
++\r
++# preprocessed source files suitable for rst2man\r
++RST2MANSRC := $(dir)/notmuch.rst $(dir)/notmuch-search.rst $(dir)/notmuch-search-terms.rst\r
++\r
++# actual source files\r
++\r
++RSTSRC := $(patsubst ${dir}/%,$(dir)/../%,${RST2MANSRC})\r
++\r
++RSTMANSRC := $(patsubst %.rst,%.1,${RST2MANSRC})\r
++\r
++rst2man: ${MANSRC}\r
++\r
++${RST2MANSRC}: ${RSTSRC}\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..4222f11\r
+--- /dev/null\r
++++ b/doc/rst2man/prerst2man.py\r
+@@ -0,0 +1,46 @@\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
++def header(file,startdocname, command, description, authors, section):\r
++ file.write("""\r
++---------------------------------------------\r
++{:s}\r
++---------------------------------------------\r
++\r
++:Date: {:s}\r
++:Version: {:s}\r
++:Manual section: {:d}\r
++:Manual group: {:s}\r
++\r
++""".format(description,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.2\r
+\r