-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle deprecated signatures in Scala3doc #10595
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tests | ||
package deprecated | ||
|
||
class A: | ||
def defInt: Int = 1 | ||
@deprecated(message = "1") | ||
def def1: 1 = 1 | ||
@deprecated("reason") | ||
val valInt: Int = 1 | ||
val val1: 1 = 1 | ||
var varInt: Int = 1 | ||
var var1: 1 = 1 | ||
class InnerA: | ||
val innerVal: Int = 1 | ||
|
||
class B extends A: | ||
@deprecated(since = "1", message = "some reason") | ||
def x: Int = 1 | ||
val y: Int = 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,10 +80,12 @@ enum Origin: | |
case class Annotation(val dri: DRI, val params: List[Annotation.AnnotationParameter]) | ||
|
||
object Annotation: | ||
sealed trait AnnotationParameter | ||
case class PrimitiveParameter(val name: Option[String] = None, val value: String) extends AnnotationParameter | ||
case class LinkParameter(val name: Option[String] = None, val dri: DRI, val value: String) extends AnnotationParameter | ||
case class UnresolvedParameter(val name: Option[String] = None, val unresolvedText: String) extends AnnotationParameter | ||
sealed trait AnnotationParameter { | ||
val name: Option[String] | ||
} | ||
case class PrimitiveParameter(name: Option[String] = None, value: String) extends AnnotationParameter | ||
case class LinkParameter(name: Option[String] = None, dri: DRI, value: String) extends AnnotationParameter | ||
case class UnresolvedParameter(name: Option[String] = None, unresolvedText: String) extends AnnotationParameter | ||
|
||
// TODO (longterm) properly represent signatures | ||
case class Link(name: String, dri: DRI) | ||
|
@@ -124,6 +126,7 @@ extension[T] (member: Member): | |
|
||
def signature: Signature = memberExt.fold(Signature(name))(_.signature) | ||
def asLink: LinkToType = LinkToType(signature, dri, kind) | ||
def deprecated: Option[Annotation] = memberExt.flatMap(_.annotations.find(a => a.dri.getPackageName == "scala" && a.dri.getClassNames == "deprecated")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we are have a deprecated member from Java? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It depends. It still will be recognized as an annotation, though it won't have added strikethrough style. The question is: if we really find that using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if one want to use a Java class with deprecated members (e.g. this one ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean as a base class for Scala class... Yeah, we would like to make the Inherited methods deprecated. Will add support then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can be done in follow up PR |
||
|
||
def modifiers: Seq[dotty.dokka.model.api.Modifier] = memberExt.fold(Nil)(_.modifiers) | ||
def kind: Kind = memberExt.fold(Kind.Unknown)(_.kind) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not thing that we should mix non-braces and braces in our code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change