使用Doxygen与Visual Studio 2010

12

我在使用Visual Studio 2010和C++时,使用Doxygen存在一些效率上的困难。

除了“取消/注释行”之外,是否还有其他的注释功能?例如生成注释桩,并在新行后添加///

此外,我想知道在VS2010的IntelliSense功能中显示这些注释所需的条件是什么?

2个回答

12
根据MSDN文档,使用///*分隔符的任何注释都将显示在IntelliSense成员列表中与其相关联的成员旁边。
您可以使用doxygen的XML输出或Visual Studio生成的XML文档作为IntelliSense输入。 /doc文档解释了如何在IntelliSense中使用XML文档:

要在IntelliSense中使用生成的.xml文件,请将.xml文件的文件名与要支持的程序集相同,并将.xml文件放在与程序集相同的目录中。当在Visual Studio项目中引用程序集时,也会找到.xml文件。

AtomineerUtils是最好的用于doxygen/javadoc/DocXML文档的Visual Studio插件之一。它不是免费的,但在doxygen助手工具列表中没有针对Visual Studio 2010的工具。

4
我自己想到的最好解决方案是一系列宏。我查找了一些可能已经聚合了一些有用的Visual Studio doxygen宏的网站,但是目前还没有找到。但是,使用Visual Studio的代码模型自动填充文档非常方便。以下是我创建的一个宏,用于为插入符号当前所在的函数创建文档:
Sub FunctionDoc()
    DTE.UndoContext.Open("Function Doc")
    Try
        Dim caretPosition As TextPoint = DTE.ActiveDocument.Selection.ActivePoint
        Dim element As CodeElement = _
            caretPosition.CodeElement(vsCMElement.vsCMElementFunction)
        If element.Kind <> vsCMElement.vsCMElementFunction Then
            MsgBox("That is not a function")
            Exit Sub
        End If
        Dim func As CodeFunction = element
        If func Is Nothing Then
            MsgBox("That is not a function")
            Exit Sub
        End If

        Dim ts As TextSelection = DTE.ActiveDocument.Selection
        ts.StartOfLine()
        ts.NewLine()
        ts.LineUp()
        Dim functionName As String = func.Name
        ts.Text = "//-----------------------------------------------------------------------------"
        ts.NewLine()
        ts.Text = "//  FUNCTION  "
        ts.Text = func.FullName
        ts.NewLine()
        ts.Text = "/// \brief    "
        Dim endline As Integer = ts.BottomPoint.Line
        Dim endoffset As Integer = ts.BottomPoint.LineCharOffset
        ts.NewLine()
        ts.Text = "///           "
        ts.NewLine()
        For Each param As CodeParameter In func.Parameters
            ts.Text = "/// \param    "
            ts.Text = param.Name
            ts.Text = ". "
            ts.NewLine()
        Next
        If func.Type.TypeKind <> vsCMTypeRef.vsCMTypeRefVoid Then
            ts.Text = "/// \return   "
            ts.Text = func.Type.AsFullName
            ts.Text = " "
            ts.NewLine()
        End If
        ts.Text = "//-----------------------------------------------------------------------------"
        ts.MoveToLineAndOffset(endline, endoffset)

    Finally
        DTE.UndoContext.Close()
    End Try
End Sub

欢迎编辑或重复使用此宏,我也欢迎任何批评意见。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接