在 Visual Studio 中自动生成函数文档
我想知道是否有一种方法(希望是键盘快捷键)在 Visual Studio 中创建自动生成函数头。
示例:
Private Function Foo(ByVal param1 As String, ByVal param2 As Integer)
它会自动变成这样......
'----------------------------------
'Pre:
'Post:
'Author:
'Date:
'Param1 (String):
'Param2 (Integer):
'Summary:
Private Function Foo(ByVal param1 As String, ByVal param2 As Integer)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
使“三个单一注释标记”
在 C# 中
默认为
///
:这里是 有关编辑 VS 模板的一些技巧。
Make that "three single comment-markers"
In C# it's
///
which as default spits out:
Here's some tips on editing VS templates.
GhostDoc!
右键单击该函数,选择“记录此”并
变为
(是的,它都是自动生成的)。
它支持 C#、VB.NET 和 C/C++。 它默认映射到 Ctrl+Shift+D。
请记住:您应该将方法签名之外的信息添加到文档中。 不要仅仅停留在自动生成的文档上。 像这样的工具的价值在于它会自动生成可以从方法签名中提取的文档,因此您添加的任何信息都应该是新信息。
话虽这么说,我个人更喜欢方法完全自我记录,但有时您会拥有强制外部文档的编码标准,然后像这样的工具将为您节省大量的脑力打字。
GhostDoc!
Right-click on the function, select "Document this" and
becomes
(yes, it is all autogenerated).
It has support for C#, VB.NET and C/C++. It is per default mapped to Ctrl+Shift+D.
Remember: you should add information beyond the method signature to the documentation. Don't just stop with the autogenerated documentation. The value of a tool like this is that it automatically generates the documentation that can be extracted from the method signature, so any information you add should be new information.
That being said, I personally prefer when methods are totally selfdocumenting, but sometimes you will have coding-standards that mandate outside documentation, and then a tool like this will save you a lot of braindead typing.
是获取方法描述注释块的快捷方式。
但请确保在添加之前已写下函数名称和签名。
首先写下函数名称和签名。
然后在函数名称上方输入 ///
即可自动获取
is the shortcut for getting the Method Description comment block.
But make sure you have written the function name and signature before adding it.
First write the Function name and signature.
Then above the function name just type ///
and you will get it automatically
Visual Assist 也有一个不错的解决方案,并且高度可定制。
调整它以生成 doxygen 风格的注释后,这两次单击将产生 -
(在默认设置下,它有点不同。)
编辑:
自定义“文档方法”文本的方法是在VassistX->Visual Assist Options->Suggestions下,选择“编辑VA Snippets”,语言:C++,类型:Refactoring,然后进入“文档方法”并自定义。 上面的示例是通过以下方式生成的:
插入代码片段:将光标置于方法名称/签名中,alt+shift+q > 「文件方法」
Visual Assist has a nice solution too, and is highly customizable.
After tweaking it to generate doxygen-style comments, these two clicks would produce -
(Under default settings, its a bit different.)
Edit:
The way to customize the 'document method' text is under VassistX->Visual Assist Options->Suggestions, select 'Edit VA Snippets', Language: C++, Type: Refactoring, then go to 'Document Method' and customize. The above example is generated by:
To Insert The Snippet: with cursor in method name/signature, alt+shift+q > "document method"
通常,如果您在要注释的内容(方法、类)上方添加三个单个注释标记,Visual Studio 会自动创建它。
在 C# 中,这将是
///
。如果 Visual Studio 没有执行此操作,您可以在
并勾选
为 ///
Normally, Visual Studio creates it automatically if you add three single comment-markers above the thing you like to comment (method, class).
In C# this would be
///
.If Visual Studio doesn't do this, you can enable it in
and check
在 Visual Basic 中,如果您首先创建函数/子,然后在其上方的行中键入 ' 三次,它将自动生成相关的 xml 文档。 当您将鼠标悬停在智能感知中以及使用该功能时,也会显示这一点。
In visual basic, if you create your function/sub first, then on the line above it, you type ' three times, it will auto-generate the relevant xml for documentation. This also shows up when you mouseover in intellisense, and when you are making use of the function.
您可以使用代码片段插入您想要的任何行。
此外,如果您在函数标题上方的行中键入三个单引号 ('''),它将插入您可以填写的 XML 标题模板。
这些 XML 注释可以由文档软件解释,并且它们作为 assembly.xml 文件包含在构建输出中。 如果您将该 XML 文件与 DLL 一起保留并在另一个项目中引用该 DLL,则这些注释将在智能感知中可用。
You can use code snippets to insert any lines you want.
Also, if you type three single quotation marks (''') on the line above the function header, it will insert the XML header template that you can then fill out.
These XML comments can be interpreted by documentation software, and they are included in the build output as an assembly.xml file. If you keep that XML file with the DLL and reference that DLL in another project, those comments become available in intellisense.
我正在开发一个名为 Todoc 的开源项目,该项目会在保存文件时分析单词以自动生成正确的文档输出。 它尊重现有的评论,并且非常快速和流畅。
http://todoc.codeplex.com/
I'm working on an open-source project called Todoc which analyzes words to produce proper documentation output automatically when saving a file. It respects existing comments and is really fast and fluid.
http://todoc.codeplex.com/