在 Visual Studio 中自动生成函数文档

发布于 2024-07-12 01:50:55 字数 417 浏览 7 评论 0 原文

我想知道是否有一种方法(希望是键盘快捷键)在 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)

I was wondering if there is a way (hopefully keyboard shortcut) to create auto generate function headers in visual studio.

Example:

Private Function Foo(ByVal param1 As String, ByVal param2 As Integer)

And it would automagically become something like this...

'---------------------------------- 
'Pre: 
'Post:
'Author: 
'Date: 
'Param1 (String): 
'Param2 (Integer): 
'Summary: 
Private Function Foo(ByVal param1 As String, ByVal param2 As Integer)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

遮云壑 2024-07-19 01:50:55

使“三个单一注释标记”

在 C# 中

默认为 ///

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

这里是 有关编辑 VS 模板的一些技巧。

Make that "three single comment-markers"

In C# it's ///

which as default spits out:

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

Here's some tips on editing VS templates.

罗罗贝儿 2024-07-19 01:50:55

GhostDoc

右键单击该函数,选择“记录此”并

private bool FindTheFoo(int numberOfFoos)

变为

/// <summary>
/// Finds the foo.
/// </summary>
/// <param name="numberOfFoos">The number of foos.</param>
/// <returns></returns>
private bool FindTheFoo(int numberOfFoos)

(是的,它都是自动生成的)。

它支持 C#、VB.NET 和 C/C++。 它默认映射到 Ctrl+Shift+D

请记住:您应该将方法签名之外的信息添加到文档中。 不要仅仅停留在自动生成的文档上。 像这样的工具的价值在于它会自动生成可以从方法签名中提取的文档,因此您添加的任何信息都应该是新信息。

话虽这么说,我个人更喜欢方法完全自我记录,但有时您会拥有强制外部文档的编码标准,然后像这样的工具将为您节省大量的脑力打字。

GhostDoc!

Right-click on the function, select "Document this" and

private bool FindTheFoo(int numberOfFoos)

becomes

/// <summary>
/// Finds the foo.
/// </summary>
/// <param name="numberOfFoos">The number of foos.</param>
/// <returns></returns>
private bool FindTheFoo(int numberOfFoos)

(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.

南冥有猫 2024-07-19 01:50:55
///

是获取方法描述注释块的快捷方式。
但请确保在添加之前已写下函数名称和签名。
首先写下函数名称和签名。

然后在函数名称上方输入 ///

即可自动获取

在此处输入图像描述

///

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

enter image description here

请恋爱 2024-07-19 01:50:55

Visual Assist 也有一个不错的解决方案,并且高度可定制。

调整它以生成 doxygen 风格的注释后,这两次单击将产生 -

/**
* Method:    FindTheFoo
* FullName:  FindTheFoo
* Access:    private 
* Qualifier:
* @param    int numberOfFoos
* @return   bool
*/
private bool FindTheFoo(int numberOfFoos)
{

}

(在默认设置下,它有点不同。)


编辑:
自定义“文档方法”文本的方法是在VassistX->Visual Assist Options->Suggestions下,选择“编辑VA Snippets”,语言:C++,类型:Refactoring,然后进入“文档方法”并自定义。 上面的示例是通过以下方式生成的:

va_doxy

插入代码片段:将光标置于方法名称/签名中,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 -

/**
* Method:    FindTheFoo
* FullName:  FindTheFoo
* Access:    private 
* Qualifier:
* @param    int numberOfFoos
* @return   bool
*/
private bool FindTheFoo(int numberOfFoos)
{

}

(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:

va_doxy

To Insert The Snippet: with cursor in method name/signature, alt+shift+q > "document method"

薄凉少年不暖心 2024-07-19 01:50:55

通常,如果您在要注释的内容(方法、类)上方添加三个单个注释标记,Visual Studio 会自动创建它。

在 C# 中,这将是 ///

如果 Visual Studio 没有执行此操作,您可以在

选项->文本编辑器->C#->高级

并勾选

生成 /// 的 XML 文档注释

为 /// 图片描述

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

Options->Text Editor->C#->Advanced

and check

Generate XML documentation comments for ///

pictured description

情释 2024-07-19 01:50:55

在 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.

软甜啾 2024-07-19 01:50:55

您可以使用代码片段插入您想要的任何行。

此外,如果您在函数标题上方的行中键入三个单引号 ('''),它将插入您可以填写的 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.

折戟 2024-07-19 01:50:55

我正在开发一个名为 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文