如何消除scaladoc中方法链接的歧义?

编程入门 行业动态 更新时间:2024-10-25 08:20:45
本文介绍了如何消除scaladoc中方法链接的歧义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在用重载方法记录一个Scala类.在 Scaladoc 注释中提及它们时如何区分它们?例如,如果我有

I'm documenting a Scala class with overloaded methods. How can I distinguish them when referring to them in scaladoc comments? For example, if I have

/** * The most important method is [[Doc.foo]]. */ object Doc { def foo[A]: A = throw new UnsupportedOperationException; def foo[A,B >: A](x: A): B = x; }

并运行 sbt doc 我得到

Doc.scala:1:警告:链接目标Doc.foo"不明确.几个(可能超载)成员符合目标:

Doc.scala:1: warning: The link target "Doc.foo" is ambiguous. Several (possibly overloaded) members fit the target:

  • 方法 foo[A,B>:A](x:A):B 在对象文档 [选择]
  • 方法 foo[A]:Nothing 在对象文档中
  • method foo[A,B>:A](x:A):B in object Doc [chosen]
  • method foo[A]:Nothing in object Doc

使用 foo[A,B >: A] 等链接不起作用.

Using foo[A,B >: A] etc. to the link doesn't work.

推荐答案

以下内容似乎在 Scala 2.10 中有效.

The following seems do the trick in Scala 2.10.

/** * The most important method is [[Doc.foo[A]:A*]]. */

这是scaladoc给我的一些提示:

And here is some hint scaladoc gives me:

[warn] Quick crash course on using Scaladoc links [warn] ========================================== [warn] Disambiguating terms and types: Prefix terms with '$' and types with '!' in case both names are in use: [warn] - [[scala.collection.immutable.List!.apply class List's apply method]] and [warn] - [[scala.collection.immutable.List$.apply object List's apply method]] [warn] Disambiguating overloaded members: If a term is overloaded, you can indicate the first part of its signature followed by *: [warn] - [[[scala.collection.immutable.List$.fill[A](Int)(⇒A):List[A]* Fill with a single parameter]]] [warn] - [[[scala.collection.immutable.List$.fill[A](Int,Int)(⇒A):List[List[A]]* Fill with a two parameters]]] [warn] Notes: [warn] - you can use any number of matching square brackets to avoid interference with the signature [warn] - you can use \. to escape dots in prefixes (don't forget to use * at the end to match the signature!) [warn] - you can use \# to escape hashes, otherwise they will be considered as delimiters, like dots.

更多推荐

如何消除scaladoc中方法链接的歧义?

本文发布于:2023-11-07 06:44:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565795.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:歧义   链接   方法   scaladoc

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!