【问题标题】:Annotating Methods in Delphi?Delphi中的注释方法?
【发布时间】:2013-02-27 23:51:03
【问题描述】:

我有一段需要认真记录的代码,我想问一下 Embarcadero Delphi 是否可以使用类似于 C#/.NET 的 In-code XML-Documentation 的功能。 我的目标是显示一些关于如何正确使用特定方法的信息,就像在 Delphi XE3 的自动完成中突出显示的那样。

类似这样的东西(C#):

/// <summary>
/// Some useful information helping other developers use this method correctly
/// </summary>
public static void ADocumentedMethod();

Delphi XE3 是否支持这样的功能?

感谢您的阅读。

【问题讨论】:

  • 你有哪些 Delphi XE3 发行版?请您将这些信息包含在您的问题中吗?
  • @TLama 应该没关系,AFAIK /// XML-doc 自 D2010 以来可用,所有 SKU,虽然它似乎有点错误......
  • @ain,我说的是Documentation Insight,据我所知,在更便宜的 Delphi 发行版中存在很大的限制,不是吗?
  • 它也可以在 Delphi 2009 中使用。

标签: delphi documentation xml-documentation


【解决方案1】:

该功能名为 XML 文档注释,名称为 documented here。它似乎是在等效的 .net 功能上紧密建模的,因此您应该对它很熟悉。

文档包含此示例:

/// <summary> Removes the specified item from the collection
/// </summary>
/// <param name="Item">The item to remove
/// </param>
/// <param name="Collection">The group containing the item
/// </param>
/// <remarks>
/// If parameter "Item" is null, an exception is raised.
/// <see cref="EArgumentNilException"/>
/// </remarks>
/// <returns>True if the specified item is successfully removed;
/// otherwise False is returned.
/// </returns>
function RemoveItem(Item: Pointer; Collection: Pointer): Boolean;
begin
  // Non-XML DOC comment
  // ...
end;

这会导致此帮助洞察提示:

还有各种其他方式来处理和使用文档。

【讨论】:

  • 这太完美了!非常感谢!通过谷歌搜索没有找到这个我觉得有点愚蠢。
  • 此外,此 XML 文档应出现在单元的 interface 部分中,以便在外部单元中显示。
  • 注意,您也可以将 用于异常。问题是,洞察提示中未显示异常名称 (cref)。 (10.3 里约)。
猜你喜欢
  • 2013-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-20
  • 2010-11-14
  • 2018-02-23
  • 2020-03-29
相关资源
最近更新 更多