Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-12035] Add more debug information in include_example tag of Jekyll #10026

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/_plugins/include_example.rb
Expand Up @@ -75,19 +75,21 @@ def select_lines(code)
.select { |l, i| l.include? "$example off$" }
.map { |l, i| i }

raise "Start indices amount is not equal to end indices amount, please check the code." \
raise "Start indices amount is not equal to end indices amount, see #{@file}." \
unless startIndices.size == endIndices.size

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