Skip to content

Commit

Permalink
refine error prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
yinxusen committed Jul 1, 2016
1 parent 51018c9 commit 176a240
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docs/_plugins/include_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,23 @@ def select_lines(code)
.select { |l, i| l.include? "$example off#{@snippet_label}$" }
.map { |l, i| i }

raise "Start indices amount is not equal to end indices amount, see #{@file}, #{@snippet_label}." \
raise "Start indices amount is not equal to end indices amount, "\
"see #{@file}, [labeled=#{@snippet_label}]." \
unless startIndices.size == endIndices.size

raise "No code is selected by include_example, see #{@file}, #{@snippet_label}." \
raise "No code is selected by include_example, see #{@file}, [labeled=#{@snippet_label}]." \
if startIndices.size == 0

# Select and join code blocks together, with a space line between each of two continuous
# blocks.
lastIndex = -1
result = ""
startIndices.zip(endIndices).each do |start, endline|
raise "Overlapping between two example code blocks are not allowed, see #{@file}, #{@snippet_label}." \
raise "Overlapping between two example code blocks are not allowed, "\
"see #{@file}, [labeled=#{@snippet_label}]." \
if start <= lastIndex
raise "$example on$ should not be in the same line with $example off$, see #{@file}, #{@snippet_label}." \
raise "$example on$ should not be in the same line with $example off$, "\
"see #{@file}, [labeled=#{@snippet_label}]." \
if start == endline
lastIndex = endline
range = Range.new(start + 1, endline - 1)
Expand Down

0 comments on commit 176a240

Please sign in to comment.