Skip to content

Commit 20dcfd2

Browse files
committed
document and better automate code formatting
1 parent d2878c0 commit 20dcfd2

4 files changed

Lines changed: 62 additions & 13 deletions

File tree

README.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Follow these steps to setup and test the project:
55
1. **Clone the Repository**
66
Clone this repository to your local machine:
77

8-
```bash
9-
git clone <https://github.com/DistCompiler/forja.git>
10-
```
8+
```bash
9+
git clone <https://github.com/DistCompiler/forja.git>
10+
```
1111

1212
2. **Install Scala CLI:**
1313
Install Scala CLI using the using this [link](https://scala-cli.virtuslab.org/install/)
@@ -17,19 +17,33 @@ git clone <https://github.com/DistCompiler/forja.git>
1717
4. **Verify Installation:**
1818
After installation, close and reopen your terminal, then verify Scala CLI is installed by running:
1919

20-
```bash
21-
scala-cli version
22-
```
20+
```bash
21+
scala-cli version
22+
```
2323

2424
5. **Run Tests:**
2525
After veryifying installation, build and run the tests using:
2626

27-
```bash
28-
scala-cli test .
29-
```
27+
```bash
28+
scala-cli test .
29+
```
3030

31-
6. **Debugging:**
32-
Use the debug adapter for troubleshooting and debugging. Refer to the documentation for setup and usage instructions.
31+
6. **Source formatting:**
32+
When contributing, make sure you've formatted your code.
33+
This is checked by CI.
34+
35+
I recommend committing your work, then running the formatters to see the formatting diff.
36+
You can then commit with `--amend` to replace your commit if you're happy with what the formatters did.
37+
38+
Run all the formatting scripts with:
39+
```bash
40+
scala-cli run . --main-class scripts.rewrite_src_sc
41+
```
42+
43+
As a convenience, you can also use `./rewrite_src.sh`, which is a one line shell script that launches the above command.
44+
45+
7. **Debugging:**
46+
You can try to use the debug adapter for troubleshooting and debugging. Refer to the documentation for setup and usage instructions.
3347

3448
# Forja Compiler Toolkit
3549

project.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
//> using dependency com.lihaoyi::sourcecode:0.4.2
1010
//> using dependency com.lihaoyi::ujson::4.2.1
1111
//> using dependency dev.zio::izumi-reflect:3.0.2
12-
//> using dependency edu.berkeley.cs.jqf:jqf-fuzz:2.0
13-
//> using dependency edu.berkeley.cs.jqf:jqf-instrument:2.0
12+
//> using dependency edu.berkeley.cs.jqf:jqf-fuzz:2.1
13+
//> using dependency edu.berkeley.cs.jqf:jqf-instrument:2.1
1414
//> using dependency io.github.java-diff-utils:java-diff-utils:4.15
1515
//> using dependency org.typelevel::cats-core:2.13.0
1616

rewrite_src.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
scala-cli run . --main-class scripts.rewrite_src_sc

scripts/rewrite_src.scala

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2024-2025 Forja Team
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package scripts
16+
17+
@main
18+
def rewrite_src_sc(): Unit =
19+
def cmd(parts: os.Shellable*): Unit =
20+
println(s"$$ ${parts.flatten(using _._1).mkString(" ")}")
21+
os.proc(parts*).call(cwd = os.pwd, stdout = os.Inherit, stderr = os.Inherit)
22+
23+
cmd(
24+
"scala-cli",
25+
"run",
26+
".",
27+
"--main-class",
28+
"scripts.update_license_sc",
29+
"--",
30+
"rewrite",
31+
)
32+
cmd("scala-cli", "fix", "--power", ".")
33+
cmd("scala-cli", "format", ".")

0 commit comments

Comments
 (0)