Auto generate function documentation in Visual Studio

后端 未结 8 1822
醉梦人生
醉梦人生 2020-12-13 01:43

I was wondering if there is a way (hopefully keyboard shortcut) to create auto generate function headers in visual studio.

Example:

Private Function          


        
相关标签:
8条回答
  • 2020-12-13 02:07

    Visual Assist has a nice solution too, and is highly costumizable.

    After tweaking it to generate doxygen-style comments, these two clicks would produce -

    /**
    * Method:    FindTheFoo
    * FullName:  FindTheFoo
    * Access:    private 
    * Qualifier:
    * @param    int numberOfFoos
    * @return   bool
    */
    private bool FindTheFoo(int numberOfFoos)
    {
    
    }
    

    (Under default settings, its a bit different.)


    Edit: The way to customize the 'document method' text is under VassistX->Visual Assist Options->Suggestions, select 'Edit VA Snippets', Language: C++, Type: Refactoring, then go to 'Document Method' and customize. The above example is generated by:

    0 讨论(0)
  • 2020-12-13 02:10

    GhostDoc!

    Right-click on the function, select "Document this" and

    private bool FindTheFoo(int numberOfFoos)
    

    becomes

    /// <summary>
    /// Finds the foo.
    /// </summary>
    /// <param name="numberOfFoos">The number of foos.</param>
    /// <returns></returns>
    private bool FindTheFoo(int numberOfFoos)
    

    (yes, it is all autogenerated).

    It has support for C#, VB.NET and C/C++. It is per default mapped to Ctrl+Shift+D.

    Remember: you should add information beyond the method signature to the documentation. Don't just stop with the autogenerated documentation. The value of a tool like this is that it automatically generates the documentation that can be extracted from the method signature, so any information you add should be new information.

    That being said, I personally prefer when methods are totally selfdocumenting, but sometimes you will have coding-standards that mandate outside documentation, and then a tool like this will save you a lot of braindead typing.

    0 讨论(0)
提交回复
热议问题