Merge pull request #18671 from akka/wip-port-includecode

+doc #18670 log errors when included snippet empty
This commit is contained in:
Konrad Malawski 2015-10-08 12:37:38 +02:00
commit 7bf8f51e2f

View file

@ -109,6 +109,11 @@ class IncludeCode(Directive):
return count
nonempty = filter(lambda l: l.strip(), lines)
if not nonempty:
return [document.reporter.error(
"Snippet ({}#{}) not found!".format(filename, section),
line=self.lineno
)]
tabcounts = map(lambda l: countwhile(lambda c: c == ' ', l), nonempty)
tabshift = min(tabcounts) if tabcounts else 0