如何从Scala的标准库继承Scaladoc? [英] How do I inherit Scaladoc from Scala's standard library?

查看:173
本文介绍了如何从Scala的标准库继承Scaladoc?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我理解正确,则Scaladoc的一个方法应该自动继承其覆盖的父方法的Scaladoc。这似乎适用于本地的一组课程,但是从Scala的标准库(可能还有任何外部的依赖关系)扩展时不是这样。

If I understand correctly, the Scaladoc of a method should automatically inherit the Scaladoc of the parent method it overrides. This seems to hold true for a local set of classes, but not when extending from Scala's standard library (and presumably any external dependency?).

class LocalParent {
  /**
   * some documentation
   */
  def foo = ???
}

class DocumentedChild extends LocalParent

class UndocumentedChild extends Iterator[Int] {
   def hasNext = ???
   def next = ???
}

有没有办法继承Scaladoc?或者我做错了?

Is there a way to inherit the Scaladoc? Or am I doing something wrong?

另外,我使用 sbt doc ,所以不是$ code> scaladoc 直接。

Also, I'm using sbt doc, so not scaladoc directly.

推荐答案

这是我使用的(SBT 0.13):

Here's what I use (SBT 0.13):

scalacOptions in (Compile, doc) ++=
  Seq("-diagrams",
      "-diagrams-max-classes",
      "20",
      "-external-urls:java=http://docs.oracle.com/javase/6/docs/api/," +
      "scala=http://www.scala-lang.org/api/current/")

附录1:

为了解决在重写方法并希望重写方法的文档注释时对标准库类进行子类化的问题,可以使用继承文档标签:

To address the issue of subclassing standard library classes while overriding methods and wanting the overridden method's documentation comment, members can be commented with the inherit documentation tag:

/** @inheritdoc */
override def foo(bar: String): Int = bar.length

附录2:

这个功能更现代化的形式记录在此SBT 0.13文档页面

The more modern form of this functionality is documented on this SBT 0.13 documentation page.

这篇关于如何从Scala的标准库继承Scaladoc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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