Is there a standard (like phpdoc or python's docstring) for commenting C# code?

前端 未结 6 1603
遇见更好的自我
遇见更好的自我 2021-01-03 20:12

Is there a standard convention (like phpdoc or python\'s docstring) for commenting C# code so that class documentation can be automatically generated from the source code?

相关标签:
6条回答
  • 2021-01-03 20:37

    C# has built in documentation commands Have fun!

    0 讨论(0)
  • 2021-01-03 20:43

    You can use XML style comments, and use tools to pull those comments out into API documentation.

    Here is an example of the comment style:

    /// <summary>
    /// Authenticates a user based on a username and password.
    /// </summary>
    /// <param name="username">The username.</param>
    /// <param name="password">The password.</param>
    /// <returns>
    /// True, if authentication is successful, otherwise False.
    /// </returns>
    /// <remarks>
    /// For use with local systems
    /// </remarks>
    public override bool Authenticate(string username, string password)
    

    Some items to facilitate this are:

    GhostDoc, which give a single shortcut key to automatically generate comments for a class or method. Sandcastle, which generates MSDN style documentation from XML comments.

    0 讨论(0)
  • Microsoft uses "XML Documentation Comments" which will give IDE intellisense descriptions and also allow you to auto-generate MSDN-style documentation using a tool such as Sandcastle if you turn on the generation of the XML file output.

    To turn on the generation of the XML file for documentation, right click on a project in visual studio, click "Properties" and go to the "Build" tab. Towards the bottom you can specify a location for your XML comments output file.

    0 讨论(0)
  • 2021-01-03 20:48

    The previous answers point out the XML syntax perfectly. I just wanted to throw in my recommendation for the free (and open-source) nDoc help library generator that parses all comments in a project.

    0 讨论(0)
  • 2021-01-03 20:55

    I was always told to use block comments opened with 2 or more asterisks do delimit documentation comments.

    /**
    Documentation goes here.
    (flowerboxes optional) 
    */
    
    0 讨论(0)
  • 2021-01-03 20:57
    /// <summary>
    ///
    /// </summary>
    /// <param name="strFilePath"></param>
    

    http://msdn.microsoft.com/en-us/magazine/cc302121.aspx

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