IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Visual Studio Discussion :

Personnaliser les commentaires XML Intellisense


Sujet :

Visual Studio

  1. #1
    Membre habitué Avatar de obitskater
    Profil pro
    Développeur .NET
    Inscrit en
    Février 2008
    Messages
    163
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Février 2008
    Messages : 163
    Points : 132
    Points
    132
    Par défaut Personnaliser les commentaires XML Intellisense
    Bonjour à tous,

    Je souhaiterai savoir s'il est possible de personnaliser les commentaires XML Intellisense que l'on met au dessus des méthodes, classes, variables membres, etc... qui par défaut met :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    /// <summary>
    /// ***
    /// </summary>
    /// <param name="***">***</param>
    Je voudrais par exemple que lorsque je tape 3 slash /// qu'il me génére les commentaires XML également de façon automatique mais avec des champs en plus, par exemple:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    ///<summary>
    ///
    ///</summary>
    ///<param name ="***">***</param>
    ///<author>***</author>
    ///<date>**/**/**</date>
    Si cela est possible qu'elle est la façon de le faire s'il vous plaît

  2. #2
    Inactif  
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Janvier 2007
    Messages
    6 604
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France

    Informations professionnelles :
    Activité : Chef de projet NTIC

    Informations forums :
    Inscription : Janvier 2007
    Messages : 6 604
    Points : 13 314
    Points
    13 314
    Par défaut
    Ben, écrire un add-in à Visual Studio.

    Je ne réponds pas aux questions techniques par MP ! Le forum est là pour ça...


    Une réponse vous a aidé ? utiliser le bouton

    "L’ennui dans ce monde, c’est que les idiots sont sûrs d’eux et les gens sensés pleins de doutes". B. Russel

  3. #3
    Membre habitué Avatar de obitskater
    Profil pro
    Développeur .NET
    Inscrit en
    Février 2008
    Messages
    163
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Février 2008
    Messages : 163
    Points : 132
    Points
    132
    Par défaut
    Salut BlueDeep,

    N'y a t-il pas un moyen plus simple pour cela?
    Car le template doit bien être présent quelque part dans les fichiers de VS. Ne suffira t'il pas alors de le compléter.
    C'est comme par exemple la commande "ctor" qui génére automatiquement le constructeur de la classe.

  4. #4
    Inactif  
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Janvier 2007
    Messages
    6 604
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France

    Informations professionnelles :
    Activité : Chef de projet NTIC

    Informations forums :
    Inscription : Janvier 2007
    Messages : 6 604
    Points : 13 314
    Points
    13 314
    Par défaut
    Citation Envoyé par obitskater Voir le message
    Salut BlueDeep,

    N'y a t-il pas un moyen plus simple pour cela?
    Car le template doit bien être présent quelque part dans les fichiers de VS. Ne suffira t'il pas alors de le compléter.
    C'est comme par exemple la commande "ctor" qui génére automatiquement le constructeur de la classe.
    C'est possible mais j'en doute un peu.

    Je ne réponds pas aux questions techniques par MP ! Le forum est là pour ça...


    Une réponse vous a aidé ? utiliser le bouton

    "L’ennui dans ce monde, c’est que les idiots sont sûrs d’eux et les gens sensés pleins de doutes". B. Russel

  5. #5
    Membre habitué Avatar de obitskater
    Profil pro
    Développeur .NET
    Inscrit en
    Février 2008
    Messages
    163
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Février 2008
    Messages : 163
    Points : 132
    Points
    132
    Par défaut
    Je vais jeter un coup d'oeil du côté des snippets, car créer un add-in ça a l'air pas mal complexe...

  6. #6
    Membre habitué Avatar de obitskater
    Profil pro
    Développeur .NET
    Inscrit en
    Février 2008
    Messages
    163
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Février 2008
    Messages : 163
    Points : 132
    Points
    132
    Par défaut
    Bon j'ai un peu avancé sur mes recherches, j'ai trouvé une macro Utilities.InsertDocComments.

    J'ai rajouté la partie pour ajouter la date au commentaire (cf : History day)

    Même en l'ayant modifiée, je n'ai toujours que les commentaires de bases... Dois-je faire quelque chose en plus?

    Voici le code de la macro

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    '' 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

  7. #7
    Membre habitué Avatar de obitskater
    Profil pro
    Développeur .NET
    Inscrit en
    Février 2008
    Messages
    163
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Février 2008
    Messages : 163
    Points : 132
    Points
    132
    Par défaut
    Bon finalement BlueDeep avait raison dès le début, je m'incline

    En fait je n'ai pas créé d'add-in, mais j'en utilise un trés trés utile que je ne connaissais pas: GhostDoc.

    Un add-in qui permet de générer automatiquement les commantaires pour la documentation XML, ou l'on peut peut personnaliser ses propres tags de commentaires. Un add-in à recommander!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. afficher les commentaires xml grâce à xsl
    Par jesemeatoutvent dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 29/04/2013, 15h17
  2. [C#][XML] Problème avec les commentaires XML
    Par xanass dans le forum C#
    Réponses: 5
    Dernier message: 14/03/2011, 16h14
  3. [JavaDoc] XML dans les commentaires javadoc
    Par La Truffe dans le forum Format d'échange (XML, JSON...)
    Réponses: 4
    Dernier message: 05/07/2007, 15h36
  4. Probleme sur les commentaire XML
    Par IGFP dans le forum EDI/Outils
    Réponses: 6
    Dernier message: 27/02/2007, 08h41
  5. Réponses: 2
    Dernier message: 02/12/2006, 21h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo