Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/_plugins/include_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ 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}." \
raise "Start indices amount is not equal to end indices amount, see #{@file}, #{@snippet_label}." \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer

... see #{@file} [labeled=#{@snippet_label}].

Otherwise the label itself might be mistaken for a file path.

unless startIndices.size == endIndices.size

raise "No code is selected by include_example, see #{@file}." \
raise "No code is selected by include_example, see #{@file}, #{@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}." \
raise "Overlapping between two example code blocks are not allowed, see #{@file}, #{@snippet_label}." \
if start <= lastIndex
raise "$example on$ should not be in the same line with $example off$, see #{@file}." \
raise "$example on$ should not be in the same line with $example off$, see #{@file}, #{@snippet_label}." \
if start == endline
lastIndex = endline
range = Range.new(start + 1, endline - 1)
Expand Down
Loading