Python中Doxygen样式文档字符串的Vim语法突出显示 [英] Vim syntax highlighting of doxygen style docstrings in Python

查看:95
本文介绍了Python中Doxygen样式文档字符串的Vim语法突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用 doxygen 来生成我的Python代码的文档。
我使用 doxypy 过滤器预处理Python文档字符串。
我的目标是在Python中对doxygen注释进行语法突出显示。

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 highlighting of doxygen comments in Python.

在专用.dox中编写 mainpage 时文件,我发现doxygen注释可以在 vim 中使用以下命令突出显示:

When writing my mainpage in a dedicated .dox file, I found that the doxygen comments can be highlighted in vim with the following command:

set syntax=c.doxygen

我在Python上尝试了相同的命令,但没有得到:
设置语法= python.doxygen

I tried the same command for Python but I got nothing: set syntax=python.doxygen

我也进行了谷歌搜索,找不到任何有趣的东西

I also made some googling and couldn't find anything interesting

我想强调的典型代码是:

Here is a typical piece of code I'd like to highlight:

class CompilationTab:
    """
    The compilation tab of the verif GUI. It contains the layout description
    and the functions required to deal with specific behaviors of the tab
    """
    def __init__(self, notebook, tab_name):
        """
        The class constructor.

        @param notebook Notebook: The parent @c Notebook widget
        @param tab_name String: The display name of the tab
        """

有人已经解决了这个问题吗?
谢谢您的帮助!

Does anybody already fixed this issue? Thank you for help!

推荐答案

如果您查看 syntax / doxygen.vim ,您可以在文件的序言中阅读当前仅

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

文件受支持。

doxygen.vim syn区域命令非常配合,我搜索了定义<$中多行字符串的行。 c $ c> syntax / python.vim 。

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

由此衍生出 doxygen.vim中的内容和上面的行,您可以添加以下行

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

〜/ .vim /after/syntax/python.vim 或手动执行它们。

此外,您可能必须自定义添加的doxygen高亮显示的颜色

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.

也许是 foldmethod 设置为<$ c $,则 syn 命令的$ c>参数特别有用。 c>语法,您可以折叠和展开多行注释,如果您不再能忍受这些颜色的视图而懒于调整它们,这似乎很有用:)

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 :)

没有突出显示氧气:

具有突出显示的doxygen和 g:doxygen_enhanced_color == 1

with doxygen highlighting and g:doxygen_enhanced_color == 1:

这篇关于Python中Doxygen样式文档字符串的Vim语法突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆