1 Return-Path: <bremner@tethera.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 206B0431FAE
\r
6 for <notmuch@notmuchmail.org>; Wed, 5 Mar 2014 06:57:22 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id asdFv7V0EVDO for <notmuch@notmuchmail.org>;
\r
16 Wed, 5 Mar 2014 06:57:18 -0800 (PST)
\r
17 Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])
\r
18 (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 5BCE2431FBF
\r
21 for <notmuch@notmuchmail.org>; Wed, 5 Mar 2014 06:56:54 -0800 (PST)
\r
22 Received: from remotemail by yantan.tethera.net with local (Exim 4.80)
\r
23 (envelope-from <bremner@tethera.net>)
\r
24 id 1WLDFe-0004AX-0m; Wed, 05 Mar 2014 10:56:54 -0400
\r
25 Received: (nullmailer pid 10383 invoked by uid 1000); Wed, 05 Mar 2014
\r
27 From: David Bremner <david@tethera.net>
\r
28 To: notmuch@notmuchmail.org
\r
29 Subject: [PATCH 2/4] doc: add target rst2man to build man pages using rst2man
\r
30 Date: Wed, 5 Mar 2014 10:56:33 -0400
\r
31 Message-Id: <1394031395-8014-3-git-send-email-david@tethera.net>
\r
32 X-Mailer: git-send-email 1.8.5.3
\r
33 In-Reply-To: <1394031395-8014-1-git-send-email-david@tethera.net>
\r
34 References: <1394031395-8014-1-git-send-email-david@tethera.net>
\r
35 X-BeenThere: notmuch@notmuchmail.org
\r
36 X-Mailman-Version: 2.1.13
\r
38 List-Id: "Use and development of the notmuch mail system."
\r
39 <notmuch.notmuchmail.org>
\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
41 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
43 List-Post: <mailto:notmuch@notmuchmail.org>
\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
47 X-List-Received-Date: Wed, 05 Mar 2014 14:57:22 -0000
\r
49 Many people have docutils installed, but not sphinx. Allow these
\r
50 people to build the man pages.
\r
52 doc/Makefile.local | 7 ++++++
\r
53 doc/prerst2man.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
54 2 files changed, 69 insertions(+)
\r
55 create mode 100644 doc/prerst2man.py
\r
57 diff --git a/doc/Makefile.local b/doc/Makefile.local
\r
58 index ec23012..4719247 100644
\r
59 --- a/doc/Makefile.local
\r
60 +++ b/doc/Makefile.local
\r
61 @@ -7,10 +7,13 @@ SPHINXOPTS := -q -c $(dir)
\r
62 SPHINXBUILD = sphinx-build
\r
63 DOCBUILDDIR := $(dir)/_build
\r
65 +prerst2man := python $(dir)/prerst2man.py
\r
67 # Internal variables.
\r
68 ALLSPHINXOPTS := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) $(dir)
\r
70 .PHONY: sphinx-html sphinx-man sphinx-texinfo sphinx-info
\r
74 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html
\r
75 @@ -24,4 +27,8 @@ sphinx-texinfo:
\r
76 sphinx-info: sphinx-texinfo
\r
77 make -C $(DOCBUILDDIR)/texinfo info
\r
79 +# fallback target in case sphinx not installed
\r
81 + $(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
\r
83 CLEAN := $(CLEAN) $(DOCBUILDDIR)
\r
84 diff --git a/doc/prerst2man.py b/doc/prerst2man.py
\r
85 new file mode 100644
\r
86 index 0000000..720deb6
\r
88 +++ b/doc/prerst2man.py
\r
90 +from sys import argv
\r
91 +from datetime import date
\r
92 +from os.path import dirname, isdir
\r
93 +from os import makedirs, system
\r
96 +sourcedir = argv[1]
\r
99 +if not isdir(outdir):
\r
100 + makedirs(outdir, 0755)
\r
102 +execfile(sourcedir + "/conf.py")
\r
105 +def header(file, startdocname, command, description, authors, section):
\r
113 +:Manual section: {5:d}
\r
114 +:Manual group: {6:s}
\r
117 +'-' * len(description),
\r
119 +'-' * len(description),
\r
120 +date.today().isoformat(), release, section, project))
\r
122 +blankre = re.compile("^\s*$")
\r
123 +for page in man_pages:
\r
124 + outdirname = outdir + '/' + dirname(page[0])
\r
125 + if not isdir(outdirname):
\r
126 + makedirs(outdirname, 0755)
\r
127 + filename = outdir + '/' + page[0] + '.rst'
\r
128 + outfile = open(filename, 'w')
\r
129 + infile = open(sourcedir + '/' + page[0] + '.rst', 'r')
\r
131 + # this is a crude hack. We look for the first blank line, and
\r
132 + # insert the rst2man header there.
\r
134 + # XXX consider really parsing input
\r
137 + lines = infile.readlines()
\r
138 + for line in lines:
\r
139 + outfile.write(line)
\r
140 + if (blankre.match(line)):
\r
142 + count = count + 1
\r
144 + del lines[0:count + 1]
\r
146 + header(outfile, *page)
\r
148 + outfile.write("".join(lines))
\r
151 + os.system('set -x; rst2man {0} {1}'.format(filename, outdir + '/' + page[0] + '.' + str(page[4])))
\r