Skip to content
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

Scaladoc: Allow to set a comment syntax based on path to source #14650

Merged
merged 3 commits into from Mar 17, 2022

Conversation

jchyb
Copy link
Contributor

@jchyb jchyb commented Mar 9, 2022

This PR adds a new Scaladoc option: CommentSyntaxOverrides, which allows to override the project wide comment syntax with one set based on a path prefix to a source file.
This PR revises -comment-syntax option to use the PathBased abstraction. This will allow to use multiple syntaxes in one project. The previous style of option passing (one syntax format for the whole project) will still work.
Additionally in the dotty repo the following paths were set with this option:

  • two newly added scaladoc-testcases examples showcasing the feature (in the examples.comment.markdown and examples.comment.wiki packages)
  • more importantly, Scala 2.13 stdlib (using wiki) and Scala 3 stdlib (using markdown)

Resolves #14596

Copy link
Contributor

@pikinier20 pikinier20 left a comment

Choose a reason for hiding this comment

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

I'd rather not introduce additional setting. Instead of this, we can change the old -comment-syntax setting to accept list of options. PathBased handles option without path as a fallback so it will work right away.

@jchyb jchyb force-pushed the scaladoc/comment-syntax-overrides branch 2 times, most recently from cc89009 to f481fbe Compare March 9, 2022 11:29
@jchyb jchyb marked this pull request as draft March 9, 2022 11:36
@jchyb jchyb force-pushed the scaladoc/comment-syntax-overrides branch from f481fbe to d0290ee Compare March 9, 2022 14:29
@jchyb jchyb requested a review from pikinier20 March 9, 2022 16:25
@jchyb jchyb marked this pull request as ready for review March 10, 2022 08:29
Copy link
Contributor

@pikinier20 pikinier20 left a comment

Choose a reason for hiding this comment

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

Could you also set correct syntaxes to dotty library and scala 2.13 library in Build.scala?

Comment on lines 20 to 25
CommentSyntax.CommentSyntaxParser.parse(commentSetting).getOrElse {
val msg = s"not a valid comment syntax: $commentSetting, defaulting to Markdown syntax."
// we should update pos with span from documentation
pos.fold(report.warning(msg))(report.warning(msg, _))

CommentSyntax.default
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we here fall back to the syntax based on path?

Copy link
Contributor

@pikinier20 pikinier20 left a comment

Choose a reason for hiding this comment

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

Overally, this is a great work.

I've left only one place that would eventually need a change. Besides that LGTM.

@jchyb jchyb force-pushed the scaladoc/comment-syntax-overrides branch from d0290ee to 196f207 Compare March 17, 2022 09:30
CommentSyntax option now allows to set the comment syntax based on
a passed path prefix. This will allow to use a correct syntax for
specific files in one project, for example a wiki syntax for scalalib
and md syntax for dottylib.
Those consist of packages example.comment.md and example.comment.wiki
configured with a matching comment syntax.
Wiki syntax was set for scala 2.13 stdlib and markdown was set for scala
3 stdlib.
@jchyb jchyb force-pushed the scaladoc/comment-syntax-overrides branch from 196f207 to 8766c44 Compare March 17, 2022 09:47
@pikinier20 pikinier20 merged commit 17e46ad into scala:main Mar 17, 2022
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CommentSyntax setting should be path based
3 participants