Re: [PATCH v4 08/16] reorganize indexing of multipart/signed and multipart/encrypted
[notmuch-archives.git] / 1f / da773fefeeba62afccabcb1909e95272f96043
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 3E845431FCF\r
6         for <notmuch@notmuchmail.org>; Sat, 22 Feb 2014 16:16:49 -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 Vrauy91cHGzj for <notmuch@notmuchmail.org>;\r
16         Sat, 22 Feb 2014 16:16:47 -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 B0A0D431E84\r
21         for <notmuch@notmuchmail.org>; Sat, 22 Feb 2014 16:16:43 -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 1WHMkL-0003q7-8L; Sat, 22 Feb 2014 20:16:41 -0400\r
25 Received: (nullmailer pid 19429 invoked by uid 1000); Sun, 23 Feb 2014\r
26         00:16:31 -0000\r
27 From: David Bremner <david@tethera.net>\r
28 To: notmuch@notmuchmail.org\r
29 Subject: [RFC Patch v3 2/3] doc: add target rst2man to build man pages using\r
30         rst2man\r
31 Date: Sat, 22 Feb 2014 20:16:14 -0400\r
32 Message-Id: <1393114575-8756-3-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 1.8.5.3\r
34 In-Reply-To: <1393114575-8756-1-git-send-email-david@tethera.net>\r
35 References: <87fvo7btu8.fsf@qmul.ac.uk>\r
36         <1393114575-8756-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: Sun, 23 Feb 2014 00:16:49 -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/conf.py                |  2 +-\r
56  doc/rst2man/Makefile       |  5 +++++\r
57  doc/rst2man/Makefile.local | 37 ++++++++++++++++++++++++++++++++\r
58  doc/rst2man/prerst2man.py  | 53 ++++++++++++++++++++++++++++++++++++++++++++++\r
59  5 files changed, 97 insertions(+), 2 deletions(-)\r
60  create mode 100644 doc/rst2man/Makefile\r
61  create mode 100644 doc/rst2man/Makefile.local\r
62  create mode 100644 doc/rst2man/prerst2man.py\r
63 \r
64 diff --git a/Makefile b/Makefile\r
65 index 39f0e62..3c7f0be 100644\r
66 --- a/Makefile\r
67 +++ b/Makefile\r
68 @@ -5,7 +5,7 @@ all:\r
69  # List all subdirectories here. Each contains its own Makefile.local.\r
70  # Use of '=', without '+=', seems to be required for out-of-tree\r
71  # builds to work.\r
72 -subdirs = compat completion doc emacs lib man parse-time-string performance-test util test\r
73 +subdirs = compat completion doc doc/rst2man emacs lib man parse-time-string performance-test util test\r
74  \r
75  # We make all targets depend on the Makefiles themselves.\r
76  global_deps = Makefile Makefile.config Makefile.local \\r
77 diff --git a/doc/conf.py b/doc/conf.py\r
78 index d80b2af..9180d86 100644\r
79 --- a/doc/conf.py\r
80 +++ b/doc/conf.py\r
81 @@ -21,7 +21,7 @@ release = '0.17'\r
82  \r
83  # List of patterns, relative to source directory, that match files and\r
84  # directories to ignore when looking for source files.\r
85 -exclude_patterns = ['_build']\r
86 +exclude_patterns = ['_build','rst2man']\r
87  \r
88  # The name of the Pygments (syntax highlighting) style to use.\r
89  pygments_style = 'sphinx'\r
90 diff --git a/doc/rst2man/Makefile b/doc/rst2man/Makefile\r
91 new file mode 100644\r
92 index 0000000..0a0815d\r
93 --- /dev/null\r
94 +++ b/doc/rst2man/Makefile\r
95 @@ -0,0 +1,5 @@\r
96 +all:\r
97 +       $(MAKE) -C ../.. all\r
98 +\r
99 +.DEFAULT:\r
100 +       $(MAKE) -C ../.. $@\r
101 diff --git a/doc/rst2man/Makefile.local b/doc/rst2man/Makefile.local\r
102 new file mode 100644\r
103 index 0000000..bc821fe\r
104 --- /dev/null\r
105 +++ b/doc/rst2man/Makefile.local\r
106 @@ -0,0 +1,37 @@\r
107 +# -*- Makefile -*-\r
108 +dir := doc/rst2man\r
109 +\r
110 +prerst2man := python $(dir)/prerst2man.py $(dir)/.. $(dir)\r
111 +\r
112 +%.1 :%.rst\r
113 +       rst2man $< > $@\r
114 +\r
115 +%.5 :%.rst\r
116 +       rst2man $< > $@\r
117 +\r
118 +%.7: %.rst\r
119 +       rst2man $< > $@\r
120 +\r
121 +# actual source files\r
122 +RST1SRC := $(wildcard doc/man1/*.rst)\r
123 +RST5SRC        := $(wildcard doc/man5/*.rst)\r
124 +RST7SRC := $(wildcard doc/man7/*.rst)\r
125 +\r
126 +RST2MAN1SRC := $(patsubst doc/man1/%,doc/rst2man/man1/%,$(RST1SRC))\r
127 +RST2MAN5SRC := $(patsubst doc/man5/%,doc/rst2man/man5/%,$(RST5SRC))\r
128 +RST2MAN7SRC := $(patsubst doc/man7/%,doc/rst2man/man7/%,$(RST7SRC))\r
129 +\r
130 +RST2MANSRC := ${RST2MAN1SRC} ${RST2MAN5SRC} ${RST2MAN7SRC}\r
131 +\r
132 +MAN1SRC := $(patsubst $(dir)/man1/%.rst,$(dir)/man1/%.1,${RST2MAN1SRC})\r
133 +MAN5SRC := $(patsubst $(dir)/man5/%.rst,$(dir)/man5/%.5,${RST2MAN5SRC})\r
134 +MAN7SRC := $(patsubst $(dir)/man7/%.rst,$(dir)/man7/%.7,${RST2MAN7SRC})\r
135 +MANSRC := ${MAN1SRC} ${MAN5SRC} ${MAN7SRC}\r
136 +\r
137 +rst2man: ${MANSRC}\r
138 +\r
139 +${RST2MANSRC}: ${RSTSRC}\r
140 +       mkdir -p doc/rst2man/man1 doc/rst2man/man5 doc/rst2man/man7\r
141 +       $(prerst2man)\r
142 +\r
143 +CLEAN := ${CLEAN} ${RST2MANSRC} ${MANSRC}\r
144 diff --git a/doc/rst2man/prerst2man.py b/doc/rst2man/prerst2man.py\r
145 new file mode 100644\r
146 index 0000000..797dd20\r
147 --- /dev/null\r
148 +++ b/doc/rst2man/prerst2man.py\r
149 @@ -0,0 +1,53 @@\r
150 +from sys import argv\r
151 +from datetime import date\r
152 +import re\r
153 +\r
154 +sourcedir=argv[1]\r
155 +outdir=argv[2]\r
156 +\r
157 +execfile(sourcedir+"/conf.py");\r
158 +\r
159 +\r
160 +\r
161 +\r
162 +def header(file,startdocname, command, description, authors, section):\r
163 +    file.write("""\r
164 +{:s}\r
165 +{:s}\r
166 +{:s}\r
167 +\r
168 +:Date:   {:s}\r
169 +:Version: {:s}\r
170 +:Manual section: {:d}\r
171 +:Manual group: {:s}\r
172 +\r
173 +""".format(\r
174 +'-' * len(description),\r
175 +description,\r
176 +'-' * len(description),\r
177 +date.today().isoformat(),release,section,project))\r
178 +\r
179 +blankre = re.compile("^\s*$")\r
180 +for page in man_pages:\r
181 +    outfile = open(outdir+"/"+page[0]+'.rst','w')\r
182 +    infile = open(sourcedir+"/"+page[0]+".rst",'r')\r
183 +\r
184 +\r
185 +    # this is a crude hack. We look for the first blank line, and\r
186 +    # insert the rst2man header there.\r
187 +    #\r
188 +    # XXX consider really parsing input\r
189 +\r
190 +    count=0\r
191 +    lines = infile.readlines()\r
192 +    for line in lines:\r
193 +        outfile.write(line);\r
194 +        if (blankre.match(line)):\r
195 +            break\r
196 +        count = count + 1\r
197 +\r
198 +    del lines[0:count+1]\r
199 +\r
200 +    header(outfile,*page)\r
201 +\r
202 +    outfile.write("".join(lines))\r
203 -- \r
204 1.8.5.3\r
205 \r