如何生成C#代码的注释行文档? [英] How to generate comment lines documentation of c# code ?

查看:68
本文介绍了如何生成C#代码的注释行文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何生成C#代码的注释行文档?
我在以下代码中有注释

///< summary>
//函数名称:abc
//说明:xyz
///< summary>

How to generate comment lines documentation of c# code ?
i have the comments in code like following

/// <summary>
// Function Name : abc
// Description : xyz
/// <summary>

推荐答案

这很遗憾,因为最简单的方法是使用内置的XML注释系统... http://msdn.microsoft.com/en-us/magazine/cc302121.aspx [ ^ ]-这是一篇旧文章,但可以为您带来灵感.

如果您使用XML注释(而且非常简单-只需在字段,方法定义的属性上方以"///"开头的空白行,其余部分就可以完成),那么您可以轻松地从中构建文档.作为额外的激励,XML注释也被转移到Intelisense中.

创建新项目时,我要做的第一件事就是打开XML强制执行:在项目属性"的生成"选项卡上,选中"XML文档文件"复选框.如果您未正确记录方法,则每次编译时都会收到警告.如果您还在同一选项卡上的将警告视为错误"下选中全部"单选按钮(就像我一样),那么除非您已正确记录了该程序,否则您甚至无法运行该程序.
That''s a pity, because the easiest way to do it is to use the built in XML comments system...http://msdn.microsoft.com/en-us/magazine/cc302121.aspx[^] - it''s an old article, but it gives you the idea.

If you use XML comments (and it''s very simple - just start a blank line with "///" above a field, property of method definition and it will do the rest) then you can build documentation from this very easily. And as an extra incentive, the XML comments are transferred into Intelisense as well.

One of the first things I do when I create a new project is to turn on XML enforcement: On the Build tab of the Project Properties, tick the XML Documentation file checkbox. You will then get warnings with each compilation where you haven''t documented a method properly. If you also check the "All" radio button under "Treat warnings as errors" on the same tab (as I do) then you can''t even run your program unless you have documented it correctly.


这似乎是自定义类型的评论.有不同的第三方加载项可以执行类似的操作.也可能是这是一个手工开发的评论系统.

如果您正在寻找C#中的内置文档注释,它们将如下所示:

That looks to be a custom type of commenting. There are different third-party addins that can do something similar. It may also be that this is a hand-developed commenting system.

If you are looking for the built-in documentation comments in C#, they would look like this:

/// <summary>
/// 
/// </summary>



您可以通过在方法或类上方的行上键入3次反斜杠字符来实现此目的(在其他两个地方也可以执行此操作).系统将自动生成此列表.如果在方法上方执行此操作,它将为该方法采用的每个参数添加参数行,并为该方法返回的内容添加返回行(如果它不返回void).

使用XML注释的好处是可以由Visual Studio拾取它们,并由系统的其余部分和自动化文档系统使用.



You get this by typing the backslash character three times on the line above a method or class (there are a couple other places you can do this as well). The system will auto-generate this list. If you are doing this above a method, it will add parameter lines for each parameter that the method takes as well as a return line for what the method returns (if it doesn''t return void).

The benefit of using the XML comments is that they can be picked up by Visual Studio and used by the rest of the system and by automated documentation systems.


这篇关于如何生成C#代码的注释行文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆