-
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
Changes from 1 commit
35c1c90
f8e2559
5633399
ff3db41
1efc4af
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 |
---|---|---|
|
@@ -123,6 +123,17 @@ 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 commentThe reason will be displayed to describe this comment to others. Learn more.
will do the same what 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. Will change |
||
case a: Apply => Some(a.fun) | ||
case _ => None | ||
}.map { | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Does it need to a
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. There was a wrong assumption that led to exception breaking the scala3doc generation while having object. Fixed it though |
||
Some(parseMethod(dd.symbol, kind = Kind.Exported).withOrigin(Origin.ExportedFrom(s"$instanceName.$functionName", dd.symbol.dri))) | ||
|
||
case dd: DefDef if !dd.symbol.isHiddenByVisibility && !dd.symbol.isGiven && !dd.symbol.isSyntheticFunc && !dd.symbol.isExtensionMethod => | ||
Some(parseMethod(dd.symbol)) | ||
|
@@ -184,7 +195,6 @@ trait ClassLikeSupport: | |
case dd: DefDef if !dd.symbol.isClassConstructor && !(dd.symbol.isSuperBridgeMethod || dd.symbol.isDefaultHelperMethod) => dd | ||
case other => other | ||
} | ||
|
||
c.membersToDocument.flatMap(parseMember) ++ | ||
inherited.flatMap(s => parseInheritedMember(s)) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Where is this used? Why is the previous line 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. Yeah, I could add some exports to the test cases. For this one with 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. Only known export for me at this moment is here 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. Updated testcases, check out exports here https://scala3doc.virtuslab.com/pr-10504/testcases/-scala3doc%20testcases/tests/exports/-b.html |
||
case _ => Map.empty | ||
case null => | ||
Map.empty | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Do we need that 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. Can delete, but thought it would be more reasonable to state that explicitly |
||
exportedMethodSignature(exprt, builder) | ||
case method: DFunction => | ||
methodSignature(method, builder) | ||
case enumEntry: DClass if enumEntry.kind == Kind.EnumCase => | ||
|
@@ -138,14 +140,14 @@ object ScalaSignatureProvider: | |
} else { | ||
extension.getParameters.asScala(0) | ||
} | ||
val withSinature = builder | ||
val withSignature = builder | ||
.modifiersAndVisibility(extension, "def") | ||
.name(extension.getName, extension.getDri) | ||
.generics(extension) | ||
.functionParameters(extension) | ||
|
||
if extension.isConstructor then withSinature | ||
else withSinature.text(":").text(" ").typeSignature(extension.getType) | ||
if extension.isConstructor then withSignature | ||
else withSignature.text(":").text(" ").typeSignature(extension.getType) | ||
|
||
private def givenMethodSignature(method: DFunction, builder: SignatureBuilder): SignatureBuilder = method.kind match | ||
case Kind.Given(Some(instance), _) => | ||
|
@@ -156,6 +158,8 @@ object ScalaSignatureProvider: | |
case _ => | ||
builder.text("given ").name(method.getName, method.getDri) | ||
|
||
private def exportedMethodSignature(method: DFunction, builder: SignatureBuilder): SignatureBuilder = | ||
methodSignature(method, builder) | ||
|
||
private def methodSignature(method: DFunction, builder: SignatureBuilder): SignatureBuilder = | ||
val bdr = builder | ||
|
Uh oh!
There was an error while loading. Please reload this page.