【发布时间】:2016-10-21 10:20:41
【问题描述】:
我有一个带有 4 个类型参数的特征:Decoder[E, D, F, T](其中E 描述编码类型,D 解码类型,F 失败类型,T 是用于标记的幻像类型解码器实例)。
定义自定义Decoder 实例的每个项目还为它们定义了类型别名。例如:CellDecoder[Int] 是 Decoder[String, Int, DecodeError, csv.type] 的类型别名。
还有一个额外的 trait,DecoderCompanion[E, F, T],它为自定义 Decoder 实例的伴随对象定义了有用的方法。因此,例如,CellDecoder 伴随对象将扩展 DecoderCompanion[String, DecodeError, csv.type]。
举个具体的例子,这可能是这样的:
trait DecoderCompanion[E, F, T] {
def apply[F](implicit dec: Decoder[E, D, F, T]): Decoder[E, D, F, T] = dec
}
object CellDecoder extends DecoderCompanion[String, DecodeResult, csv.type]
在为CellDecoder 生成 API 文档时,scaladoc 无法确定它应该用CellDecoder[D] 替换所有Decoder[String, D, DecodeResult, csv.type] 实例。读者会期望CellDecoder.apply 产生CellDecoder,而不是Decoder——他们甚至可能不知道存在这种类型。
我明白为什么,或者至少为什么这不是默认行为。我想知道是否有办法改变这种行为,无论是作为 scaladoc 标志还是类型级别的诡计?
【问题讨论】: