style: no spaces in parens
This commit is contained in:
parent
9e88a3925c
commit
3e9a14e896
36
lib/rocco.rb
36
lib/rocco.rb
@ -314,14 +314,14 @@ class Rocco
|
|||||||
# the _end_ of a comment block or the _end_ of a comment block with a
|
# the _end_ of a comment block or the _end_ of a comment block with a
|
||||||
# comment.
|
# comment.
|
||||||
if in_comment_block
|
if in_comment_block
|
||||||
if block_comment_end && line.match( block_comment_end )
|
if block_comment_end && line.match(block_comment_end)
|
||||||
in_comment_block = false
|
in_comment_block = false
|
||||||
elsif block_comment_end_with && line.match( block_comment_end_with )
|
elsif block_comment_end_with && line.match(block_comment_end_with)
|
||||||
in_comment_block = false
|
in_comment_block = false
|
||||||
docs << line.match( block_comment_end_with ).captures.first.
|
docs << line.match(block_comment_end_with).captures.first.
|
||||||
sub( block_comment_mid || '', '' )
|
sub(block_comment_mid || '', '')
|
||||||
else
|
else
|
||||||
docs << line.sub( block_comment_mid || '', '' )
|
docs << line.sub(block_comment_mid || '', '')
|
||||||
end
|
end
|
||||||
# If we're currently in a heredoc, we're looking for the end of the
|
# If we're currently in a heredoc, we're looking for the end of the
|
||||||
# heredoc, and everything it contains is code.
|
# heredoc, and everything it contains is code.
|
||||||
@ -335,41 +335,41 @@ class Rocco
|
|||||||
# the beginning of a block, or a single-line comment all on it's lonesome.
|
# the beginning of a block, or a single-line comment all on it's lonesome.
|
||||||
# In either case, if there's code, start a new section.
|
# In either case, if there's code, start a new section.
|
||||||
else
|
else
|
||||||
if heredoc_start && line.match( heredoc_start )
|
if heredoc_start && line.match(heredoc_start)
|
||||||
in_heredoc = $1
|
in_heredoc = $1
|
||||||
code << line
|
code << line
|
||||||
elsif block_comment_one_liner && line.match( block_comment_one_liner )
|
elsif block_comment_one_liner && line.match(block_comment_one_liner)
|
||||||
if code.any?
|
if code.any?
|
||||||
sections << [docs, code]
|
sections << [docs, code]
|
||||||
docs, code = [], []
|
docs, code = [], []
|
||||||
end
|
end
|
||||||
docs << line.match( block_comment_one_liner ).captures.first
|
docs << line.match(block_comment_one_liner).captures.first
|
||||||
elsif block_comment_start && line.match( block_comment_start )
|
elsif block_comment_start && line.match(block_comment_start)
|
||||||
in_comment_block = true
|
in_comment_block = true
|
||||||
if code.any?
|
if code.any?
|
||||||
sections << [docs, code]
|
sections << [docs, code]
|
||||||
docs, code = [], []
|
docs, code = [], []
|
||||||
end
|
end
|
||||||
elsif block_comment_start_with && line.match( block_comment_start_with )
|
elsif block_comment_start_with && line.match(block_comment_start_with)
|
||||||
in_comment_block = true
|
in_comment_block = true
|
||||||
if code.any?
|
if code.any?
|
||||||
sections << [docs, code]
|
sections << [docs, code]
|
||||||
docs, code = [], []
|
docs, code = [], []
|
||||||
end
|
end
|
||||||
docs << line.match( block_comment_start_with ).captures.first
|
docs << line.match(block_comment_start_with).captures.first
|
||||||
elsif single_line_comment && line.match( single_line_comment )
|
elsif single_line_comment && line.match(single_line_comment)
|
||||||
if code.any?
|
if code.any?
|
||||||
sections << [docs, code]
|
sections << [docs, code]
|
||||||
docs, code = [], []
|
docs, code = [], []
|
||||||
end
|
end
|
||||||
docs << line.sub( single_line_comment || '', '' )
|
docs << line.sub(single_line_comment || '', '')
|
||||||
else
|
else
|
||||||
code << line
|
code << line
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sections << [docs, code] if docs.any? || code.any?
|
sections << [docs, code] if docs.any? || code.any?
|
||||||
normalize_leading_spaces( sections )
|
normalize_leading_spaces(sections)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Normalizes documentation whitespace by checking for leading whitespace,
|
# Normalizes documentation whitespace by checking for leading whitespace,
|
||||||
@ -385,13 +385,13 @@ class Rocco
|
|||||||
#
|
#
|
||||||
# should yield a comment block of `Comment 1\nComment 2` and code of
|
# should yield a comment block of `Comment 1\nComment 2` and code of
|
||||||
# `def func():\n print "omg!"`
|
# `def func():\n print "omg!"`
|
||||||
def normalize_leading_spaces( sections )
|
def normalize_leading_spaces(sections)
|
||||||
sections.map do |section|
|
sections.map do |section|
|
||||||
if section.any? && section[0].any?
|
if section.any? && section[0].any?
|
||||||
leading_space = section[0][0].match( "^\s+" )
|
leading_space = section[0][0].match("^\s+")
|
||||||
if leading_space
|
if leading_space
|
||||||
section[0] =
|
section[0] =
|
||||||
section[0].map{ |line| line.sub( /^#{leading_space.to_s}/, '' ) }
|
section[0].map{ |line| line.sub(/^#{leading_space.to_s}/, '') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
section
|
section
|
||||||
@ -472,7 +472,7 @@ class Rocco
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
code_stream = code_blocks.join( divider_input )
|
code_stream = code_blocks.join(divider_input)
|
||||||
|
|
||||||
code_html =
|
code_html =
|
||||||
if pygmentize?
|
if pygmentize?
|
||||||
|
Loading…
Reference in New Issue
Block a user