google / vimdoc

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

Docs fail to generate when addon-info.json description is too long #82

Closed dbarnett closed 9 years ago

dbarnett commented 9 years ago

If you try to generate docs for a plugin with a long (~ 70+ chars) description value in addon-info.json, vimdoc fails with an AssertionError about line width:

Traceback (most recent call last):
  File "/usr/bin/vimdoc", line 5, in <module>
    vimdoc.__main__.main()
  File "/usr/lib/python3/dist-packages/vimdoc/__main__.py", line 19, in main
    Helpfile(module, docdir).Write()
  File "/usr/lib/python3/dist-packages/vimdoc/output.py", line 28, in Write
    self.WriteHeader()
  File "/usr/lib/python3/dist-packages/vimdoc/output.py", line 42, in WriteHeader
    self.Print(line)
  File "/usr/lib/python3/dist-packages/vimdoc/output.py", line 172, in Print
    assert len(line) <= self.WIDTH
AssertionError

Apparently it tries to fit the whole description onto one line without wrapping.

The first step is to figure out what doc generation should look like for long lines that need to be wrapped. Currently it would look something like this if it generated successfully:

*codefmtlib.txt*»  Interface library for registering syntax-aware code formatters.
Google                                                            codefmtlib

Since this line is rendered verbatim into the :help local-additions table (see :help write-local-help), we might get the best results if we just disable wrapping for that line and allow it to be indefinitely long to accommodate the description. Otherwise anything wrapped onto subsequent lines will be truncated from local-additions. Since this one line contains a literal tab character (on purpose), wrapping at a certain character length doesn't guarantee the text will fit on one line, anyway.

The other options would be to just live with line wraps truncating long descriptions in local-additions, explicitly truncate long descriptions in the generated docs with an ellipsis, or fail with an explicit error saying "your description is too long".