Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add documentation to a function when building a NuGet package

I'm building an internal NuGet package for work, and I want to make it as easy to use as possible.

How do I include function definitions and descriptions for exposed methods in the NuGet package?

I'm going for something similar to this: enter image description here

Is there something I need to add to my package to provide those details of what the function does?

Extra points for explaining how to do it using the Nuget package explorer tool.

like image 587
itcropper Avatar asked Jan 31 '17 19:01

itcropper


People also ask

How do I add a reference to a NuGet package?

After you install a NuGet package, you can then make a reference to it in your code with the using <namespace> statement, where <namespace> is the name of package you're using. After you've made a reference, you can then call the package through its API.

Should I include PDB files in NuGet package?

Actually you should add -Symbols to the end of command to create a symbols package. You shouldn't add pdb files to main nuget package.

Do I need a Nuspec file?

nuspec file is not required to create packages for SDK-style projects (typically . NET Core and . NET Standard projects that use the SDK attribute).


1 Answers

This type of documentation is added via XML documentation comments. When you compile with the Generate XML Documentation option enabled, an XML file is created next to your DLL that includes the documentation. You can include that in your .nuspec file to distribute it with your library, and Visual Studio will pick it up automatically.

On your functions, just include the tags you want in the /// block:

/// <summary>  
///  Returns "Hello World!"  
/// </summary>  
/// <remarks>This function is pretty useless, actually.</remarks>
public string HelloWorld() 

There are a number of common and recommended tags you can use. Visual Studio should be able to give you some Intellisense on these.

When you're building the package, enable the Generate XML Documentation option, and include the generated XML file in the nuspec file, as described in this question: How do you include Xml Docs for a class library in a NuGet package?

like image 125
Nate Barbettini Avatar answered Sep 19 '22 19:09

Nate Barbettini