Ability to format non-OCaml files
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
Description
Desired Behavior
dune build @fmt can format anything with a dialect defined, but dialect requires the files to be OCaml-like (have an implementation and interface and compile into OCaml). It would be nice if we could define formatters for non-OCaml files. For example, Dune internally has a formatter for dune files, but I don't think it's possible for users to define similar formatters.
Examples of things we want to format:
- atdgen files
- random Python scripts in our build system
- Various other sexp files we use in our builds
Example
Something like:
; dune-project
(formatter
(extension py)
(format python3 -m yapf -))
.. and then dune build @fmt would run the equivalent of python3 -m yapf < python_file.py for each Python file.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the formatter behavior behind dune build @fmt and the existing formatter definition for Dune files; the issue also gives a proposed (formatter ...) entry in dune-project. Done means users can register formatters for non-OCaml files, including the shown Python command, and have them run for matching files through @fmt.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100