Skip to content

Fix markdown syntax for scala3 library docstrings #11612

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 1 commit into from
Mar 5, 2021

Conversation

BarkingBad
Copy link
Contributor

Before
obraz

After
obraz

@BarkingBad
Copy link
Contributor Author

There might be more docstrings that need @syntax markdown applied

@BarkingBad BarkingBad merged commit 98e3839 into scala:master Mar 5, 2021
@smarter
Copy link
Member

smarter commented Mar 15, 2021

I don't understand this change, doesn't scaladoc use markdown syntax by default? We certainly want to use it by default for all new code, having to add @syntax markdown everywhere would be very cumbersome.

@BarkingBad
Copy link
Contributor Author

Well, scaladoc uses markdown syntax by default. However, most of the compiler has comments with wikisyntax. Therefore, we run scaladoc with wikisyntax flag raised. We could either:

  • convert everything to markdown (a lot of work, since most of the comments are already in wikisyntax)
  • convert everything to wikisyntax
  • add markdown syntax annotation

The third option was the easiest as I didn't have to rewrite all the conflicting symbols.

@smarter
Copy link
Member

smarter commented Mar 15, 2021

most of the compiler has comments with wikisyntax.

Do you have examples? From what I can see, most of the comments use markdown syntax (backticks for code are very commonly used for example).

Also, can't we support using both syntaxes at once?

@BarkingBad
Copy link
Contributor Author

Just browsed the .scala files for occurances of \*.*\{\{\{|\*.*\[\[ regex which I believe is correct ([[ and {{{ are known for wikisyntax) and got 2534 occurances across 569 files. I see markdown is also present (```) has 308 results in 42 files, but I fixed it for these docstrings that are in public api of dotty compiler.

@BarkingBad
Copy link
Contributor Author

As for supporting both syntaxes, it is hard as we should have to assume whether something is in markdown or wikisyntax, which I think we cannot so easily determine.

@smarter
Copy link
Member

smarter commented Mar 15, 2021

[[ and {{{ are known for wikisyntax)

[[ is supported under markdown syntax according to http://dotty.epfl.ch/docs/usage/scaladoc/docComments.html

Limiting myself to {{{ and searching in all the source code in the dotty repo I get:

% rg -o '\*.*\{\{\{' library compiler interfaces scaladoc tasty-inspector staging language-server|wc -l
68

Am I missing something? Perhaps you're also looking at the scala 2 standard library scala files, but that's a different project (and this one does use wiki syntax since it has to work with the scala 2 scaladoc too).

@BarkingBad
Copy link
Contributor Author

Yes, you are right. However I thought we want to have wikisyntax as a default for compiler.

So what do you propose? Certainly we have to revert these changes, but should we update the old comments with @syntax wiki or actually rewrite all these comments to be in markdown style?

@smarter
Copy link
Member

smarter commented Mar 15, 2021

I think ideally we should support wiki code blocks by default if possible: #11728 (comment), otherwise I would prefer to default to markdown syntax and rewrite comments (maybe we can do that with a regexp to replace {{{ and }}} by three backticks).

@BarkingBad
Copy link
Contributor Author

I talked with @romanowski and he told me we document a lot of scala2 code in our projects which has wikisyntax docstrings. Maybe the best solution is to remove flag -comment-syntax wiki and introduce new flag that will list all directories that are supposed to be documented in wikisyntax using regex prefixes. Similar mechanism is already implemented for skipping packages, so it would be easy and convenient, moreover we won't interfere with exisiting docstrings. This solution is also useful for library developers migrating to scala3 that have some old scala2 code with wikisyntax.

@Kordyjan Kordyjan added this to the 3.0.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.

Scaladoc <code> tags recursively applied after code in markdown comment
4 participants