Как я настраиваю автоматический текст комментария в Visual Studio?

Это может помочь вам добавить ссылку, как вы ожидали, на страницу.

if (window.location.origin === "red.abc.com") {
  var link = document.createElement('link');
  link.rel = 'stylesheet';
  link.href = window.location.origin + 'red.css';
  document.head.appendChild(link);
}
9
задан Dillie-O 15 September 2010 в 15:27
поделиться

3 ответа

Я предложил бы использовать GhostDoc. Это генерирует очень умные комментарии с помощью///на основе имен методов и параметров. Кроме того, это полностью настраиваемо.

11
ответ дан 4 December 2019 в 13:05
поделиться

Я думаю, что Вы могли использовать инструмент, как dgarcia сказал, но попытайтесь, выбрал тот, который делает управление версиями insetad, Лично я не огромный поклонник содержания "история" или дорожка проекта с помощью комментариев в коде.

Если Вам нравится этот способ, которым Вы могли бы создать свою собственную настроенную версию отрывка, это легче при использовании инструмента как Грубый

Скопируйте этот файл в Ваш

Мой Studio Documents\Visual 2005\Code отрывки [язык] \My кодирует Snippets\

Просто будьте осторожны для изменения файла, если Вы собираетесь использовать его в VB.NET

Надеюсь эта справка

3
ответ дан 4 December 2019 в 13:05
поделиться

Так же, как продолжение комментария Olivier. Вот копия макроса теперь, ищите '' раздел Do History для наблюдения, где я ввел код.

    ''// 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, я не получаю тег истории. Кто-либо может видеть что-то здесь, я отсутствую?

1
ответ дан 4 December 2019 в 13:05
поделиться
Другие вопросы по тегам:

Похожие вопросы: