开发者

Using Doxygen with Visual Studio 2010

I have 开发者_JAVA技巧difficulties efficiently using Doxygen with Visual Studio 2010 and C++.

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

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


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

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

The /doc documentation explains how to use XML documentation with 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.

AtomineerUtils is 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 tools is targeted at Visual Studio 2010.


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:

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜