是否有一个"最佳实践"来记录F#中的歧视联盟?我一直在使用MSDN网站上XML提供的标签,但没有提及记录除标签之外的DU .<typeparam name = "x"> Desc. </typeparam>
标签有助于标准类型和功能,但是哪些XML标签应该用于DU?
我大多只使用<summary>标签作为类型及其所有成员(因为编译器<summary>自动添加,这意味着我不必手动编写任何XML):
/// Represents a thumbnail that will appear on the movie web site
type MovieThumbnail =
/// Use a PNG image at the specified URL
| Image of string
/// Use a default image for the specified genre
| Default of Genre
Run Code Online (Sandbox Code Playgroud)
它可能只是我,但我发现归档所有其他标签只是太多的工作,它不会给你更多的信息.
如果您使用的是F#ProjectScaffold,那么文档工具也支持XML注释中的Markdown,因此您可以编写例如:
/// Represents a thumbnail that will appear on the movie web site
///
/// ## Example
/// The following shows simple pattern matching:
///
/// match movieThumb with
/// | Image(url) -> sprintf "<img src='%s' />" url
/// | Default(g) -> defaultImageFor g
///
type MovieThumbnail =
/// Use a PNG image at the specified URL
| Image of string
/// Use a default image for the specified genre
| Default of Genre
Run Code Online (Sandbox Code Playgroud)
目前,这在Visual Studio工具提示中并没有很好地显示,但是如果你正在编写一个库并希望有一个很好的文档,那么这是一个很好的方法来获得它.