##// END OF EJS Templates
releasenotes: improve parsing around bullet points...
Rishabh Madan -
r33012:5814db57 default
parent child Browse files
Show More
@@ -185,8 +185,8 b' def parsereleasenotesfile(sections, text'
185
185
186 blocks = minirst.parse(text)[0]
186 blocks = minirst.parse(text)[0]
187
187
188 def gatherparagraphs(offset):
188 def gatherparagraphsbullets(offset, title=False):
189 paragraphs = []
189 notefragment = []
190
190
191 for i in range(offset + 1, len(blocks)):
191 for i in range(offset + 1, len(blocks)):
192 block = blocks[i]
192 block = blocks[i]
@@ -198,17 +198,27 b' def parsereleasenotesfile(sections, text'
198 elif block['type'] == 'bullet':
198 elif block['type'] == 'bullet':
199 if block['indent'] != 0:
199 if block['indent'] != 0:
200 raise error.Abort(_('indented bullet lists not supported'))
200 raise error.Abort(_('indented bullet lists not supported'))
201 if title:
202 lines = [l[1:].strip() for l in block['lines']]
203 notefragment.append(lines)
204 continue
205 else:
206 lines = [[l[1:].strip() for l in block['lines']]]
201
207
202 lines = [l[1:].strip() for l in block['lines']]
208 for block in blocks[i + 1:]:
203 paragraphs.append(lines)
209 if block['type'] in ('bullet', 'section'):
204 continue
210 break
211 if block['type'] == 'paragraph':
212 lines.append(block['lines'])
213 notefragment.append(lines)
214 continue
205 elif block['type'] != 'paragraph':
215 elif block['type'] != 'paragraph':
206 raise error.Abort(_('unexpected block type in release notes: '
216 raise error.Abort(_('unexpected block type in release notes: '
207 '%s') % block['type'])
217 '%s') % block['type'])
218 if title:
219 notefragment.append(block['lines'])
208
220
209 paragraphs.append(block['lines'])
221 return notefragment
210
211 return paragraphs
212
222
213 currentsection = None
223 currentsection = None
214 for i, block in enumerate(blocks):
224 for i, block in enumerate(blocks):
@@ -226,16 +236,18 b' def parsereleasenotesfile(sections, text'
226 title)
236 title)
227
237
228 currentsection = name
238 currentsection = name
229 paragraphs = gatherparagraphs(i)
239 bullet_points = gatherparagraphsbullets(i)
230 if paragraphs:
240 if bullet_points:
231 notes.addnontitleditem(currentsection, paragraphs)
241 for para in bullet_points:
242 notes.addnontitleditem(currentsection, para)
232
243
233 elif block['underline'] == '-': # sub-section
244 elif block['underline'] == '-': # sub-section
234 paragraphs = gatherparagraphs(i)
235
236 if title == BULLET_SECTION:
245 if title == BULLET_SECTION:
237 notes.addnontitleditem(currentsection, paragraphs)
246 bullet_points = gatherparagraphsbullets(i)
247 for para in bullet_points:
248 notes.addnontitleditem(currentsection, para)
238 else:
249 else:
250 paragraphs = gatherparagraphsbullets(i, True)
239 notes.addtitleditem(currentsection, title, paragraphs)
251 notes.addtitleditem(currentsection, title, paragraphs)
240 else:
252 else:
241 raise error.Abort(_('unsupported section type for %s') % title)
253 raise error.Abort(_('unsupported section type for %s') % title)
@@ -34,8 +34,7 b' A fix directive from commit message is a'
34
34
35 * Fix from commit message.
35 * Fix from commit message.
36
36
37 Processing again will no-op
37 Processing again ignores the already added bullet.
38 TODO this is buggy
39
38
40 $ hg releasenotes -r . $TESTTMP/single-fix-bullet
39 $ hg releasenotes -r . $TESTTMP/single-fix-bullet
41
40
@@ -45,8 +44,6 b' TODO this is buggy'
45
44
46 * Fix from release notes.
45 * Fix from release notes.
47
46
48 Fix from commit message.
49
50 * Fix from commit message.
47 * Fix from commit message.
51
48
52 $ cd ..
49 $ cd ..
@@ -111,7 +108,7 b" Doing it again won't add another section"
111
108
112 $ cd ..
109 $ cd ..
113
110
114 Bullets don't merge properly
111 Bullets from rev merge with those from notes file.
115
112
116 $ hg init bullets
113 $ hg init bullets
117 $ cd bullets
114 $ cd bullets
@@ -157,7 +154,7 b" Bullets don't merge properly"
157
154
158 * this is fix1.
155 * this is fix1.
159
156
160 this is fix2.
157 * this is fix2.
161
158
162 * this is fix3.
159 * this is fix3.
163
160
@@ -59,7 +59,9 b' Multiple bullet points. With some entrie'
59 section: feature
59 section: feature
60 bullet point:
60 bullet point:
61 paragraph: First bullet point. It has a single line.
61 paragraph: First bullet point. It has a single line.
62 bullet point:
62 paragraph: Second bullet point. It consists of multiple lines.
63 paragraph: Second bullet point. It consists of multiple lines.
64 bullet point:
63 paragraph: Third bullet point. It has a single line.
65 paragraph: Third bullet point. It has a single line.
64
66
65 Bullet point without newline between items
67 Bullet point without newline between items
@@ -77,8 +79,11 b' Bullet point without newline between ite'
77 section: feature
79 section: feature
78 bullet point:
80 bullet point:
79 paragraph: First bullet point
81 paragraph: First bullet point
82 bullet point:
80 paragraph: Second bullet point And it has multiple lines
83 paragraph: Second bullet point And it has multiple lines
84 bullet point:
81 paragraph: Third bullet point
85 paragraph: Third bullet point
86 bullet point:
82 paragraph: Fourth bullet point
87 paragraph: Fourth bullet point
83
88
84 Sub-section contents are read
89 Sub-section contents are read
@@ -130,10 +135,12 b' Multiple sections are read'
130 section: feature
135 section: feature
131 bullet point:
136 bullet point:
132 paragraph: Feature 1
137 paragraph: Feature 1
138 bullet point:
133 paragraph: Feature 2
139 paragraph: Feature 2
134 section: fix
140 section: fix
135 bullet point:
141 bullet point:
136 paragraph: Fix 1
142 paragraph: Fix 1
143 bullet point:
137 paragraph: Fix 2
144 paragraph: Fix 2
138
145
139 Mixed sub-sections and bullet list
146 Mixed sub-sections and bullet list
@@ -166,4 +173,5 b' Mixed sub-sections and bullet list'
166 paragraph: Some words about the second feature. That span multiple lines.
173 paragraph: Some words about the second feature. That span multiple lines.
167 bullet point:
174 bullet point:
168 paragraph: Bullet item 1
175 paragraph: Bullet item 1
176 bullet point:
169 paragraph: Bullet item 2
177 paragraph: Bullet item 2
General Comments 0
You need to be logged in to leave comments. Login now