From 7ab55cddee5c5f7d7f365227ab44ade7c2eb64fe Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 3 Jan 2015 16:49:27 +0100 Subject: [PATCH] [PATCH] doc: Allow rst2man.py as an alternative to rst2man --- f8/1b4a8569a2beb4372ea8aa2216beacebdfa504 | 169 ++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 f8/1b4a8569a2beb4372ea8aa2216beacebdfa504 diff --git a/f8/1b4a8569a2beb4372ea8aa2216beacebdfa504 b/f8/1b4a8569a2beb4372ea8aa2216beacebdfa504 new file mode 100644 index 000000000..01946cab9 --- /dev/null +++ b/f8/1b4a8569a2beb4372ea8aa2216beacebdfa504 @@ -0,0 +1,169 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 6C485431FBC + for ; Sat, 3 Jan 2015 07:49:43 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id TD83hV5NKkEp for ; + Sat, 3 Jan 2015 07:49:40 -0800 (PST) +Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id B9A6B431FB6 + for ; Sat, 3 Jan 2015 07:49:40 -0800 (PST) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1Y7QxQ-0007cd-0e; Sat, 03 Jan 2015 11:49:40 -0400 +Received: (nullmailer pid 5255 invoked by uid 1000); Sat, 03 Jan 2015 + 15:49:34 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [PATCH] doc: Allow rst2man.py as an alternative to rst2man +Date: Sat, 3 Jan 2015 16:49:27 +0100 +Message-Id: <1420300167-5060-1-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.3 +In-Reply-To: <1420294479-27224-1-git-send-email-tomi.ollila@iki.fi> +References: <1420294479-27224-1-git-send-email-tomi.ollila@iki.fi> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 03 Jan 2015 15:49:43 -0000 + +From: "W. Trevor King" + +Gentoo's dev-python/docutils-0.10 installs Docutils scripts with a +*.py extension, so I have /usr/bin/rst2man.py and no rst2man script. +This patch supports users with both types of systems by checking for +rst2man, falling back on rst2man.py, and giving up only if neither is +found. Users can also set the new RST2MAN path variable explicitly +when they call Make: + + make RST2MAN=/my/custom/rst_to_man_converter build-man + +We pass the configured RST2MAN path through to prerst2man.py to use in +its system call. + +We can use a non-empty RST2MAN to check for the availability of an +rst2man program, so there's no need for a separate HAVE_RST2MAN. +However, we keep the existing HAVE_RST2MAN for consistency with +HAVE_SPHINX. +--- + +At the risk of bike-shedding, rewrite the configure check to be more +"obvious". This is pretty subjective, but in particular I'm not a big +fan of resetting RST2MAN at the bottom of every iteration of the for +loop. Also conform a bit more to the convention of using a lower case variable in configure and assigning it in Makefile. + +For some reason it bugs me a bit to pass RST2MAN as an extra command line argument, but I guess taking some arguments by command line and some by environment variables would also be icky. + +configure | 23 ++++++++++++++++------- + doc/Makefile.local | 2 +- + doc/prerst2man.py | 9 +++++---- + 3 files changed, 22 insertions(+), 12 deletions(-) + +diff --git a/configure b/configure +index 137acea..fdf5bad 100755 +--- a/configure ++++ b/configure +@@ -444,21 +444,27 @@ else + fi + + printf "Checking if sphinx is available and supports nroff output... " ++have_sphinx=0 ++have_rst2man=0 ++ + if hash sphinx-build > /dev/null 2>&1 && ${python} -m sphinx.writers.manpage > /dev/null 2>&1 ; then + printf "Yes.\n" + have_sphinx=1 +- have_rst2man=0 + else + printf "No (falling back to rst2man).\n" +- have_sphinx=0 + ++ rst2man= + printf "Checking if rst2man is available... " +- if rst2man -V > /dev/null 2>&1; then +- printf "Yes.\n" +- have_rst2man=1 +- else ++ for name in rst2man rst2man.py; do ++ if "${name}" -V > /dev/null 2>&1; then ++ printf "Yes (${name}).\n" ++ have_rst2man=1 ++ rst2man=$name ++ break ++ fi ++ done ++ if [ $have_rst2man -eq 0 ]; then + printf "No (so will not install man pages).\n" +- have_rst2man=0 + fi + fi + +@@ -854,6 +860,9 @@ HAVE_RST2MAN=${have_rst2man} + # Whether there's a doxygen binary available for building api documentation + HAVE_DOXYGEN=${have_doxygen} + ++# The path to the rst2man program for building documentation. ++RST2MAN = ${rst2man} ++ + # The directory to which desktop files should be installed + desktop_dir = \$(prefix)/share/applications + +diff --git a/doc/Makefile.local b/doc/Makefile.local +index e7d0bac..a13cb37 100644 +--- a/doc/Makefile.local ++++ b/doc/Makefile.local +@@ -51,7 +51,7 @@ ifeq ($(HAVE_SPHINX),1) + mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \ + done + else ifeq ($(HAVE_RST2MAN),1) +- $(prerst2man) $(srcdir)/doc $(DOCBUILDDIR)/man ++ $(prerst2man) "$(RST2MAN)" $(srcdir)/doc $(DOCBUILDDIR)/man + else + @echo "Fatal: build dependency fail." + @false +diff --git a/doc/prerst2man.py b/doc/prerst2man.py +index 968722a..2e87976 100644 +--- a/doc/prerst2man.py ++++ b/doc/prerst2man.py +@@ -4,8 +4,9 @@ from os.path import dirname, isdir + from os import makedirs, system + import re + +-sourcedir = argv[1] +-outdir = argv[2] ++rst2man = argv[1] ++sourcedir = argv[2] ++outdir = argv[3] + + if not isdir(outdir): + makedirs(outdir, 0o755) +@@ -60,5 +61,5 @@ for page in man_pages: + outfile.write("".join(lines)) + outfile.close() + +- system('set -x; rst2man {0} {1}/{2}.{3}' +- .format(filename, outdir, page[0], page[4])) ++ system('set -x; {0} {1} {2}/{3}.{4}' ++ .format(rst2man, filename, outdir, page[0], page[4])) +-- +2.1.3 + -- 2.26.2