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

Add new syntax patterns for dune(-project) files #1391

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ComanderP
Copy link

Resolves #1180

@ComanderP
Copy link
Author

Hi, this is my first time contributing here, sorry if I did something wrong.
I went through most of the dune documentation and added syntax highlighting to most of the stanzas in the list of the issue.
I think most of the stanzas are covered now, with the exception of the stanzas from the config section, which I do not know if they're in a separate file or not.

On a side note, I took note of some things while doing this, concerning the syntax highlighting and the documentation:

  • I tried to not touch the executable(s) and library/libraries stanzas, as I didn't want to mess with the existing syntax highlighting that they have in common.
  • The menhir stanza added to env in version 3.0 of the menhir extension was not added as I was not sure if I was allowed to make a separate rule in the file's repository for both the normal menhir stanza and the menhir stanza in env. I can add it if it's okay. I also didn't want to just add the menhir stanza rules inside the env stanza rules, as it would lead to code duplication.
  • The documentation for the subst stanza seems to be incorrect, I think. It says that the subst stanza takes a <bool> as an argument, but it actually takes <enabled|disabled>. For example, the warnings stanza takes <enabled|disabled> and is documented as such. If you want, I can make a PR to fix this.
  • Another thing that I noticed is that the different TextMate grammar files have different formatting styles. This isn't that big of a deal, but it's something that I noticed.
  • Should external_variant be added to the syntax highlighting? I didn't add it as it was an experimental feature removed in version 2.6 of dune, and there's no documentation for it in the dune docs anymore.
  • I noticed that there is a variable.declaration.other.dune name and a variable.other.declaration.dune name in the syntax highlighting files. I don't know if this is intentional or not, and I do not know if there is a difference between the two. I tried both of them and they both seem to work the same way.
  • For the install stanza, the documentation only mentions 3 fields (files, section, package), but the syntax highlighting file is highlighting way more fields than that. I think there may have been a mistake with the executable fields, as there's a mention of the install stanza in the documentation for the executable stanza followed by the fields for the executable stanza. I'm not sure if this is a mistake or not, but I mentioned it just in case.

I hope this is helpful. Let me know if I should change something or if I missed something.

@smorimoto smorimoto requested a review from mnxn February 18, 2024 23:19
Copy link
Collaborator

@mnxn mnxn left a comment

Choose a reason for hiding this comment

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

Hi, sorry for the delay. The changes look good.
To fix the failing check, you need to add a change log entry to the CHANGELOG.md file.

To address your questions:

  • I think most of the stanzas are covered now, with the exception of the stanzas from the config section, which I do not know if they're in a separate file or not.

    The documentation mentions that config stanzas can be used in dune-workspace. That means the syntax patterns need to be added to dune-workspace.json.

  • I was not sure if I was allowed to make a separate rule in the file's repository for both the normal menhir stanza and the menhir stanza in env. I can add it if it's okay.

    That's a good idea.

  • The documentation for the subst stanza seems to be incorrect, I think. It says that the subst stanza takes a <bool> as an argument, but it actually takes <enabled|disabled>. For example, the warnings stanza takes <enabled|disabled> and is documented as such. If you want, I can make a PR to fix this.

    I'm not very familiar with these specifics, but I think you're right. You can make a PR to correct the documentation if you wish.

  • Another thing that I noticed is that the different TextMate grammar files have different formatting styles. This isn't that big of a deal, but it's something that I noticed.

    Our formatter for JSON files, Prettier, tends to preserve newlines. There may be some settings to make the formatting more consistent, but I agree with you that it's not a big deal.

  • Should external_variant be added to the syntax highlighting? I didn't add it as it was an experimental feature removed in version 2.6 of dune, and there's no documentation for it in the dune docs anymore.

    I agree with your decision. There's little point in highlighting a removed feature, especially one that was experimental.

  • I noticed that there is a variable.declaration.other.dune name and a variable.other.declaration.dune name in the syntax highlighting files. I don't know if this is intentional or not, and I do not know if there is a difference between the two. I tried both of them and they both seem to work the same way.

    I don't think it was intentional. I believe it's supposed to be variable.other.declaration.dune since that's closer to what other languages use.

  • For the install stanza, the documentation only mentions 3 fields (files, section, package), but the syntax highlighting file is highlighting way more fields than that. I think there may have been a mistake with the executable fields, as there's a mention of the install stanza in the documentation for the executable stanza followed by the fields for the executable stanza. I'm not sure if this is a mistake or not, but I mentioned it just in case.

    There does seem to be some mistake here. I don't think it was a confusion with the executable fields though. The install stanza documentation includes a table that has most of the current fields. The problem is that the list in the table is supposed to represent values for the section field, not field names like our current interpretation.

Let me know if you have any further questions.

@ComanderP
Copy link
Author

ComanderP commented Mar 5, 2024

Hi, thank you for the feedback!
I've added the config stanzas to the dune-workspace file as you said, but I'll try changing some things based on what you said as well before committing.

@smorimoto smorimoto requested a review from mnxn March 14, 2024 09:48
@ComanderP
Copy link
Author

Sorry for the delay, got caught up with my studies.
I fixed/changed/added stuff based on your previous insights.
Hopefully, all's fine now.

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.

Syntax: dune
3 participants