Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just as followup to the comment to Olivier. Here is a copy of the macro now, look for the '' Do History section to see where I inserted code.</p> <pre><code> ''// InsertDocComments goes through the current document using the VS Code Model ''// to add documentation style comments to each function. '' Sub InsertDocComments() Dim projectItem As ProjectItem Dim fileCodeModel As FileCodeModel Dim codeElement As CodeElement Dim codeElementType As CodeType Dim editPoint As EditPoint Dim commentStart As String projectItem = DTE.ActiveDocument.ProjectItem fileCodeModel = projectItem.FileCodeModel codeElement = fileCodeModel.CodeElements.Item(1) ''// For the sample, don't bother recursively descending all code like ''// the OutlineCode sample does. Just get a first CodeType in the ''// file. If (TypeOf codeElement Is CodeNamespace) Then codeElement = codeElement.members.item(1) End If If (TypeOf codeElement Is CodeType) Then codeElementType = CType(codeElement, CodeType) Else Throw New Exception("Didn't find a type definition as first thing in file or find a namespace as the first thing with a type inside the namespace.") End If editPoint = codeElementType.GetStartPoint(vsCMPart.vsCMPartHeader).CreateEditPoint() ''// Make doc comment start. commentStart = LineOrientedCommentStart() If (commentStart.Length = 2) Then commentStart = commentStart &amp; commentStart.Chars(1) &amp; " " ElseIf (commentStart.Length = 1) Then commentStart = commentStart &amp; commentStart.Chars(0) &amp; commentStart.Chars(0) &amp; " " End If ''// Make this atomically undo'able. Use Try...Finally to ensure Undo ''// Context is close. Try DTE.UndoContext.Open("Insert Doc Comments") ''// Iterate over code elements emitting doc comments for functions. For Each codeElement In codeElementType.Members If (codeElement.Kind = vsCMElement.vsCMElementFunction) Then ''// Get Params. Dim parameters As CodeElements Dim codeFunction As CodeFunction Dim codeElement2 As CodeElement Dim codeParameter As CodeParameter codeFunction = codeElement editPoint.MoveToPoint(codeFunction.GetStartPoint(vsCMPart.vsCMPartHeader)) ''//editPoint.LineUp() parameters = codeFunction.Parameters ''// Do comment. editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) editPoint.LineUp() editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab &amp; commentStart &amp; "&lt;summary&gt;") editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab &amp; commentStart &amp; "Summary of " &amp; codeElement.Name &amp; ".") editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab &amp; commentStart &amp; "&lt;/summary&gt;") editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab &amp; commentStart) For Each codeElement2 In parameters codeParameter = codeElement2 editPoint.Insert("&lt;param name=" &amp; codeParameter.Name &amp; "&gt;&lt;/param&gt;") editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab &amp; commentStart) Next ''//param ''// Do history tag. editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) editPoint.LineUp() editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab &amp; commentStart &amp; "&lt;history&gt;") editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab &amp; commentStart &amp; "Name MM/DD/YYYY [Created]") editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab &amp; commentStart &amp; "&lt;/history&gt;") editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab &amp; commentStart) End If ''//we have a function Next ''//code elt member Finally DTE.UndoContext.Close() End Try End Sub </code></pre> <p>For some reason, after a save, rebuild, and a restart of Visual Studio, I'm not getting the history tag. Can anybody see something here I'm missing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload