After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 787495 - gtkdoc-fixxref crashes when running vim for syntax highlighting
gtkdoc-fixxref crashes when running vim for syntax highlighting
Status: RESOLVED FIXED
Product: gtk-doc
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: 1.27
Assigned To: gtk-doc maintainers
gtk-doc maintainers
Depends on:
Blocks:
 
 
Reported: 2017-09-10 08:38 UTC by Carlos Garcia Campos
Modified: 2017-12-18 15:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sample code to reproduce (2.68 KB, application/gzip)
2017-10-03 13:29 UTC, Wataru Shimizu
Details
HTML file generated by gtk-doc-1.26 with vim (7.95 KB, application/gzip)
2017-11-06 14:29 UTC, Wataru Shimizu
Details

Description Carlos Garcia Campos 2017-09-10 08:38:28 UTC
I don't know if this is because of a new version of vim, or a change in gtk-doc, but now I'm getting always this crash when running gtkdoc-fixxref

Traceback (most recent call last):
  • File "/home/cgarcia/gnome/bin/gtkdoc-fixxref", line 57 in <module>
    fixxref.Run(options)
  • File "/home/cgarcia/gnome/share/gtk-doc/python/gtkdoc/fixxref.py", line 114 in Run
    FixCrossReferences(options)
  • File "/home/cgarcia/gnome/share/gtk-doc/python/gtkdoc/fixxref.py", line 217 in FixCrossReferences
    FixHTMLFile(options, full_entry)
  • File "/home/cgarcia/gnome/share/gtk-doc/python/gtkdoc/fixxref.py", line 236 in FixHTMLFile
    repl_func, content, flags=re.DOTALL)
  • File "/usr/lib/python2.7/re.py", line 155 in sub
    return _compile(pattern, flags).sub(repl, string, count)
  • File "/home/cgarcia/gnome/share/gtk-doc/python/gtkdoc/fixxref.py", line 233 in repl_func
    return HighlightSourceVim(options, m.group(1), m.group(2))
  • File "/home/cgarcia/gnome/share/gtk-doc/python/gtkdoc/fixxref.py", line 382 in HighlightSourceVim
    subprocess.check_call([script], shell=True)
  • File "/usr/lib/python2.7/subprocess.py", line 186 in check_call
    raise CalledProcessError(retcode, cmd)
ubprocess.CalledProcessError: Command '["echo 'let html_number_lines=0|let html_use_css=1|let html_use_xhtml=1|e /tmp/tmpKs6YKo.h|syn on|set syntax=c|run! syntax/2html.vim|w! /tmp/tmpKs6YKo.h.html|qa!' | /usr/bin/vim -n -e -u NONE -T xterm >/dev/null"]' returned non-zero exit status 1

I tried to run the vim command to see why it fails and it seems to fail because of a problem with 2html.vim when plugins are not loaded:

Error detected while processing /usr/share/vim/vim80/syntax/2html.vim:
line 725:
E121: Undefined variable: g:loaded_2html_plugin
E116: Invalid arguments for function extend

I don't know anything about vim, and I don't understand the 2html.vim syntax. The only way I managed to "fix" it was by removing the -u NONE from the vim command line in fixxref.py. With that it doesn't crash, but for some reason a lot of empty lines are added before and after the code in all program listings in the html output.
Comment 1 Carlos Garcia Campos 2017-09-10 09:30:31 UTC
I don't know if the empty lines problem is related to this crash, because I upgraded gtk-doc to see if current master would fix the crash, so the empty lines could be preexisting. See these examples:

https://webkitgtk.org/reference/webkit2gtk/2.17.92/WebKitWebView.html#webkit-web-view-run-javascript-finish
https://webkitgtk.org/reference/webkit2gtk/2.17.92/WebKitSettings.html#WebKitSettings.object-hierarchy
Comment 2 Wataru Shimizu 2017-09-30 07:53:19 UTC
I'm a newbie of GTK-Doc, but I also investigated this issue.

As you mentioned, 2html.vim can't run when -u NONE is specified. This is an issue of 2html.vim
and it has already been registered in:
https://github.com/vim/vim/issues/2135

I have confirmed that the workaround mentioned in that ticket can solve crash issue. However,
the empty line problem still remains. I think this is another issue.

Another workaround is to use other highlight tool. GTK-Doc has build option to specify highlight
tool (--with-highlight=(no|source-highlight|highlight|vim|auto)). On my environment, GTK-Doc 1.26
with source-hilight can work without problem.
Comment 3 Wataru Shimizu 2017-10-03 13:29:05 UTC
Created attachment 360836 [details]
sample code to reproduce

Sample for this issue.
See README.txt in the archive to reproduce.
Comment 4 Stefan Sauer (gstreamer, gtkdoc dev) 2017-10-25 19:22:40 UTC
Hmm, it works for me, but I am on an old distro:

echo 'let html_number_lines=0|let html_use_css=1|let html_use_xhtml=1|e ./tests/annotations/src/tester.h|syn on|set syntax=c|run! syntax/2html.vim|w! /tmp/x.html|qa!' | /usr/bin/vim -n -e -u NONE -T xterm

I've tried a few different .h files and the resulting /tmp/x.html look good to me. Can someone post a patch for the workaround? If I understood right, we should just prepend "run! plugin/tohtml.vim|" to the command?
Comment 5 Wataru Shimizu 2017-10-28 13:49:40 UTC
I checked on Ubuntu-16.04 (amd64). The following command looks work, but the return value is 1.  Adding "run! plugin/tohtml.vim" can fix it.

echo 'let html_number_lines=0|let html_use_css=1|let html_use_xhtml=1|e test.c|syn on|set syntax=c|run! syntax/2html.vim|w! out.html|qa!' | /usr/bin/vim -n -e -u NONE -T xterm
# => 1

echo 'let html_number_lines=0|let html_use_css=1|let html_use_xhtml=1|e test.c|syn on|set syntax=c|run! plugin/tohtml.vim|run! syntax/2html.vim|w! out.html|qa!' | /usr/bin/vim -n -e -u NONE -T xterm
# => 0

However, it can't fix the empty line issue.
Comment 6 Stefan Sauer (gstreamer, gtkdoc dev) 2017-11-01 20:48:18 UTC
Are the empty lines visible? Can you attach a sample html file? I can maybe trim leading/trailing blank lines.
Comment 7 Wataru Shimizu 2017-11-06 14:29:24 UTC
Created attachment 363058 [details]
HTML file generated by gtk-doc-1.26 with vim

This is the result of gtk-doc-1.26 (with vim) on Ubuntu-16.04.
See the code snippet in SampleGreeter.html.
Comment 8 Stefan Sauer (gstreamer, gtkdoc dev) 2017-11-24 20:16:55 UTC
Thanks for the example. Should be fixed now.

commit 69242948f7acf2a99a78c05808a18c9dc4d56674 (HEAD -> master, origin/master, origin/HEAD)
Author: Stefan Sauer <ensonic@users.sf.net>
Date:   Fri Nov 24 21:14:24 2017 +0100

    fixxref: fix vim syntax highlighting
    
    Update the vim command script. Also fix cutting out the highlighted part
    from the output.
    
    Fixes #787495
Comment 9 Tomasz Miąsko 2017-12-18 14:12:00 UTC
Last commit also accidentally changed the output file from %s.html to out.html,
and now highlighting results in runtime error:
TypeError: not all arguments converted during string formatting
Comment 10 Stefan Sauer (gstreamer, gtkdoc dev) 2017-12-18 14:59:14 UTC
It would be awesome if I'd get a patch next time and not some bits and pieces taht I needs to manually assemble. I'll fix it and push another realse, but maybe it is time to use an actual syntax hilighter instead.

Tomaz, thanks for testing.
Comment 11 Stefan Sauer (gstreamer, gtkdoc dev) 2017-12-18 15:04:17 UTC
commit 023792b001890a1eb7e71c16029acf7b63c7b285 (HEAD -> master, origin/master, origin/HEAD)
Author: Stefan Sauer <ensonic@users.sf.net>
Date:   Mon Dec 18 16:00:51 2017 +0100

    fixxref: restore the %s for the output file.
    
    Apparently this is not as widely used, since no one noticed this for a bit.
    See https://bugzilla.gnome.org/show_bug.cgi?id=787495