2009-01-08 2 views
9

Visual Studio에서 " '' '또는"/// "를 입력하여 자동 주석 기능을 트리거하면 대부분의 XML 주석 세부 정보가 표시됩니다. 그러나 일반적으로 문서에 히스토리 태그를 추가하여 시간이 지남에 따라 메소드를 추적하고 변경할 수 있습니다.Visual Studio에서 자동 주석 달기 텍스트를 어떻게 사용자 정의합니까?

자동 주석 기능을 사용자 정의하여 내역 태그를 추가하고 잠재적 인 일반 이름 - 날짜 - 자리 표시 자 텍스트를 변경할 수있는 방법이 있습니까?

답변

11

GhostDoc을 사용하시기 바랍니다. 메서드 이름과 매개 변수를 기반으로 ///를 사용하여 매우 스마트 한 주석을 생성합니다. 또한, 그것은 완벽하게 사용자 정의 할 수 있습니다.

+0

우수한 자료! 불행히도 우리는 여기서 VB 상점이고 GhostDoc은 VB.NET 코드에 대해 "실험적"으로 나열됩니다. 나는 집에서 내 자신의 C# 프로젝트에 북마크를 유지하고있다. 감사! –

+0

Doh> _ DavGarcia

+0

업데이트를 통해 GhostDoc 2.5는 VB.NET에서 주석 처리를 완벽하게 지원합니다. 나는 단순히 GhostDoc 옵션에 가서 (현재 날짜에 넣을 변수가있는) 내 기록 태그를 추가했는데 모두 설정되었습니다. –

3

dgarcia가 말했듯이 도구를 사용할 수 있다고 생각하지만 버전 제어를 insetad로 만드는 것을 선택하려고 시도합니다. 개인적으로 저는 "역사"또는 프로젝트의 트랙을 암호.

당신이 코드 조각 \ 비주얼 스튜디오 2005 \ 당신의

내 문서에 Snippy

Copy this file 같은 도구를 사용하는 경우 당신은 당신이 조각의 자신의 사용자 정의 버전을 만들 수있는 방법처럼이 쉽게 경우 당신이 거 VB.NET에

희망이 도움이 그것을 사용하는 경우 내 코드 조각 \ [언어]

\

그냥 파일을 변경주의 하시고

1

올리비에 (Olivier)에 대한 의견에 대한 후속 조치처럼. 여기에 매크로 사본이 있습니다. '코드 삽입 위치를 보려면'역사 작업 '섹션을 찾으십시오.

''// 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 & commentStart.Chars(1) & " " 
     ElseIf (commentStart.Length = 1) Then 
      commentStart = commentStart & commentStart.Chars(0) & commentStart.Chars(0) & " " 
     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 & commentStart & "<summary>") 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "Summary of " & codeElement.Name & ".") 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "</summary>") 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart) 

        For Each codeElement2 In parameters 
         codeParameter = codeElement2 
         editPoint.Insert("<param name=" & codeParameter.Name & "></param>") 
         editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) 
         editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart) 
        Next ''//param 

        ''// Do history tag. 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) 
        editPoint.LineUp() 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "<history>") 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "Name MM/DD/YYYY [Created]") 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "</history>") 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf) 
        editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart) 

       End If ''//we have a function 
      Next ''//code elt member 

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

Visual Studio를 저장, 다시 작성한 후 다시 시작한 후에도 기록 태그가 표시되지 않습니다. 아무도 내가 여기없는 걸 볼 수 있니?

+0

Sub보다 먼저 '' '를 입력 할 때 Visual Studio IDE에서 사용하는 매크로는 아닙니다. 매크로 탐색기에서 마우스 오른쪽 버튼을 클릭하고 실행을 선택하여 수정 된 매크로를 실행할 수 있습니다. 이렇게하면 주석이 이미 있는지 여부에 관계없이 모든 루틴 앞에 주석이 삽입됩니다. –

+0

흠, 시도할만한 것 같습니다. 실제 매크로 이름이 무엇인지에 대한 아이디어가 있습니까? –

1

vb는 xml 파일을 사용하여 오류를로드합니다. 그것은 VBXMLDoc.xml이며 파일의 위치와 관련하여 실행중인 버전에 따라 다릅니다.

관련 문제