C# 你把函数文档放在哪里,以便它显示在智能感知上?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1138004/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where do you put the function documentation so that it shows up on intellisense?
提问by Alex319
I'm writing a library and I want to put documentation in my functions so that it will show up in intellisense, kind of like how the intellisense for the built in functions shows descriptions for each of the parameters and for the function itself. How do you put the documentation in? Is it through comments in the function or is it in some separate file?
我正在编写一个库,我想将文档放在我的函数中,以便它显示在智能感知中,有点像内置函数的智能感知如何显示每个参数和函数本身的描述。你怎么把文件放进去?是通过函数中的注释还是在某个单独的文件中?
采纳答案by Brandon
回答by Richard
As well as the XML comments you need to enable building the documentation (in the project settings) and keep the generated XML file with the assembly.
除了 XML 注释外,您还需要启用构建文档(在项目设置中)并将生成的 XML 文件与程序集一起保存。
回答by smnbss
"XML Documentation Comments (C# Programming Guide)In Visual C# you can create documentation for your code by including XML tags in special comment fields in the source code directly before the code block they refer to."
“ XML 文档注释(C# 编程指南)在 Visual C# 中,您可以通过在源代码中的特殊注释字段中直接在它们引用的代码块之前包含 XML 标记来为您的代码创建文档。
http://msdn.microsoft.com/en-us/library/b2s063f7.aspx
http://msdn.microsoft.com/en-us/library/b2s063f7.aspx
you can then use Sandcastle to generate chm files too if you want
如果需要,您也可以使用 Sandcastle 生成 chm 文件
回答by Gustavo Ayala
To auto-generate the three-slash comment section on top of an existing method, just place the cursor on an empty line, right above the method definition and type three forward slashes ("///"). Visual Studio will auto-generate a three-slash comment that corresponds to your method. It will have placeholders for the summary, each parameter (if any) and the return value (if any). You just have to fill-in the blanks.
要在现有方法的顶部自动生成三斜线注释部分,只需将光标放在方法定义正上方的空行上,然后键入三个正斜线(“///”)。Visual Studio 将自动生成与您的方法相对应的三斜线注释。它将包含摘要、每个参数(如果有)和返回值(如果有)的占位符。你只需要填空。
I would recommend you don't try to write these description blocks by hand and not to copy from one method to another. Third-party tools are also not necessary to generate them (at least in Visual Studio 2010).
我建议您不要尝试手动编写这些描述块,也不要从一种方法复制到另一种方法。生成它们也不需要第三方工具(至少在 Visual Studio 2010 中)。