-
Notifications
You must be signed in to change notification settings - Fork 397
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
Auto format dune-project
files with dune fmt
#10716
Open
maxRN
wants to merge
11
commits into
ocaml:main
Choose a base branch
from
maxRN:dune-fmt-dune-project-files
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
087ea7e
doc: fix typo
maxRN 015b715
feat(fmt): auto format dune-project files
maxRN d060db8
feat: enable dune-project formatting for dune <= 3.17
maxRN c47472e
fix: typo in example
maxRN 8215838
fix: don't hardcode build dir
maxRN bc18985
doc: update formatting docs
maxRN d968084
test: test disabled dune-project formatting
maxRN f3d2de2
fix: handle empty field case pre-3.17
maxRN a8f0ede
fix: add new dune 2.0 variant
maxRN e773978
rename: DuneProject -> Dune_project
maxRN befce10
test!: format dune-project with format-dune-file
maxRN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ module Language : sig | |
type t = | ||
| Dialect of string | ||
| Dune | ||
| DuneProject | ||
end | ||
|
||
type t | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,7 +190,8 @@ Sometimes, the suggestion is to just remove the configuration. | |
5 | (using fmt 1.2) | ||
^^^^^^^^^^^^^^^ | ||
Error: Starting with (lang dune 2.0), formatting is enabled by default. | ||
To port it to the new syntax, you can delete this part. | ||
To port it to the new syntax, you can replace this part by: | ||
(formatting (enabled_for dune ocaml reason)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsure whether we should extend the help message by mentioning the differences between > 3.17 dune and 3.17+ |
||
[1] | ||
|
||
Formatting can also be set in the (env ...) stanza | ||
|
@@ -250,3 +251,38 @@ settings as dictated by the dune language version. | |
> ;; formatting disabled by default | ||
> EOF | ||
$ (cd using-env && dune build @fmt) | ||
|
||
dune fmt automatically formats dune-project files starting from dune 3.17. | ||
|
||
$ mkdir dune-project-files | ||
$ touch dune-project-files/.ocamlformat | ||
$ cat > dune-project-files/dune-project << EOF | ||
> (lang dune 3.17) | ||
> (name | ||
> format_project) | ||
> EOF | ||
$ (cd dune-project-files && dune fmt) | ||
File "dune-project", line 1, characters 0-0: | ||
Error: Files _build/default/dune-project and | ||
_build/default/.formatted/dune-project differ. | ||
Promoting _build/default/.formatted/dune-project to dune-project. | ||
[1] | ||
$ cat dune-project-files/dune-project | ||
(lang dune 3.17) | ||
|
||
(name format_project) | ||
|
||
But does not format if formatting is disabled for dune-project files. | ||
|
||
$ cat > dune-project-files/dune-project << EOF | ||
> (lang dune 3.17) | ||
> (name | ||
> format_project) | ||
> (formatting (enabled_for ocaml dune reason)) | ||
> EOF | ||
$ (cd dune-project-files && dune fmt) | ||
$ cat dune-project-files/dune-project | ||
(lang dune 3.17) | ||
(name | ||
format_project) | ||
(formatting (enabled_for ocaml dune reason)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dune_project
is the convention