coffeedoc / codo

CoffeeScript API documentation generator. It's like YARD but for CoffeeScript!
Other
625 stars 92 forks source link

Parsing fails if source contains multiline string #254

Open murrayju opened 7 years ago

murrayju commented 7 years ago

Coffeescript allows multiline strings. The codo parser throws an error if the source contains a multiline string with interpolation.

class Test
  constructor: (a, b) ->
    @thing = "#{a} >
      #{b}"

Gives the error:

error: Cannot parse Coffee file Test.coffee: missing "

The same code passes through the CoffeeScript compiler (and coffeelint) without error.

timkinnane commented 7 years ago

You could try with a multiline block instead

@thing = """
  #{a} >
    #{b}
"""

Not a solution to the parsing issue, but might let you move forward and is probably safer generally to use multiline blocks because it's more explicit and readable as opposed to the single quote method, which could easily be read as a mistake.

murrayju commented 7 years ago

Those aren't equivalent though. The block form will include newline characters, while the other form joins lines with a single space character. The workaround is to put it on a single line, or concatenate multiple strings across lines.

This isn't blocking me, just annoying when valid coffee code fails to process through codo and I have to modify it.

murrayju commented 7 years ago

This would also be way less annoying if codo would output the offending line number. These parse errors can be really hard to track down.

timkinnane commented 7 years ago

Of course, my bad.