Skip to content

Scaladoc - fix uncompiling snippets, fix indentation for snippets #14856

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

Merged
merged 10 commits into from
Jun 9, 2022

Conversation

rochala
Copy link
Contributor

@rochala rochala commented Apr 5, 2022

Main change of this PR is fixing existing snippets and adding new flag for macro snippets to fix it's creation.
The repair of it was due, mainly for #10896 ( this issue, may or may not be closed after this PR, as it's unresolved )

First one is sc:macrocompile which allows to parse macros as snippets. Before this changes, snippets were wrapped in traits which are not static what lead to macro malformation. This flag skips wrapping in Traits with self types in favour of single object Snippet { ... } wrapping to enable snippet validation at compile time.

https://dotty.epfl.ch/api/scala/quoted/Varargs$.html#

Before:
image

After ( + it now checks snippet at compiletime ):
image

@rochala rochala force-pushed the fix-uncompiling-snippets branch from da37458 to 8057f8d Compare April 5, 2022 20:11
@pikinier20 pikinier20 force-pushed the fix-uncompiling-snippets branch from 9345810 to f8969ae Compare April 11, 2022 13:56
@pikinier20
Copy link
Contributor

Basically, we started with idea to add macrocompile flag but ended up with getting rid of the context-providing feature in code snippets. The feature wrapped snippets in traits with the self-type set up to the class in which the snippet is defined. This was meant to help author with writing snippet without the need to import and instantiate stuff. However, we can do it by ourselves if we need that and just hide the unnecessary boilerplate so that user sees only relevant part.

Removing this feature solved the problem with macros as well as with running snippets in API docs. It was also based on some nasty piece of code that we couldn't prove it actually works.

@pikinier20
Copy link
Contributor

As it affects snippets in stdlib documentation, I'll ask @nicolasstucki if he's fine with that.

@KacperFKorban
Copy link
Member

It seems that most of the changes are just adding a wildcard import from the current package. Can we maybe add it as default to the generated code?

@pikinier20 pikinier20 merged commit 8bd527e into scala:main Jun 9, 2022
@Kordyjan Kordyjan added this to the 3.2.0 milestone Aug 2, 2023
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.

4 participants