-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Scala3doc: improve stdlib loading #10593
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
d8ff7d8
e06a381
3fa8fb9
3071a53
0d8d6b7
454bc22
8b7467c
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 |
---|---|---|
|
@@ -30,17 +30,22 @@ case class DokkaTastyInspector(parser: Parser)(using ctx: DocContext) extends Do | |
private val topLevels = Seq.newBuilder[Documentable] | ||
|
||
def processCompilationUnit(using q: Quotes)(root: q.reflect.Tree): Unit = | ||
val parser = new TastyParser(q, this) | ||
|
||
def driFor(link: String): Option[DRI] = | ||
val symOps = new SymOps[q.type](q) | ||
import symOps._ | ||
Try(QueryParser(link).readQuery()).toOption.flatMap(q => | ||
MemberLookup.lookupOpt(q, None).map{ case (sym, _) => sym.dri} | ||
) | ||
// NOTE we avoid documenting definitions in the magical stdLibPatches directory; | ||
// the symbols there are "patched" through dark Dotty magic onto other stdlib | ||
// definitions, so if we documented their origin, we'd get defs with duplicate DRIs | ||
if !root.symbol.show.startsWith("scala.runtime.stdLibPatches") 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 we should turn this into setting and do not hardcode in the logic itseld (I can see usage for excluding bits from documentation) 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 we have a separate issue for that? I can already see a bunch of things that would need to be considered with such an option (should the option take a list of full package names? a list of FQN string prefixes?) and I'd rather discuss them separately. |
||
val parser = new TastyParser(q, this) | ||
|
||
def driFor(link: String): Option[DRI] = | ||
val symOps = new SymOps[q.type](q) | ||
import symOps._ | ||
Try(QueryParser(link).readQuery()).toOption.flatMap(q => | ||
MemberLookup.lookupOpt(q, None).map{ case (sym, _) => sym.dri} | ||
) | ||
|
||
ctx.staticSiteContext.foreach(_.memberLinkResolver = driFor) | ||
topLevels ++= parser.parseRootTree(root.asInstanceOf[parser.qctx.reflect.Tree]) | ||
ctx.staticSiteContext.foreach(_.memberLinkResolver = driFor) | ||
topLevels ++= parser.parseRootTree(root.asInstanceOf[parser.qctx.reflect.Tree]) | ||
end processCompilationUnit | ||
|
||
def result(): List[DPackage] = | ||
topLevels.clear() | ||
|
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.
Shouldn't that logic be placed into TASY? I mean people may wan to parse tasty from stdlib and they will be really supprised what they will get
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.
Tasty Reflect is already aware of how the compiler patches stdlib definitions. Our problem is that we rely on class bodies to document classes, and those aren't patched.
We can open a separate issue for patching class bodies as well.