Skip to content

Enable Snippet Compiler for CC Docs#25276

Merged
bracevac merged 2 commits intoscala:mainfrom
dotty-staging:ob-cc-docs-checked
Feb 16, 2026
Merged

Enable Snippet Compiler for CC Docs#25276
bracevac merged 2 commits intoscala:mainfrom
dotty-staging:ob-cc-docs-checked

Conversation

@bracevac
Copy link
Contributor

@bracevac bracevac commented Feb 15, 2026

A first step towards #24756.

This enables CC snippet checking for scaladoc/generateScalaDocumentation and scaladoc/generateReferenceDocumentation.

Most snippets are exempted through sc:nocompile for now. A separate PR should go over them and actually make them compilable.

- 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
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.
@bracevac bracevac marked this pull request as ready for review February 15, 2026 15:14

```scala sc:nocompile sc-name:preamble
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@bracevac bracevac Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bracevac bracevac merged commit fabb58b into scala:main Feb 16, 2026
59 checks passed
@bracevac bracevac deleted the ob-cc-docs-checked branch February 16, 2026 13:18
@WojciechMazur WojciechMazur added this to the 3.8.3 milestone Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments