C++ 在 Visual Studio 2010 中使用 Doxygen

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3864201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 13:55:32  来源:igfitidea点击:

Using Doxygen with Visual Studio 2010

c++visual-studio-2010documentationdoxygen

提问by Sven

I have difficulties efficiently using Doxygen with Visual Studio 2010 and C++.

我在将 Doxygen 与 Visual Studio 2010 和 C++ 一起使用时遇到了困难。

Is there no other function for commenting than "un/comment lines"? For example generating comment stubs, and adding ///after a new line.

除了“un/comment lines”之外,没有其他评论功能吗?例如生成注释存根,并///在新行之后添加。

Also, I wonder what is needed to display those Comments within the IntelliSense feature in VS2010?

另外,我想知道在 VS2010 的 IntelliSense 功能中显示这些评论需要什么?

采纳答案by Velociraptors

According to the MSDN Documentation, any comments using //or /*delimiters will be displayed next to the associated member in the IntelliSense Members list.

根据MSDN 文档,任何使用///*分隔符的注释都将显示在 IntelliSense 成员列表中的关联成员旁边。

You can use doxygen's XML output or the XML documentationgenerated by Visual Studio as IntelliSense input.

您可以使用 doxygen 的 XML 输出或Visual Studio 生成的XML 文档作为 IntelliSense 输入。

The /docdocumentationexplains how to use XML documentation with IntelliSense:

/doc文档解释了如何将 XML 文档与 IntelliSense 结合使用:

To use the generated .xml file with IntelliSense, make the file name of the .xml file the same as the assembly that you want to support and put the .xml file is in the same directory as the assembly. When the assembly is referenced in the Visual Studio project, the .xml file is also found.

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

AtomineerUtilsis one of the best Visual Studio add-ins for doxygen/javadoc/DocXML documentation. It's not free, but nothing on the list of doxygen helper toolsis targeted at Visual Studio 2010.

AtomineerUtils是用于 doxygen/javadoc/DocXML 文档的最佳 Visual Studio 插件之一。它不是免费的,但doxygen 帮助工具列表中的任何内容都没有针对 Visual Studio 2010。

回答by enriched

The best that I have been able to come up with on my own has been a collection of macros. I have looked around for websites that may have aggregated some useful Visual Studio doxygen macros together, but so far have come up empty. But, using Visual Studio's code model to auto-populate the documentation can be really handy. Here is a macro that I made to create documentation for the function that the caret is currently in:

我自己能想出的最好的东西是宏的集合。我已经环顾四周,寻找可能将一些有用的 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

Feel free to edit or reuse this macro, and I welcome any critiques.

随意编辑或重用这个宏,我欢迎任何批评。