Scaladoc [用例] [英] Scaladoc [use case]

查看:50
本文介绍了Scaladoc [用例]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么Scaladoc中的一些方法描述以[use case]开头?

Why do some method descriptions in Scaladoc start with [use case]?

示例:scala.collection.immutable.StringOps.++

只是一个占位符,以后会被替换吗?

Is it just a placeholder to be replaced in the future?

推荐答案

它们是如何调用这些方法的简化示例.通常这些方法(++mapflatMap 等)包含一个隐式参数,最常见的是一个称为构建器工厂的参数(简单地说)抽象结果集合的创建.

They are simplified examples of how these methods are called. Usually these methods (++, map, flatMap, etc.) contain an implicit parameter, most often an argument called a builder factory which (simply put) abstracts creation of resulting collections.

在大多数情况下,集合的客户端不会指定这些隐式参数,因此 ScalaDoc 允许定义方法的简化描述 - 用例.这使用户能够快速掌握所讨论方法背后的想法,而不会被什么东西所困扰,例如,什么是问题. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .CanBuildFrom 意味着以及它的使用方式.

In most cases, a client of a collection does not specify these implicit parameters, so ScalaDoc allows defining a simplified description of the method - a use case. This enables users to quickly pick up the idea behind the method in question, and not be bothered with what e.g. CanBuildFrom means and how it's used.

例如,这是++的完整声明:

For example, this is the full declaration of ++:

def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That

在大多数情况下,目标集合类型与调用的接收者相同,因此调用几乎看起来好像声明如下(假设 ++ 在 a 上定义,比如说,List):

In most cases, the target collection type is the same as the receiver of the call, so the call pretty much looks as if the declaration is the following (assuming ++ is defined on a, say, List):

def ++(that: TraversableOnce[A]): List[A]

以上,隐式是在编译时解析的,类型参数是推断出来的.在大多数情况下,这应该是客户对方法的看法.

Above, the implicit is resolved at compile time, and the type parameters are inferred. In most cases, this should be the client's view of the method.

如果您想用用例注释自己的方法,请在文档注释中使用 @usecase 标签:

And if you want to annotate your own method with use cases, use the @usecase tag in your doc comments:

/** ...
 *  ...
 *  @usecase def ++(that: TraversableOnce[A]): List[A]
 */

这篇关于Scaladoc [用例]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆