Enable Snippet Compiler for CC Docs#25276
Conversation
- Annotate all scala snippets with sc:nocompile and sc-compile-with:preamble - Extend snippet compiler path config to support per-path scalac options - Configure -language:experimental.captureChecking (and separationChecking where needed) via path-based entries in Build.scala
c952146 to
88489c2
Compare
The reference docs task copies files to a temp directory, so the relative snippet compiler paths from Scala3 config don't match. Add absolute-path entries using the temp dir prefix.
|
|
||
| ```scala sc:nocompile sc-name:preamble | ||
| ``` | ||
|
|
There was a problem hiding this comment.
9/10 of preamble snippets are empty. Is it necessary to include them?
If so maybe instead of adding a dedicated parsing of scalac options for given paths, we can just add import language.experimental.captrueChecking only in the preamble and not add additional options?
At the same time I think all of the modified snippets are explicit disabled with sc:nocompile, is it expected? Are there any CC docs snippets being actually compiled after that?
There was a problem hiding this comment.
As mentioned in the PR description, this is to set up the infrastructure. I've tested a handful of code snippets, but most of them have to be adapted to be compilable. That should be done in a separate PR.
There was a problem hiding this comment.
Also: I tried putting the experimental language imports in the snippets directly, but I get the same error as in the REPL, i.e., that this import isn't allowed. So we have to pass them as compiler options.
There was a problem hiding this comment.
It might be due to the way how markdown snippets are compiled. Multiple snippets might be squashed to a single targer source that would be compiled. That's why in https://github.com/WojciechMazur/dotty/blob/0c477928e4c438cba594b7251ca8a274e0a064a4/docs/_docs/reference/error-codes/E223.md?plain=1#L19-L32 we've been passing them to scalac options directlly.
A first step towards #24756.
This enables CC snippet checking for
scaladoc/generateScalaDocumentationandscaladoc/generateReferenceDocumentation.Most snippets are exempted through
sc:nocompilefor now. A separate PR should go over them and actually make them compilable.