gren-lang / gren-lang/compiler
Implement code formatting
Open
Nobody has claimed this yet.
formatting
- Dominant language
- Haskell
- Stars
- 503
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
#38 is a discussion of possible approaches. This issue tracks implementation progress for the current approach.
- add CLI subcommand with options and file processing https://github.com/gren-lang/compiler/pull/46
- format directories implied by
gren.jsonhttps://github.com/gren-lang/compiler/pull/46 -
--yeshttps://github.com/gren-lang/compiler/pull/46 -
--validatehttps://github.com/gren-lang/compiler/pull/143 - explicit
INPUTS...https://github.com/gren-lang/compiler/pull/46 -
--stdinhttps://github.com/gren-lang/compiler/pull/46
- format directories implied by
- modify parser/AST to retain comments and necessary whitespace info
- modify whitespace parser to parse comments https://github.com/gren-lang/compiler/pull/56
- https://github.com/gren-lang/compiler/pull/132
- https://github.com/gren-lang/compiler/pull/142
- https://github.com/gren-lang/compiler/pull/153
- https://github.com/gren-lang/compiler/pull/154
- https://github.com/gren-lang/compiler/pull/159
- https://github.com/gren-lang/compiler/pull/160
- https://github.com/gren-lang/compiler/pull/161
- https://github.com/gren-lang/compiler/pull/162
- https://github.com/gren-lang/compiler/pull/165
- TBD: retain comments part N
- retain comments in empty arrays and records
- implement the formatting logic
- initial implementation (everything no requiring whitespace info should work) https://github.com/gren-lang/compiler/pull/117
- allow kernel module features when formatting kernel modules
- TBD any adjustments to formatting rules
- TBD fix anything that's broken
- add formatting test suite
- basic pattern established in https://github.com/gren-lang/compiler/pull/132
- (maybe) a property test to ensure that formatting is idempotent
- cleanup
- extract
Text.PrettyPrint.Avh4to a separate library to share with elm-format
- extract
Planned CLI options:
gren format [INPUTS... | --stdin] [--yes] [--validate]
INPUTS: zero or more files to format, or directories to recursively search for gren files to format. If none are given, use the directories implied bygren.json--stdin: instead of formatting files, read stdin and format it to stdout--yes: don't prompt for confirmation before formatting files and overwriting them (does nothing with--stdin)--validate: Don't modify files, and exit 0 if files are all formatted, or exit 1 if some files are not formatted. Intended for use on CI.
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 with the unchecked parser/AST comment-retention items and the formatting test suite described in the issue. Review the planned gren format CLI options and the existing linked implementation work before proceeding. Done means completing the remaining formatting, test, and cleanup checklist items, including idempotence if retained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100