简体   繁体   English

如何在构建NuGet包时向函数添加文档

[英]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. 我正在构建一个内部NuGet包用于工作,我想让它尽可能易于使用。

How do I include function definitions and descriptions for exposed methods in the NuGet package? 如何在NuGet包中包含暴露方法的函数定义和描述?

I'm going for something similar to this: 我要找类似的东西: 在此输入图像描述

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. 使用Nuget包资源管理器工具解释如何执行此操作的额外要点。

This type of documentation is added via XML documentation comments . 通过XML文档注释添加此类文档 When you compile with the Generate XML Documentation option enabled, an XML file is created next to your DLL that includes the documentation. 在启用“生成XML文档”选项的情况下进行编译时,会在DLL旁边创建一个包含文档的XML文件。 You can include that in your .nuspec file to distribute it with your library, and Visual Studio will pick it up automatically. 您可以将它包含在.nuspec文件中,以便将其与您的库一起分发,Visual Studio将自动提取它。

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. Visual Studio应该能够为您提供一些Intellisense。

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? 在构建程序包时,启用“生成XML文档”选项,并将生成的XML文件包含在nuspec文件中,如此问题中所述: 如何在NuGet包中包含类库的Xml Docs?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM