Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9109#discussion_r42838196
  
    --- Diff: docs/_plugins/include_example.rb ---
    @@ -0,0 +1,79 @@
    +require 'liquid'
    +require 'pygments'
    +
    +module Jekyll
    +  class IncludeExampleTag < Liquid::Tag
    +    
    +    def initialize(tag_name, markup, tokens)
    +      @markup = markup
    +      super
    +    end
    + 
    +    def render(context)
    +      site = context.registers[:site]
    +      config_dir = (site.config['code_dir'] || 
'../examples/src/main').sub(/^\//,'')
    +      @code_dir = File.join(site.source, config_dir)
    +
    +      clean_markup = @markup.strip
    +      @file = File.join(@code_dir, clean_markup)
    +      @lang = clean_markup.split('.').last
    +
    +      code = File.open(@file).read.encode("UTF-8")
    +      code = select_lines(code)
    + 
    +      Pygments.highlight(code, :lexer => @lang)
    +    end
    + 
    +    # Trim the code block so as to have the same indention, regardless of 
their positions in the
    +    # code file.
    +    def trim_codeblock(lines)
    +      # Select the minimum indention of the current code block.
    +      min_start_spaces = lines
    +        .select{ |l| l.strip.size !=0 }
    --- End diff --
    
    nit: if we still want to follow Spark code style, it should be `select {` 
instead of `select{`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to