带有接口和实现类的 XML 文档注释

发布于 2024-07-17 06:38:27 字数 1436 浏览 14 评论 0原文

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

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

发布评论

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

评论(4

你的呼吸 2024-07-24 06:38:27

我有一个更好的答案:FiXml

使用 GhostDoc \ AtomineerUtils 克隆注释当然是可行的方法,但它有明显的缺点,例如:

  • 当原始注释被更改时(这经常发生)发生在开发过程中),
    它的克隆不是。
  • 您正在生成大量重复项。 如果您正在使用任何
    源代码分析工具(例如 Team City 中的 Duplicate Finder),它将
    主要查找您的评论。

正如前面提到的,Sandcastle< 中有 标记/a>,但与 FiXml 相比,它有一些缺点:

  • Sandcastle 生成编译的 HTML 帮助文件 - 它不会修改 .xml 文件
    包含提取的 XML 注释。 但这些文件被许多工具使用,
    包括 Visual Studio .NET 中的 .NET Reflector 和类浏览器 \ IntelliSense。
    因此,如果您只使用 Sandcastle,您将不会在那里看到继承的文档。
  • Sandcastle 的实现功能不太强大。 例如,没有
    <参见...copy="true"/>

请参阅 Sandcastle 的 描述 了解更多详细信息。

FiXml简介:它是由C#\Visual Basic .Net生成的XML文档的后处理器。 它作为 MSBuild 任务实现,因此很容易将其集成到任何项目中。 它解决了与用这些语言编写 XML 文档相关的一些恼人的情况:

  • 不支持从基类或接口继承文档。即任何重写成员的文档都应该从头开始编写,尽管通常情况下这很麻烦至少希望继承其中的一部分。
  • 不支持插入常用的文档模板,例如“此类型是单例 - 使用其 属性来获取唯一的它的实例。”,甚至“初始化 类的新实例。”

为了解决上述问题,提供了以下附加 XML 标记:

  • 标记 <
  • see cref="..." copy=" ...” 标记中的/> 属性。

这是其网页下载页面

I have a better answer: FiXml.

Cloning comments with GhostDoc \ AtomineerUtils is certainly working approach, but it has significant disadvantages, e.g.:

  • When the original comment is changed (which frequently happens during development),
    its clone is not.
  • You're producing huge amount of duplicates. If you're using any
    source code analysis tools (e.g. Duplicate Finder in Team City), it will
    find mainly your comments.

As it was mentioned, there is <inheritdoc> tag in Sandcastle, but it has few disadvantages in comparison to FiXml:

  • Sandcastle produces compiled HTML help files - it doesn't modify .xml files
    containing extracted XML comments. But these files are used by many tools,
    including .NET Reflector and class browser \ IntelliSense in Visual Studio .NET.
    So if you use just Sandcastle, you won't see inherited documentation there.
  • Sandcastle's implementation is less powerful. E.g. the is no
    <see ... copy="true" />.

See Sandcastle's <inheritdoc> description for further details.

Short description of FiXml: it is a post-processor of XML documentation produced by C# \ Visual Basic .Net. It is implemented as MSBuild task, so it's quite easy to integrate it to any project. It addresses few annoying cases related to writing XML documentation in these languages:

  • No support for inheriting the documentation from base class or interface. I.e. a documentation for any overridden member should be written from scratch, although normally it’s quite desirable to inherit at least the part of it.
  • No support for insertion of commonly used documentation templates, such as “This type is singleton - use its <see cref="Instance" /> property to get the only instance of it.”, or even “Initializes a new instance of <CurrentType> class.”

To solve mentioned issues, the following additional XML tags are provided:

  • <inheritdoc />, <inherited /> tags
  • <see cref="..." copy="..." /> attribute in <see/> tag.

Here is its web page and download page.

怎樣才叫好 2024-07-24 06:38:27

Sandcastle 中似乎不支持此类自动文档。 Sandcastle 帮助文件生成器 不过实现了自定义的heritdoc 标记。

来自 SHFB 网站:

支持包括
<继承文档/>> 标签允许您
从基础继承文档
类型/成员。 这是通过以下方式实现的
一个独立的工具,所以它也可以
由其他第三方工具使用以及
构建脚本。 该工具提供
超出那些发现的功能
构建组件提供
沙堡。

第二次更新:根据此工作项 ,Sandcastle 对inheritdoc 的“支持”是通过SHFB 工具实现的。 我认为最重要的是,SHFB 解决了您的问题。

There seems to not be any support for such autodocumentation in Sandcastle. The Sandcastle Help File Builder though implements a custom inheritdoc tag.

From the SHFB site:

Support is included for the
<inheritdoc /> tag which allows you to
inherit documentation from base
types/members. This is implemented via
a standalone tool so it can also be
used by other third-party tools and
build scripts. This tool provides
features beyond those found in the
build component supplied with
Sandcastle.

Second Update: according to this workitem, the Sandcastle "support" for inheritdoc is through the SHFB tool. Bottom line I suppose is, SHFB solves your problem.

梦回梦里 2024-07-24 06:38:27

当您使用键盘时,诸如 GhostDoc 之类的工具可以生成有关实现类的文档捷径。 这并不是完全自动的,但可以帮助防止过多的复制粘贴。

也许它可以通过脚本自动化。

A tool such as GhostDoc can generate the documentation on the implementing classes, when you use it's keyboard shortcut. That is not entirely automatic, but could help prevent too much copy pasting.

Perhaps it could be automized with a script.

初心未许 2024-07-24 06:38:27

AtomineerUtils 将为您自动生成注释,并从重载和重写的基类中获取现有文档,从而为您节省在需要的地方复制信息的麻烦。

http://www.atomineer.com/AtomineerUtils.html

AtomineerUtils will auto-generate comments for you, and it picks up existing documentation from overloads and overridden base class, saving you loads of hassle in duplicating the information where it's needed.

http://www.atomineer.com/AtomineerUtils.html

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