[PATCH v2 1/5] doc: Allow rst2man.py as an alternative to rst2man
authorW. Trevor King <wking@tremily.us>
Sat, 10 May 2014 17:03:32 +0000 (10:03 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:02:36 +0000 (10:02 -0800)
d9/2c7f2d8ed98ce9bb36c4c5385d81adbb294326 [new file with mode: 0644]

diff --git a/d9/2c7f2d8ed98ce9bb36c4c5385d81adbb294326 b/d9/2c7f2d8ed98ce9bb36c4c5385d81adbb294326
new file mode 100644 (file)
index 0000000..97da4e1
--- /dev/null
@@ -0,0 +1,178 @@
+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 16E28431FC2\r
+       for <notmuch@notmuchmail.org>; Sat, 10 May 2014 10:10:40 -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 rMU4pZ1g1PV0 for <notmuch@notmuchmail.org>;\r
+       Sat, 10 May 2014 10:10:32 -0700 (PDT)\r
+Received: from qmta08.westchester.pa.mail.comcast.net\r
+       (qmta08.westchester.pa.mail.comcast.net [76.96.62.80])\r
+       by olra.theworths.org (Postfix) with ESMTP id 4EB40431FBF\r
+       for <notmuch@notmuchmail.org>; Sat, 10 May 2014 10:10:32 -0700 (PDT)\r
+Received: from omta16.westchester.pa.mail.comcast.net ([76.96.62.88])\r
+       by qmta08.westchester.pa.mail.comcast.net with comcast\r
+       id 0H3j1o0051uE5Es58HAWug; Sat, 10 May 2014 17:10:30 +0000\r
+Received: from odin.tremily.us ([24.18.63.50])\r
+       by omta16.westchester.pa.mail.comcast.net with comcast\r
+       id 0HAU1o00d152l3L3cHAVGX; Sat, 10 May 2014 17:10:30 +0000\r
+Received: from mjolnir.tremily.us (unknown [192.168.0.140])\r
+       by odin.tremily.us (Postfix) with ESMTPS id 0FA7E11969A4;\r
+       Sat, 10 May 2014 10:04:16 -0700 (PDT)\r
+Received: (nullmailer pid 24529 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 1/5] doc: Allow rst2man.py as an alternative to rst2man\r
+Date: Sat, 10 May 2014 10:03:32 -0700\r
+Message-Id:\r
+ <c8b019cf95243e4b47780a19d0bfca5b65c79ecb.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=1399741830;\r
+       bh=XPKzTxLHxzG8cJUIytCGfqNSFtxO0FOYNOfGC92Jpec=;\r
+       h=Received:Received:Received:Received:From:To:Subject:Date:\r
+       Message-Id;\r
+       b=l7xGVWN71+7OENd8SiKZB+w8i9pdBrzBF8lpCiANrPdZCTX3v1G42YEEmCUZihloB\r
+       pZBnZvXHl095yaM8a5dMVRyzPL8TqZf5gvhgNf8agA6lk853sBoxV6lwR786CbOcQ8\r
+       XEeXzzE5ZfKt2J40T1zVjPSkzffzC7/VcVG5wL1QUunb0/lo1uJFSEkNrUU5Yewnvt\r
+       eVk9cjV4f6ywjrtmcXoZaY8i6B+PwAX2Xs8v5/RSpja4ksQt1KhcHjuCNgLJSy8EYZ\r
+       K/JbareZCMLSnPhZ5e5TZEgMzJq7x3c3Ke9RP+Sl9Qy/4QsbQShVTflXQov1ENmQvk\r
+       F6Q0q+isK0pfg==\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:10:40 -0000\r
+\r
+Gentoo's dev-python/docutils-0.10 installs Docutils scripts with a\r
+*.py extension, so I have /usr/bin/rst2man.py and no rst2man script.\r
+This patch supports users with both types of systems by checking for\r
+rst2man, falling back on rst2man.py, and giving up only if neither is\r
+found.  Users can also set the new RST2MAN path variable explicitly\r
+when they call Make:\r
+\r
+  make RST2MAN=/my/custom/rst_to_man_converter build-man\r
+\r
+I use POSIX's 'command -v' [1] to find the path to rst2man or\r
+rst2man.py, and save that as RST2MAN in Makefile.config.  Then pass\r
+the configured RST2MAN path through to prerst2man.py to use in its\r
+system call.\r
+\r
+We can use a non-empty RST2MAN to check for the availability of an\r
+rst2man program, so there's no need for a separate HAVE_RST2MAN.\r
+However, we keep the existing HAVE_RST2MAN for consistency with\r
+HAVE_SPHINX.\r
+\r
+[1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html\r
+---\r
+ configure          | 15 +++++++++++++--\r
+ doc/Makefile.local |  2 +-\r
+ doc/prerst2man.py  |  9 +++++----\r
+ 3 files changed, 19 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/configure b/configure\r
+index 9bde2eb..f017af8 100755\r
+--- a/configure\r
++++ b/configure\r
+@@ -413,17 +413,24 @@ if hash sphinx-build > /dev/null 2>&1 && python -m sphinx.writers.manpage > /dev\r
+     printf "Yes.\n"\r
+     have_sphinx=1\r
+     have_rst2man=0\r
++    RST2MAN=\r
+ else\r
+     printf "No (falling back to rst2man).\n"\r
+     have_sphinx=0\r
\r
+     printf "Checking if rst2man is available... "\r
+     if rst2man -V > /dev/null 2>&1; then\r
+-       printf "Yes.\n"\r
+        have_rst2man=1\r
++       RST2MAN=$(command -v rst2man)\r
++       printf "Yes (${RST2MAN}).\n"\r
++    elif rst2man.py -V > /dev/null 2>&1; then\r
++       have_rst2man=1\r
++       RST2MAN=$(command -v rst2man.py)\r
++       printf "Yes (${RST2MAN}).\n"\r
+     else\r
+-       printf "No (so will not install man pages).\n"\r
+        have_rst2man=0\r
++       RST2MAN=\r
++       printf "No (so will not install man pages).\n"\r
+     fi\r
+ fi\r
\r
+@@ -820,6 +827,10 @@ HAVE_SPHINX=${have_sphinx}\r
+ # Whether there's a rst2man binary available for building documentation\r
+ HAVE_RST2MAN=${have_rst2man}\r
\r
++# The path to the rst2man program for building documentation.  Set to\r
++# an empty string if no such program is available.\r
++RST2MAN=${RST2MAN}\r
++\r
+ # The directory to which desktop files should be installed\r
+ desktop_dir = \$(prefix)/share/applications\r
\r
+diff --git a/doc/Makefile.local b/doc/Makefile.local\r
+index bbd4610..d96cdd5 100644\r
+--- a/doc/Makefile.local\r
++++ b/doc/Makefile.local\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) $(srcdir)/doc $(DOCBUILDDIR)/man\r
++      $(prerst2man) "$(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
+index 437dea9..81ce817 100644\r
+--- a/doc/prerst2man.py\r
++++ b/doc/prerst2man.py\r
+@@ -4,8 +4,9 @@ from os.path import dirname, isdir\r
+ from os import makedirs, system\r
+ import re\r
\r
+-sourcedir = argv[1]\r
+-outdir = argv[2]\r
++rst2man = argv[1]\r
++sourcedir = argv[2]\r
++outdir = argv[3]\r
\r
+ if not isdir(outdir):\r
+     makedirs(outdir, 0o755)\r
+@@ -59,5 +60,5 @@ for page in man_pages:\r
+     outfile.write("".join(lines))\r
+     outfile.close()\r
\r
+-    system('set -x; rst2man {0} {1}/{2}.{3}'\r
+-           .format(filename, outdir, page[0], page[4]))\r
++    system('set -x; {0} {1} {2}/{3}.{4}'\r
++           .format(rst2man, filename, outdir, page[0], page[4]))\r
+-- \r
+1.9.1.353.gc66d89d\r
+\r