google / vimdoc

Helpfile generation for vim
Apache License 2.0
291 stars 29 forks source link

Support "\ (line-continuation-comment) #113

Open flwyd opened 4 years ago

flwyd commented 4 years ago

If a .vim script contains a line continuation comment (:help line-continuation-comment, introduced in Vim 8.1.0369), vimdoc fails to parse it with an error like

Traceback (most recent call last):
  File "vimdoc", line 5, in <module>
    vimdoc.__main__.main()
  File "vimdoc/__main__.py", line 18, in main
    for module in Modules(args.plugin):
  File "vimdoc/module.py", line 423, in Modules
    blocks = list(parser.ParseBlocks(lines, filename))
  File "vimdoc/parser.py", line 127, in ParseBlocks
    for lineno, line in EnumerateParsedLines(lines):
  File "vimdoc/parser.py", line 53, in EnumerateParsedLines
    for i, line in EnumerateStripNewlinesAndJoinContinuations(lines):
  File "vimdoc/parser.py", line 40, in EnumerateStripNewlinesAndJoinContinuations
    raise error.CannotContinue('No comment to continue.', i)
vimdoc.error.CannotContinue: ./plugin/myfile.vim.072: No comment to continue.

It looks like parser.py line 40 is encountering the continuation line after the inline comment and assuming that a continuation can't follow a comment. (It's now allowed to follow a continuation comment.)

Example input:

echo
  \ 'first string'
  "\ Some comment
  \ 'second string'