aboutsummaryrefslogtreecommitdiff
path: root/docs/_plugins/include_example.rb
diff options
context:
space:
mode:
authorXusen Yin <yinxusen@gmail.com>2015-11-13 13:14:25 -0800
committerXiangrui Meng <meng@databricks.com>2015-11-13 13:14:25 -0800
commit912b94363bb113ab14024a45f17a4d2b82a09e66 (patch)
tree2dc1024391e87ca0103ba476231a5106094b88af /docs/_plugins/include_example.rb
parent2d2411faa2dd1b7312c4277b2dd9e5678195cfbb (diff)
downloadspark-912b94363bb113ab14024a45f17a4d2b82a09e66.tar.gz
spark-912b94363bb113ab14024a45f17a4d2b82a09e66.tar.bz2
spark-912b94363bb113ab14024a45f17a4d2b82a09e66.zip
[SPARK-11336] Add links to example codes
https://issues.apache.org/jira/browse/SPARK-11336 mengxr I add a hyperlink of Spark on Github and a hint of their existences in Spark code repo in each code example. I remove the config key for changing the example code dir, since we assume all examples should be in spark/examples. The hyperlink, though we cannot use it now, since the Spark v1.6.0 has not been released yet, can be used after the release. So it is not a problem. I add some screen shots, so you can get an instant feeling. <img width="949" alt="screen shot 2015-10-27 at 10 47 18 pm" src="https://cloud.githubusercontent.com/assets/2637239/10780634/bd20e072-7cfc-11e5-8960-def4fc62a8ea.png"> <img width="1144" alt="screen shot 2015-10-27 at 10 47 31 pm" src="https://cloud.githubusercontent.com/assets/2637239/10780636/c3f6e180-7cfc-11e5-80b2-233589f4a9a3.png"> Author: Xusen Yin <yinxusen@gmail.com> Closes #9320 from yinxusen/SPARK-11336.
Diffstat (limited to 'docs/_plugins/include_example.rb')
-rw-r--r--docs/_plugins/include_example.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/docs/_plugins/include_example.rb b/docs/_plugins/include_example.rb
index 6ee63a5ac6..549f81fe1b 100644
--- a/docs/_plugins/include_example.rb
+++ b/docs/_plugins/include_example.rb
@@ -28,7 +28,7 @@ module Jekyll
def render(context)
site = context.registers[:site]
- config_dir = (site.config['code_dir'] || '../examples/src/main').sub(/^\//,'')
+ config_dir = '../examples/src/main'
@code_dir = File.join(site.source, config_dir)
clean_markup = @markup.strip
@@ -38,7 +38,12 @@ module Jekyll
code = File.open(@file).read.encode("UTF-8")
code = select_lines(code)
- Pygments.highlight(code, :lexer => @lang)
+ rendered_code = Pygments.highlight(code, :lexer => @lang)
+
+ hint = "<div><small>Find full example code at " \
+ "\"examples/src/main/#{clean_markup}\" in the Spark repo.</small></div>"
+
+ rendered_code + hint
end
# Trim the code block so as to have the same indention, regardless of their positions in the