defunkt / tomdoc

A TomDoc Ruby library.
http://tomdoc.org/
MIT License
114 stars 16 forks source link

Bug in clean code and question #11

Closed trans closed 13 years ago

trans commented 13 years ago

https://github.com/defunkt/tomdoc/blob/363b61934092e14d3ee4db9b4d13d9b36ecaba6a/lib/tomdoc/tomdoc.rb#L49

  clean = raw.split("\n").map do |line|
    line =~ /^(\s*# ?)/ ? line.sub($1, '') : nil
  end.compact.join("\n")

nil needs to be line.

However I am wondering why this is happening. Should we be removing the comment markers from comments in example comments?

leejarvis commented 13 years ago

No, this doesn't remove them.

c = TomDoc::TomDoc.new(<<comment)
# Examples
#   multiplex('Tom', 4)
#   # => 'TomTomTomTom'
#
# Returns
comment
puts c.examples.first
multiplex('Tom', 4)
  # => 'TomTomTomTom'

Also, why has this been commented out in the main branch? In commit 3e74b306eaa259a3a7a4d17359107541c260be81 you decide to return the raw string. Why?

trans commented 13 years ago

My mistake. I thought the comment had already been stripped of the # before it got passed into TomDoc::TomDoc.new. Will fix ASAP. Thanks.