Skip to content

Commit 6a3f72f

Browse files
committed
---
yaml --- r: 182349 b: refs/heads/beta c: 39e19cc h: refs/heads/master i: 182347: eeeb36b v: v3
1 parent 48b1d90 commit 6a3f72f

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: de6f520192d76151bf99f2250afac75da3f040d5
34+
refs/heads/beta: 39e19ccdb6c89703a9c88eb88a26f61ec10d31f3
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: eb836bf767aa1d8d4cba488a9091cde3c0ab4b2f

branches/beta/src/etc/htmldocck.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,43 @@ def close(self):
148148

149149
Command = namedtuple('Command', 'negated cmd args lineno')
150150

151-
LINE_PATTERN = re.compile(r'(?<=(?<!\S)@)(?P<negated>!?)(?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*)(?P<args>.*)$')
151+
# returns a generator out of the file object, which
152+
# - removes `\\` then `\n` then a shared prefix with the previous line then optional whitespace;
153+
# - keeps a line number (starting from 0) of the first line being concatenated.
154+
def concat_multi_lines(f):
155+
lastline = None # set to the last line when the last line has a backslash
156+
firstlineno = None
157+
catenated = ''
158+
for lineno, line in enumerate(f):
159+
line = line.rstrip('\r\n')
160+
161+
# strip the common prefix from the current line if needed
162+
if lastline is not None:
163+
maxprefix = 0
164+
for i in xrange(min(len(line), len(lastline))):
165+
if line[i] != lastline[i]: break
166+
maxprefix += 1
167+
line = line[maxprefix:].lstrip()
168+
169+
firstlineno = firstlineno or lineno
170+
if line.endswith('\\'):
171+
lastline = line[:-1]
172+
catenated += line[:-1]
173+
else:
174+
yield firstlineno, catenated + line
175+
lastline = None
176+
firstlineno = None
177+
catenated = ''
178+
179+
LINE_PATTERN = re.compile(r'''
180+
(?<=(?<!\S)@)(?P<negated>!?)
181+
(?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*)
182+
(?P<args>.*)$
183+
''', re.X)
152184
def get_commands(template):
153185
with open(template, 'rUb') as f:
154-
for lineno, line in enumerate(f):
155-
m = LINE_PATTERN.search(line.rstrip('\r\n'))
186+
for lineno, line in concat_multi_lines(f):
187+
m = LINE_PATTERN.search(line)
156188
if not m: continue
157189

158190
negated = (m.group('negated') == '!')

branches/beta/src/test/run-make/rustdoc-where/foo.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ impl<D> Delta<D> where D: MyTrait {
2424
}
2525

2626
pub struct Echo<E>;
27-
// @matches foo/struct.Echo.html '//*[@class="impl"]//code' "impl.*MyTrait.*for.*Echo.*where.*E:.*MyTrait"
28-
// @matches foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' "impl.*MyTrait.*for.*Echo.*where.*E:.*MyTrait"
27+
// @matches foo/struct.Echo.html '//*[@class="impl"]//code' \
28+
// "impl.*MyTrait.*for.*Echo.*where.*E:.*MyTrait"
29+
// @matches foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \
30+
// "impl.*MyTrait.*for.*Echo.*where.*E:.*MyTrait"
2931
impl<E> MyTrait for Echo<E> where E: MyTrait {}
3032

3133
pub enum Foxtrot<F> {}
32-
// @matches foo/enum.Foxtrot.html '//*[@class="impl"]//code' "impl.*MyTrait.*for.*Foxtrot.*where.*F:.*MyTrait"
33-
// @matches foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' "impl.*MyTrait.*for.*Foxtrot.*where.*F:.*MyTrait"
34+
// @matches foo/enum.Foxtrot.html '//*[@class="impl"]//code' \
35+
// "impl.*MyTrait.*for.*Foxtrot.*where.*F:.*MyTrait"
36+
// @matches foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \
37+
// "impl.*MyTrait.*for.*Foxtrot.*where.*F:.*MyTrait"
3438
impl<F> MyTrait for Foxtrot<F> where F: MyTrait {}

0 commit comments

Comments
 (0)