Skip to content

scaladoc: support expectations in snippets#25713

Open
bracevac wants to merge 2 commits intoscala:mainfrom
dotty-staging:ob-fix-25647
Open

scaladoc: support expectations in snippets#25713
bracevac wants to merge 2 commits intoscala:mainfrom
dotty-staging:ob-fix-25647

Conversation

@bracevac
Copy link
Copy Markdown
Contributor

@bracevac bracevac commented Apr 6, 2026

Fixes #25647

This adds compiler-suite-style diagnostic expectations for checked scaladoc snippets.

Supported:

  • // error
  • // warn
  • repeated markers on one line, e.g. // error // error

How to enable it:

  • enable compile+test for the markdown file in scaladoc's snippetCompiler / -snippet-compiler configuration
  • example: docs/_docs/reference/experimental/capture-checking/basics.md=compile+test

How to use it:

  • annotate expected diagnostics directly in Scala snippets

In compile+test mode:

  • clean snippets must compile without diagnostics
  • failing snippets must mark expected errors
  • warning snippets must mark expected warnings
  • unannotated errors or warnings fail

Not ported:

  • // anypos-error
    Useful in the compiler test suite for awkward parser/scanner cases, but not a good fit for scaladoc.
  • // nopos-error / // nopos-warn
    Position-less diagnostics don't arise in self-contained documentation snippets (they occur in multi-file macro scenarios), so these annotations have no practical use here.
  • full compiler-output checking with sc-check:<id>
    A poor fit for docs, since it checks wrapped compiler output rather than the focused excerpts we want to show in documentation.

How much have you relied on LLM-based tools in this contribution?

A lot.

How was the solution tested?

Automated tests, plus manual testing on the CC language reference.

@bracevac bracevac marked this pull request as ready for review April 7, 2026 19:44
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.

Scaladoc/Snippet checking should support expected diagnostics like the compilation test suite

1 participant