spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yinxusen <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-10382] [POC] Make example code in user ...
Date Sat, 17 Oct 2015 07:25:59 GMT
Github user yinxusen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9109#discussion_r42306886
  
    --- Diff: docs/_plugins/include_example.rb ---
    @@ -0,0 +1,70 @@
    +require 'octopress-code-highlighter'
    +require 'liquid'
    +
    +module Octopress
    +  module IncludeExample
    +    class Tag < Liquid::Tag
    +      
    +      # Pattern for {% include_example /path/to/a/file.lan %}
    +      FileOnly = /^(\S+)$/
    +      # Pattern for {% include_example /path/to/a/file.lan title %}
    +      FileTitle = /(\S+)\s+(\S.*?)$/i
    +
    +      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)
    +
    +        begin
    +          options = get_options
    +          code = File.open(@file).read.encode("UTF-8")
    +          code = select_lines(code, options)
    +
    +          CodeHighlighter.highlight(code, options)
    --- End diff --
    
    So there is no need to call outside function, just translate it into markdown highlight.
Then we can avoid to use Octopress in the beginning. I get it.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message