Skip to content Skip to sidebar Skip to footer

Vim Syntax Highlighting Of Doxygen Style Docstrings In Python

I started working with doxygen to generate the documentation of my Python code. I use doxypy filter to preprocess the Python docstrings. My goal is to have a nice syntax highlighti

Solution 1:

If you look into syntax/doxygen.vim you can read in the preamble of the file that currently only

cpp,c, idl, doxygen and php

files are supported.

Since doxygen.vim works a lot with the syn region command i searched for the line that defines the multiline string in syntax/python.vim.

The interesting part of the command that defines this region is

syn region pythonString start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend

Derived from that what is in doxygen.vim and the above line you can add the following lines

"delete the following line if you don't want to have enhanced colors
let g:doxygen_enhanced_color=1
runtime! syntax/doxygen.vim
syn region doxygenComment matchgroup=pythonString start=+[uU]\=\z('''\|"""\)+end="\z1" contains=doxygenSyncStart,doxygenStart,doxygenTODO keepend fold containedin=pythonString

to ~/.vim/after/syntax/python.vim or execute them by hand.

In addition you may have to customize the colors of the added doxygen highlighting groups by hand. At least i would do so since the resulting look doesn't conform with my taste.

Perhaps the fold argument of the syn command is of special interest for you. If you set foldmethod to syntax you can fold and unfold the multiline comments. That seems to be useful if you could no longer stand the view of those colors and are to lazy to adjust them :)


without doxygen highlighting:

enter image description here

with doxygen highlighting and g:doxygen_enhanced_color == 1:

enter image description here

Post a Comment for "Vim Syntax Highlighting Of Doxygen Style Docstrings In Python"