GNOME Bugzilla – Bug 787495
gtkdoc-fixxref crashes when running vim for syntax highlighting
Last modified: 2017-12-18 15:04:17 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):
+ Trace 237946
fixxref.Run(options)
FixCrossReferences(options)
FixHTMLFile(options, full_entry)
repl_func, content, flags=re.DOTALL)
return _compile(pattern, flags).sub(repl, string, count)
return HighlightSourceVim(options, m.group(1), m.group(2))
subprocess.check_call([script], shell=True)
raise CalledProcessError(retcode, cmd)
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.
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
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.
Created attachment 360836 [details] sample code to reproduce Sample for this issue. See README.txt in the archive to reproduce.
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?
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.
Are the empty lines visible? Can you attach a sample html file? I can maybe trim leading/trailing blank lines.
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.
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
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
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.
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