Skip to content

Commit f689245

Browse files
committed
---
yaml --- r: 174383 b: refs/heads/master c: 39e19cc h: refs/heads/master i: 174381: 5021c8c 174379: 1227dbd 174375: 75f0336 174367: 86ba9ff v: v3
1 parent ecc0e7b commit f689245

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: de6f520192d76151bf99f2250afac75da3f040d5
2+
refs/heads/master: 39e19ccdb6c89703a9c88eb88a26f61ec10d31f3
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9006c3c0f14be45da8ffeba43d354d088e366c83
55
refs/heads/try: 08f6380a9f0b866796080094f44fe25ea5636547

trunk/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') == '!')

trunk/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)