Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
move comment styles out into their own module
Browse files Browse the repository at this point in the history
Something here was screwing with the doc generation. It's kind of
noisy in the main codebase anyway.
  • Loading branch information
rtomayko committed Jun 19, 2011
1 parent acb6e5d commit 618e696
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 51 deletions.
53 changes: 2 additions & 51 deletions lib/rocco.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,57 +206,8 @@ def detect_language
#
# At the moment, we're only returning `:single`. Consider this
# groundwork for block comment parsing.
C_STYLE_COMMENTS = {
:single => "//",
:multi => { :start => "/**", :middle => "*", :end => "*/" },
:heredoc => nil
}
COMMENT_STYLES = {
"bash" => { :single => "#", :multi => nil },
"c" => C_STYLE_COMMENTS,
"coffee-script" => {
:single => "#",
:multi => { :start => "###", :middle => nil, :end => "###" },
:heredoc => nil
},
"cpp" => C_STYLE_COMMENTS,
"csharp" => C_STYLE_COMMENTS,
"css" => {
:single => nil,
:multi => { :start => "/**", :middle => "*", :end => "*/" },
:heredoc => nil
},
"html" => {
:single => nil,
:multi => { :start => '<!--', :middle => nil, :end => '-->' },
:heredoc => nil
},
"java" => C_STYLE_COMMENTS,
"js" => C_STYLE_COMMENTS,
"lua" => {
:single => "--",
:multi => nil,
:heredoc => nil
},
"php" => C_STYLE_COMMENTS,
"python" => {
:single => "#",
:multi => { :start => '"""', :middle => nil, :end => '"""' },
:heredoc => nil
},
"rb" => {
:single => "#",
:multi => { :start => '=begin', :middle => nil, :end => '=end' },
:heredoc => "<<-"
},
"scala" => C_STYLE_COMMENTS,
"scheme" => { :single => ";;", :multi => nil, :heredoc => nil },
"xml" => {
:single => nil,
:multi => { :start => '<!--', :middle => nil, :end => '-->' },
:heredoc => nil
},
}
require 'rocco/comment_styles'
include CommentStyles

def generate_comment_chars
@_commentchar ||=
Expand Down
56 changes: 56 additions & 0 deletions lib/rocco/comment_styles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
class Rocco
module CommentStyles
C_STYLE_COMMENTS = {
:single => "//",
:multi => { :start => "/**", :middle => "*", :end => "*/" },
:heredoc => nil
}

COMMENT_STYLES = {
"bash" => { :single => "#", :multi => nil },
"c" => C_STYLE_COMMENTS,
"coffee-script" => {
:single => "#",
:multi => { :start => "###", :middle => nil, :end => "###" },
:heredoc => nil
},
"cpp" => C_STYLE_COMMENTS,
"csharp" => C_STYLE_COMMENTS,
"css" => {
:single => nil,
:multi => { :start => "/**", :middle => "*", :end => "*/" },
:heredoc => nil
},
"html" => {
:single => nil,
:multi => { :start => '<!--', :middle => nil, :end => '-->' },
:heredoc => nil
},
"java" => C_STYLE_COMMENTS,
"js" => C_STYLE_COMMENTS,
"lua" => {
:single => "--",
:multi => nil,
:heredoc => nil
},
"php" => C_STYLE_COMMENTS,
"python" => {
:single => "#",
:multi => { :start => '"""', :middle => nil, :end => '"""' },
:heredoc => nil
},
"rb" => {
:single => "#",
:multi => { :start => '=begin', :middle => nil, :end => '=end' },
:heredoc => "<<-"
},
"scala" => C_STYLE_COMMENTS,
"scheme" => { :single => ";;", :multi => nil, :heredoc => nil },
"xml" => {
:single => nil,
:multi => { :start => '<!--', :middle => nil, :end => '-->' },
:heredoc => nil
},
}
end
end

0 comments on commit 618e696

Please sign in to comment.