From d12f1b02f5c1f4ef3d1c40108a9d822bf9e85d26 Mon Sep 17 00:00:00 2001 From: Magnus Madsen Date: Wed, 14 Oct 2026 12:03:28 +0200 Subject: [PATCH 1/2] docs: add the format command Add a Formatting the Source Code section to the Checking, Running, and Testing chapter with a before-and-after example, list `format` in the command table, and mention formatting among the VS Code features. Co-Authored-By: Claude Fable 5.1 --- src/build-and-packages.md | 1 + src/checking-running-and-testing.md | 24 ++++++++++++++++++++++++ src/vscode.md | 3 +++ 3 files changed, 28 insertions(+) diff --git a/src/build-and-packages.md b/src/build-and-packages.md index f8b2c816..937f5d62 100644 --- a/src/build-and-packages.md +++ b/src/build-and-packages.md @@ -34,6 +34,7 @@ every test. | `test` | runs all tests in the project. | | `doc` | generates API documentation for the project. | | `stat` | prints statistics about the project. | +| `format` | formats the source code of the project. | | `build` | compiles the entire project. | | `build-classes` | compiles the project to Java class files. | | `build-jar` | builds a JAR-file from the project. | diff --git a/src/checking-running-and-testing.md b/src/checking-running-and-testing.md index 16bd6d05..3b307c1c 100644 --- a/src/checking-running-and-testing.md +++ b/src/checking-running-and-testing.md @@ -87,6 +87,30 @@ build We read it by opening `build/doc/index.html` in a browser. +## Formatting the Source Code + +We can format the source code of the project with the `format` command. The +command rewrites every file in `src` and `test` in place. If `src/Main.flix` reads: + +```flix +def main( ) : Unit \ IO = + println( "Hello World!" ) + +def add(x:Int32,y:Int32):Int32=x+y +``` + +then after `format` it reads: + +```flix +def main(): Unit \ IO = + println("Hello World!") + +def add(x: Int32, y: Int32): Int32 = x + y +``` + +If the project does not compile, `format` reports the errors and leaves the +files untouched. + ## Printing Statistics We can print statistics about the project with the `stat` command: diff --git a/src/vscode.md b/src/vscode.md index cedca166..5666b378 100644 --- a/src/vscode.md +++ b/src/vscode.md @@ -52,6 +52,9 @@ Flix also comes with an (optional) Visual Studio Code color theme called "Flixif - Rename local variables or formal parameters. - Rename functions. +* __Formatting__ + - Format the current file. + * __Code Lenses__ - Run `main` from within the editor. - Run tests from within the editor. From 56c54d60c70e19be91d66ce8f2e618aff439c29f Mon Sep 17 00:00:00 2001 From: Magnus Madsen Date: Wed, 14 Oct 2026 12:04:50 +0200 Subject: [PATCH 2/2] docs: list format before stat in the command table Co-Authored-By: Claude Fable 5.1 --- src/build-and-packages.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build-and-packages.md b/src/build-and-packages.md index 937f5d62..74c90096 100644 --- a/src/build-and-packages.md +++ b/src/build-and-packages.md @@ -33,8 +33,8 @@ every test. | `run` | runs `main` in the project. | | `test` | runs all tests in the project. | | `doc` | generates API documentation for the project. | -| `stat` | prints statistics about the project. | | `format` | formats the source code of the project. | +| `stat` | prints statistics about the project. | | `build` | compiles the entire project. | | `build-classes` | compiles the project to Java class files. | | `build-jar` | builds a JAR-file from the project. |