Skip to content

scaladoc: indicate optional parameters with = ... #23676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scaladoc-testcases/src/tests/extendsCall.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package extendsCall

class Impl() extends Base(Seq.empty, c = "-") //expected: class Impl() extends Base

class Base(val a: Seq[String], val b: String = "", val c: String = "") //expected: class Base(val a: Seq[String], val b: String, val c: String)
class Base(val a: Seq[String], val b: String = "", val c: String = "") //expected: class Base(val a: Seq[String], val b: String = ..., val c: String = ...)
23 changes: 23 additions & 0 deletions scaladoc-testcases/src/tests/optionalParams.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package tests
package optionalParams

class C(val a: Seq[String], val b: String = "", var c: String = "") //expected: class C(val a: Seq[String], val b: String = ..., var c: String = ...)
{
def m(x: Int, s: String = "a"): Nothing //expected: def m(x: Int, s: String = ...): Nothing
= ???
}

def f(x: Int, s: String = "a"): Nothing //expected: def f(x: Int, s: String = ...): Nothing
= ???

extension (y: Int)
def ext(x: Int = 0): Int //expected: def ext(x: Int = ...): Int
= 0

def byname(s: => String = "a"): Int //expected: def byname(s: => String = ...): Int
= 0

enum E(val x: Int = 0) //expected: enum E(val x: Int = ...)
{
case E1(y: Int = 10) extends E(y) //expected: final case class E1(y: Int = ...) extends E
}
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,15 @@ trait ClassLikeSupport:
val inlinePrefix = if symbol.flags.is(Flags.Inline) then "inline " else ""
val name = symbol.normalizedName
val nameIfNotSynthetic = Option.when(!symbol.flags.is(Flags.Synthetic))(name)
val defaultValue = Option.when(symbol.flags.is(Flags.HasDefault))(Plain(" = ..."))
api.TermParameter(
symbol.getAnnotations(),
inlinePrefix + prefix(symbol),
nameIfNotSynthetic,
symbol.dri,
argument.tpt.asSignature(classDef, symbol.owner),
isExtendedSymbol,
isGrouped
argument.tpt.asSignature(classDef, symbol.owner) :++ defaultValue,
isExtendedSymbol = isExtendedSymbol,
isGrouped = isGrouped
)

def mkTypeArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ class RightAssocExtension extends SignatureTest("rightAssocExtension", Signature
class NamedTuples extends SignatureTest("namedTuples", SignatureTest.all)

class InnerClasses extends SignatureTest("innerClasses", SignatureTest.all)

class OptionalParams extends SignatureTest("optionalParams", SignatureTest.all)
Loading