[PATCH v3 06/10] cli: Introduce "notmuch address" command
[notmuch-archives.git] / 36 / 4d2da9353d769b879d0ba3b4befa56ad16eca6
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 463CE431FC3\r
6         for <notmuch@notmuchmail.org>; Tue, 28 Jan 2014 08:13:11 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\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 sb75CNUeLKah for <notmuch@notmuchmail.org>;\r
16         Tue, 28 Jan 2014 08:13:09 -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 B0B9E431FC0\r
21         for <notmuch@notmuchmail.org>; Tue, 28 Jan 2014 08:13:07 -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 1W8BHf-00036J-8U; Tue, 28 Jan 2014 12:13:07 -0400\r
25 Received: (nullmailer pid 15969 invoked by uid 1000); Tue, 28 Jan 2014\r
26         16:13:03 -0000\r
27 From: David Bremner <david@tethera.net>\r
28 To: notmuch@notmuchmail.org\r
29 Subject: [RFC Patch v2 2/2] doc: add target rst2man to build man pages using\r
30         rst2man\r
31 Date: Tue, 28 Jan 2014 12:12:38 -0400\r
32 Message-Id: <1390925558-15873-3-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 1.8.5.2\r
34 In-Reply-To: <1390925558-15873-1-git-send-email-david@tethera.net>\r
35 References: <87vbxfkdex.fsf@zancas.localnet>\r
36         <1390925558-15873-1-git-send-email-david@tethera.net>\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Tue, 28 Jan 2014 16:13:11 -0000\r
50 \r
51 Many people have docutils installed, but not sphinx. Allow these\r
52 people to build the man pages.\r
53 ---\r
54  Makefile                   |  2 +-\r
55  doc/rst2man/Makefile       |  5 +++++\r
56  doc/rst2man/Makefile.local | 28 ++++++++++++++++++++++++++++\r
57  doc/rst2man/prerst2man.py  | 46 ++++++++++++++++++++++++++++++++++++++++++++++\r
58  4 files changed, 80 insertions(+), 1 deletion(-)\r
59  create mode 100644 doc/rst2man/Makefile\r
60  create mode 100644 doc/rst2man/Makefile.local\r
61  create mode 100644 doc/rst2man/prerst2man.py\r
62 \r
63 diff --git a/Makefile b/Makefile\r
64 index 39f0e62..3c7f0be 100644\r
65 --- a/Makefile\r
66 +++ b/Makefile\r
67 @@ -5,7 +5,7 @@ all:\r
68  # List all subdirectories here. Each contains its own Makefile.local.\r
69  # Use of '=', without '+=', seems to be required for out-of-tree\r
70  # builds to work.\r
71 -subdirs = compat completion doc emacs lib man parse-time-string performance-test util test\r
72 +subdirs = compat completion doc doc/rst2man emacs lib man parse-time-string performance-test util test\r
73  \r
74  # We make all targets depend on the Makefiles themselves.\r
75  global_deps = Makefile Makefile.config Makefile.local \\r
76 diff --git a/doc/rst2man/Makefile b/doc/rst2man/Makefile\r
77 new file mode 100644\r
78 index 0000000..0a0815d\r
79 --- /dev/null\r
80 +++ b/doc/rst2man/Makefile\r
81 @@ -0,0 +1,5 @@\r
82 +all:\r
83 +       $(MAKE) -C ../.. all\r
84 +\r
85 +.DEFAULT:\r
86 +       $(MAKE) -C ../.. $@\r
87 diff --git a/doc/rst2man/Makefile.local b/doc/rst2man/Makefile.local\r
88 new file mode 100644\r
89 index 0000000..5bb3e43\r
90 --- /dev/null\r
91 +++ b/doc/rst2man/Makefile.local\r
92 @@ -0,0 +1,28 @@\r
93 +# -*- Makefile -*-\r
94 +dir := doc/rst2man\r
95 +\r
96 +prerst2man := python $(dir)/prerst2man.py $(dir)/.. $(dir)\r
97 +\r
98 +MANSRC := $(dir)/notmuch.1 $(dir)/notmuch-search.1 $(dir)/notmuch-search-terms.7\r
99 +\r
100 +%.1 : %.rst\r
101 +       rst2man $< > $@\r
102 +\r
103 +%.7: %.rst\r
104 +       rst2man $< > $@\r
105 +\r
106 +# preprocessed source files suitable for rst2man\r
107 +RST2MANSRC := $(dir)/notmuch.rst $(dir)/notmuch-search.rst $(dir)/notmuch-search-terms.rst\r
108 +\r
109 +# actual source files\r
110 +\r
111 +RSTSRC := $(patsubst ${dir}/%,$(dir)/../%,${RST2MANSRC})\r
112 +\r
113 +RSTMANSRC := $(patsubst %.rst,%.1,${RST2MANSRC})\r
114 +\r
115 +rst2man: ${MANSRC}\r
116 +\r
117 +${RST2MANSRC}: ${RSTSRC}\r
118 +       $(prerst2man)\r
119 +\r
120 +CLEAN := ${CLEAN} ${RST2MANSRC} ${MANSRC}\r
121 diff --git a/doc/rst2man/prerst2man.py b/doc/rst2man/prerst2man.py\r
122 new file mode 100644\r
123 index 0000000..4222f11\r
124 --- /dev/null\r
125 +++ b/doc/rst2man/prerst2man.py\r
126 @@ -0,0 +1,46 @@\r
127 +from sys import argv\r
128 +from datetime import date\r
129 +import re\r
130 +\r
131 +sourcedir=argv[1]\r
132 +outdir=argv[2]\r
133 +\r
134 +execfile(sourcedir+"/conf.py");\r
135 +\r
136 +def header(file,startdocname, command, description, authors, section):\r
137 +    file.write("""\r
138 +---------------------------------------------\r
139 +{:s}\r
140 +---------------------------------------------\r
141 +\r
142 +:Date:   {:s}\r
143 +:Version: {:s}\r
144 +:Manual section: {:d}\r
145 +:Manual group: {:s}\r
146 +\r
147 +""".format(description,date.today().isoformat(),release,section,project))\r
148 +\r
149 +blankre = re.compile("^\s*$")\r
150 +for page in man_pages:\r
151 +    outfile = open(outdir+"/"+page[0]+'.rst','w')\r
152 +    infile = open(sourcedir+"/"+page[0]+".rst",'r')\r
153 +\r
154 +\r
155 +    # this is a crude hack. We look for the first blank line, and\r
156 +    # insert the rst2man header there.\r
157 +    #\r
158 +    # XXX consider really parsing input\r
159 +\r
160 +    count=0\r
161 +    lines = infile.readlines()\r
162 +    for line in lines:\r
163 +        outfile.write(line);\r
164 +        if (blankre.match(line)):\r
165 +            break\r
166 +        count = count + 1\r
167 +\r
168 +    del lines[0:count+1]\r
169 +\r
170 +    header(outfile,*page)\r
171 +\r
172 +    outfile.write("".join(lines))\r
173 -- \r
174 1.8.5.2\r
175 \r