-
-
Notifications
You must be signed in to change notification settings - Fork 55
Ocamlformat #581
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
Open
TheRealOwenRees
wants to merge
14
commits into
exercism:main
Choose a base branch
from
TheRealOwenRees:ocamlformat
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
Ocamlformat #581
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cc6e756
add file to enable auto code formatting
TheRealOwenRees fee0137
install ocamlformat and ocaml-lsp-server
TheRealOwenRees 65e39e4
add manual file formatting command
TheRealOwenRees 4e7ab61
make commands for checking and formatting code only apply to the test…
TheRealOwenRees f851ca2
remove old ocamlformat file
TheRealOwenRees 12e3f0a
update ocamlformat to use default profile and specific version
TheRealOwenRees 175b775
install ocamlformat 0.28.1
TheRealOwenRees 254c8e9
format all test generator files
TheRealOwenRees 9159044
update CI workflow to check linting before building dockerfile
TheRealOwenRees 7008976
install specific version of ocamlformat
TheRealOwenRees 81ed2a9
pin setup-ocaml version
TheRealOwenRees ce3c19c
run ci after lint
TheRealOwenRees bb92071
add built in dune-cache flag for caching ocam setup in lint job
TheRealOwenRees df5d8e4
add small comment to retrigger cache test
TheRealOwenRees 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| profile = default | ||
| version = 0.28.1 |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,5 +5,6 @@ | |
| (pps ppx_jane))) | ||
|
|
||
| (env | ||
| (dev | ||
| (flags (:standard -warn-error -A)))) | ||
| (dev | ||
| (flags | ||
| (:standard -warn-error -A)))) | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,5 +5,6 @@ | |
| (pps ppx_jane))) | ||
|
|
||
| (env | ||
| (dev | ||
| (flags (:standard -warn-error -A)))) | ||
| (dev | ||
| (flags | ||
| (:standard -warn-error -A)))) | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,5 +5,6 @@ | |
| (pps ppx_jane))) | ||
|
|
||
| (env | ||
| (dev | ||
| (flags (:standard -warn-error -A)))) | ||
| (dev | ||
| (flags | ||
| (:standard -warn-error -A)))) | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,32 +1,36 @@ | ||
| open Core | ||
|
|
||
| let run | ||
| ?(exercise: string option) | ||
| ~(templates_folder: string) | ||
| ~(canonical_data_folder: string) | ||
| ?(filter_broken: bool option) | ||
| (output_folder: string) = | ||
|
|
||
| let filter_broken = match filter_broken with Some x -> x | None -> false in | ||
| let exercise_filter = exercise |> function | ||
| | Some x -> fun (canidate: Exercise_candidate.t) -> String.equal x canidate.name | ||
| | None -> fun _ -> true | ||
| in | ||
| Files.find_files canonical_data_folder ~glob:["*canonical-data.json"] | ||
| |> List.map ~f:Exercise_candidate.of_path | ||
| |> List.filter ~f:exercise_filter | ||
| |> List.filter ~f:(fun (e: Exercise_candidate.t) -> match filter_broken with | true -> not(e.is_broken ~tpl:templates_folder) | false -> true) | ||
| |> List.filter ~f:(fun (e: Exercise_candidate.t) -> e.is_implemented ~tpl:templates_folder) | ||
| |> List.map ~f:(Exercise.of_candidate ~tpl:templates_folder ~out:output_folder) | ||
| |> List.concat_map ~f:(fun (e: Exercise.t) -> | ||
| List.map e.templates ~f:(fun (t: Template.t) -> | ||
| let path = Files.append_path output_folder t.relative_path |> Files.strip_ext in | ||
| Template.render t ~data:e.canonical_data | ||
| |> (fun r -> if String.((Files.ext path) = ".ml") then Template.format r else r) | ||
| |> Files.write_file ~path | ||
| )) | ||
| |> Result.all | ||
|
|
||
| let run ?(exercise : string option) ~(templates_folder : string) | ||
| ~(canonical_data_folder : string) ?(filter_broken : bool option) | ||
| (output_folder : string) = | ||
| let filter_broken = match filter_broken with Some x -> x | None -> false in | ||
| let exercise_filter = | ||
| exercise |> function | ||
| | Some x -> | ||
| fun (canidate : Exercise_candidate.t) -> String.equal x canidate.name | ||
| | None -> fun _ -> true | ||
| in | ||
| Files.find_files canonical_data_folder ~glob:[ "*canonical-data.json" ] | ||
| |> List.map ~f:Exercise_candidate.of_path | ||
| |> List.filter ~f:exercise_filter | ||
| |> List.filter ~f:(fun (e : Exercise_candidate.t) -> | ||
| match filter_broken with | ||
| | true -> not (e.is_broken ~tpl:templates_folder) | ||
| | false -> true) | ||
| |> List.filter ~f:(fun (e : Exercise_candidate.t) -> | ||
| e.is_implemented ~tpl:templates_folder) | ||
| |> List.map | ||
| ~f:(Exercise.of_candidate ~tpl:templates_folder ~out:output_folder) | ||
| |> List.concat_map ~f:(fun (e : Exercise.t) -> | ||
| List.map e.templates ~f:(fun (t : Template.t) -> | ||
| let path = | ||
| Files.append_path output_folder t.relative_path |> Files.strip_ext | ||
| in | ||
| Template.render t ~data:e.canonical_data | ||
| |> (fun r -> | ||
| if String.(Files.ext path = ".ml") then Template.format r else r) | ||
| |> Files.write_file ~path)) | ||
| |> Result.all | ||
|
|
||
| (* bin_data_checker calls this, but does not exist *) | ||
| let check_canonical_data _ = failwith "not implemented" |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,5 +5,6 @@ | |
| (pps ppx_jane))) | ||
|
|
||
| (env | ||
| (dev | ||
| (flags (:standard -warn-error -A)))) | ||
| (dev | ||
| (flags | ||
| (:standard -warn-error -A)))) | ||
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.
The documentation for ocamlformat recommend the ocamlformat version and a profile. Ocamlformat supports three different profiles straight out of the box. I'd suggest using
defaultunless there is a reason not to.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.
agreed. I will attend to that and add a version of ocamlformat to the switch as well (let me research how to do that!)