diff --git a/src/build-and-packages.md b/src/build-and-packages.md index f8b2c81..74c9009 100644 --- a/src/build-and-packages.md +++ b/src/build-and-packages.md @@ -33,6 +33,7 @@ every test. | `run` | runs `main` in the project. | | `test` | runs all tests in the project. | | `doc` | generates API documentation for 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. | diff --git a/src/checking-running-and-testing.md b/src/checking-running-and-testing.md index 16bd6d0..3b307c1 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 cedca16..5666b37 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.