-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle exports presenting in scala3doc #10504
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
Conversation
The reflection API changes look good. |
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.
Otherwise, the reflection part of the code looks good.
…on for constant types
case _ => link(tr.termSymbol) | ||
} | ||
case tr @ TermRef(qual, typeName) => | ||
tr.termSymbol.tree match |
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.
This one here is a little bit tricky. The reason behind this is to extract ConstantType
when one occurs
class A:
def defInt: Int = 1
def def1: 1 = 1
val valInt: Int = 1
val val1: 1 = 1
var varInt: Int = 1
var var1: 1 = 1
class B:
val a = new A
export a._ I know that setters and getters could be bundled into |
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.
What are the files where I can see how this is displayed?
@@ -43,6 +43,7 @@ object FilterAttributes: | |||
case Origin.InheritedFrom(name, _) => Map("inherited" -> name) | |||
case Origin.ImplicitlyAddedBy(name, _) => Map("implicitly" -> s"by $name") | |||
case Origin.ExtensionFrom(name, _) => Map("extension" -> s"from $name") | |||
case Origin.ExportedFrom(name, _) => Map("export" -> s"Exported from $name") |
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.
Where is this used? Why is the previous line "from $name"
, but this one is "Exported from $name"
, i.e. why is the "Exported" part necessary?
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.
Yeah, I could add some exports to the test cases.
For this one with Exported from...
is my fault, will fix
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.
Only known export for me at this moment is here
https://scala3doc.virtuslab.com/pr-10504/self/scala3doc/-a-p-i/dotty.dokka/tasty/-basic-support.html
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.
Updated testcases, check out exports here https://scala3doc.virtuslab.com/pr-10504/testcases/-scala3doc%20testcases/tests/exports/-b.html
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.
Asked some question about exporting members from objects plus some minor style things.
} | ||
val functionName = exportedTarget.fold("instance")(_.name) | ||
val instanceName = exportedTarget.fold("function")(_.qualifier.asInstanceOf[Select].name) | ||
val dri = dd.rhs.flatMap { |
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.
Can rhs
be empy? If not we can simplify this code a lot
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.
Not sure, but I followed the API that returns an Option
@@ -123,6 +123,26 @@ trait ClassLikeSupport: | |||
.map { _ => | |||
parseMethod(dd.symbol, kind = Kind.Given(getGivenInstance(dd).map(_.asSignature), None)) | |||
} | |||
|
|||
case dd: DefDef if !dd.symbol.isHiddenByVisibility && dd.symbol.isExported => | |||
val exportedTarget = dd.rhs.flatMap { |
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.
dd.rhs.collect {
case a: Apply => a.fun
case s: Select => s
}
will do the same what flatmap
and map
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
case s: Select => s | ||
} | ||
val functionName = exportedTarget.fold("instance")(_.name) | ||
val instanceName = exportedTarget.fold("function")(_.qualifier.asInstanceOf[Select].name) |
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.
Does it need to a Select
? What if we have
object A:
def a = 1
object B extends App:
export A._
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.
There was a wrong assumption that led to exception breaking the scala3doc generation while having object. Fixed it though
case a: Apply => None | ||
case s: Select => | ||
val dri = s.symbol.dri | ||
dri.getCallable match |
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.
we should check if symbol is method not check if callable is set in DRI
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.
As I recall it was my first attempt then it came out everything he perceives as method, so I had to find another way to determine it, but I will double check that
dri.getCallable match | ||
case null => None | ||
case _ => Some(dri) | ||
}.orElse(exportedTarget.map(_.qualifier.tpe.typeSymbol.dri)) |
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 typeSymbol
works with object? See comment above.
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.
Hard to tell. Could not produce anything breaking the generation.
EDIT: That was my misinterpretation
However, there is one interesting thing, for that code:
object X:
def x: Int = 1
val x2: Int = 1
var x3: Int = 1
class B:
val a = new A
export a._
export X._
we get following output:
I will have to check is it our bug, but it sees x2
as Int
, not literal 1
, which is odd, since that type is stable and safe to assume it's literal type (as it did with previous vals
)
@@ -49,6 +49,8 @@ object ScalaSignatureProvider: | |||
extensionSignature(extension, builder) | |||
case method: DFunction if method.kind.isInstanceOf[Kind.Given] => | |||
givenMethodSignature(method, builder) | |||
case exprt: DFunction if exprt.kind == Kind.Exported => |
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.
Do we need that case
and exportedMethodSignature
since we handle it as methodSignature
anyway ?
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.
Can delete, but thought it would be more reasonable to state that explicitly
No description provided.