--- /dev/null
+Return-Path: <wking@tremily.us>\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 E7935431FBF\r
+ for <notmuch@notmuchmail.org>; Sat, 10 May 2014 10:04:31 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\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\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001]\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 CSeZ4DHy4zwm for <notmuch@notmuchmail.org>;\r
+ Sat, 10 May 2014 10:04:26 -0700 (PDT)\r
+Received: from qmta05.westchester.pa.mail.comcast.net\r
+ (qmta05.westchester.pa.mail.comcast.net [76.96.62.48])\r
+ by olra.theworths.org (Postfix) with ESMTP id 3DAEB431FC3\r
+ for <notmuch@notmuchmail.org>; Sat, 10 May 2014 10:04:20 -0700 (PDT)\r
+Received: from omta24.westchester.pa.mail.comcast.net ([76.96.62.76])\r
+ by qmta05.westchester.pa.mail.comcast.net with comcast\r
+ id 0Git1o0041ei1Bg55H4Jkl; Sat, 10 May 2014 17:04:18 +0000\r
+Received: from odin.tremily.us ([24.18.63.50])\r
+ by omta24.westchester.pa.mail.comcast.net with comcast\r
+ id 0H4H1o00W152l3L3kH4JMG; Sat, 10 May 2014 17:04:18 +0000\r
+Received: from mjolnir.tremily.us (unknown [192.168.0.140])\r
+ by odin.tremily.us (Postfix) with ESMTPS id 39D3511969A9;\r
+ Sat, 10 May 2014 10:04:17 -0700 (PDT)\r
+Received: (nullmailer pid 24533 invoked by uid 1000);\r
+ Sat, 10 May 2014 17:03:44 -0000\r
+From: "W. Trevor King" <wking@tremily.us>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 3/5] doc/prerst2x.py: Adjust to handle any output format,\r
+ not just man pages\r
+Date: Sat, 10 May 2014 10:03:34 -0700\r
+Message-Id:\r
+ <acb1c6dc1128eaefe0a8def82da7800727716139.1399740604.git.wking@tremily.us>\r
+X-Mailer: git-send-email 1.9.1.353.gc66d89d\r
+In-Reply-To: <cover.1399740604.git.wking@tremily.us>\r
+References: <cover.1399740604.git.wking@tremily.us>\r
+In-Reply-To: <cover.1399740604.git.wking@tremily.us>\r
+References: <cover.1399740604.git.wking@tremily.us>\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;\r
+ s=q20140121; t=1399741458;\r
+ bh=i0e9QngBX2US8UgqLpR6RGdcPlw3GAWa9kqKAw1c+h8=;\r
+ h=Received:Received:Received:Received:From:To:Subject:Date:\r
+ Message-Id;\r
+ b=LzW7NSErwCxCU+TVENMIDHpK1wY5kk1C6kcbGPCOHJgvOfMVWv5PdWzaOzYW0nh7n\r
+ KrphLmgHwgmAwdmSM1lPWDHGUorb4KANOmlICG9U+xvC2y/P97M4QUC+yMP8LuWNX0\r
+ gR6WBWWb8vq8si/q36l+lKzdx+XqDg8prJzQWtkNY2nZ0C6gCB4yoo+K962o+TLxfV\r
+ sllmP3Fgwiw5VL2RwckTcKsiWulMDqyR7cSeuNf/H48Al5oyiWqNcV9H+y6DZ1IL2j\r
+ vDLCSvGMWaXZNIXZ1TmpojchecLf1hHwIbhZWVznx5XEcDyMEzyqrXTr0aoMbvsufj\r
+ XJiexHeauRLLQ==\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>\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: Sat, 10 May 2014 17:04:32 -0000\r
+\r
+For example, with these changes we can build HTML output using:\r
+\r
+ $ prerst2x.py rst2html ${SRCDIR} ${OUTDIR} html\r
+\r
+The extension adjustment ensures that the output filenames from the\r
+above command match what we currently generate with sphinx-html.\r
+---\r
+ doc/Makefile.local | 4 +--\r
+ doc/prerst2man.py | 66 -----------------------------------------------\r
+ doc/prerst2x.py | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 3 files changed, 77 insertions(+), 68 deletions(-)\r
+ delete mode 100644 doc/prerst2man.py\r
+ create mode 100644 doc/prerst2x.py\r
+\r
+diff --git a/doc/Makefile.local b/doc/Makefile.local\r
+index d96cdd5..5fb526b 100644\r
+--- a/doc/Makefile.local\r
++++ b/doc/Makefile.local\r
+@@ -7,7 +7,7 @@ SPHINXOPTS := -q\r
+ SPHINXBUILD = sphinx-build\r
+ DOCBUILDDIR := $(dir)/_build\r
+ \r
+-prerst2man := python $(srcdir)/$(dir)/prerst2man.py\r
++prerst2x := python $(srcdir)/$(dir)/prerst2x.py\r
+ mkdocdeps := python $(srcdir)/$(dir)/mkdocdeps.py\r
+ \r
+ # Internal variables.\r
+@@ -49,7 +49,7 @@ ifeq ($(HAVE_SPHINX),1)\r
+ mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \\r
+ done\r
+ else ifeq ($(HAVE_RST2MAN),1)\r
+- $(prerst2man) "$(RST2MAN)" $(srcdir)/doc $(DOCBUILDDIR)/man\r
++ $(prerst2x) "$(RST2MAN)" $(srcdir)/doc $(DOCBUILDDIR)/man\r
+ else\r
+ @echo "Fatal: build dependency fail."\r
+ @false\r
+diff --git a/doc/prerst2man.py b/doc/prerst2man.py\r
+deleted file mode 100644\r
+index 7d78e9b..0000000\r
+--- a/doc/prerst2man.py\r
++++ /dev/null\r
+@@ -1,66 +0,0 @@\r
+-import sys\r
+-from datetime import date\r
+-from os.path import dirname, isdir\r
+-from os import makedirs, system\r
+-import re\r
+-\r
+-rst2man = sys.argv[1]\r
+-sourcedir = sys.argv[2]\r
+-outdir = sys.argv[3]\r
+-\r
+-sys.path.insert(0, sourcedir)\r
+-import conf\r
+-\r
+-\r
+-if not isdir(outdir):\r
+- makedirs(outdir, 0o755)\r
+-\r
+-\r
+-def header(file, startdocname, command, description, authors, section):\r
+- file.write("""\r
+-{0:s}\r
+-{1:s}\r
+-{2:s}\r
+-\r
+-:Date: {3:s}\r
+-:Version: {4:s}\r
+-:Manual section: {5:d}\r
+-:Manual group: {6:s}\r
+-\r
+-""".format(\r
+-'-' * len(description),\r
+-description,\r
+-'-' * len(description),\r
+-date.today().isoformat(), conf.release, section, conf.project))\r
+-\r
+-blankre = re.compile("^\s*$")\r
+-for page in conf.man_pages:\r
+- outdirname = outdir + '/' + dirname(page[0])\r
+- if not isdir(outdirname):\r
+- makedirs(outdirname, 0o755)\r
+- filename = outdir + '/' + page[0] + '.rst'\r
+- outfile = open(filename, 'w')\r
+- infile = open(sourcedir + '/' + page[0] + '.rst', '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
+- outfile.close()\r
+-\r
+- system('set -x; {0} {1} {2}/{3}.{4}'\r
+- .format(rst2man, filename, outdir, page[0], page[4]))\r
+diff --git a/doc/prerst2x.py b/doc/prerst2x.py\r
+new file mode 100644\r
+index 0000000..4f9213f\r
+--- /dev/null\r
++++ b/doc/prerst2x.py\r
+@@ -0,0 +1,75 @@\r
++import sys\r
++from datetime import date\r
++from os.path import dirname, isdir\r
++from os import makedirs, system\r
++import re\r
++\r
++rst2x = sys.argv[1]\r
++sourcedir = sys.argv[2]\r
++outdir = sys.argv[3]\r
++try:\r
++ extension = sys.argv[4]\r
++except IndexError:\r
++ extension = ''\r
++\r
++sys.path.insert(0, sourcedir)\r
++import conf\r
++\r
++\r
++if not isdir(outdir):\r
++ makedirs(outdir, 0o755)\r
++\r
++\r
++def header(file, startdocname, command, description, authors, section):\r
++ file.write("""\r
++{0:s}\r
++{1:s}\r
++{2:s}\r
++\r
++:Date: {3:s}\r
++:Version: {4:s}\r
++:Manual section: {5:d}\r
++:Manual group: {6:s}\r
++\r
++""".format(\r
++'-' * len(description),\r
++description,\r
++'-' * len(description),\r
++date.today().isoformat(), conf.release, section, conf.project))\r
++\r
++blankre = re.compile("^\s*$")\r
++for page in conf.man_pages:\r
++ outdirname = outdir + '/' + dirname(page[0])\r
++ if not isdir(outdirname):\r
++ makedirs(outdirname, 0o755)\r
++ filename = outdir + '/' + page[0] + '.rst'\r
++ outfile = open(filename, 'w')\r
++ infile = open(sourcedir + '/' + page[0] + '.rst', 'r')\r
++\r
++ # this is a crude hack. We look for the first blank line, and\r
++ # insert the rst2x 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
++ outfile.close()\r
++\r
++ if extension:\r
++ ext = extension\r
++ else:\r
++ ext = page[4] # man page section\r
++\r
++ system('set -x; {0} {1} {2}/{3}.{4}'\r
++ .format(rst2x, filename, outdir, page[0], ext))\r
+-- \r
+1.9.1.353.gc66d89d\r
+\r