From bc8a463d68b18b7fbcf1425b9487a23b71ff44e5 Mon Sep 17 00:00:00 2001 From: AoifeHughes Date: Tue, 1 Jul 2025 09:45:19 +0100 Subject: [PATCH] init adding of formatting instructions --- developers/contributing/index.qmd | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/developers/contributing/index.qmd b/developers/contributing/index.qmd index 00040e7e2..8e6693daa 100755 --- a/developers/contributing/index.qmd +++ b/developers/contributing/index.qmd @@ -49,6 +49,28 @@ julia --project=. -e 'import Pkg; Pkg.test(; test_args=ARGS)' -- optim hmc --ski Or otherwise, set the global `ARGS` variable, and call `include("test/runtests.jl")`. +### Code Formatting + +Turing uses [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) to ensure consistent code style across the codebase. **All code must be formatted before submitting a pull request**, and ideally with every commit. + +#### Installing JuliaFormatter + +We use version 1 of JuliaFormatter. Install it in your **global Julia environment** (not the project environment, as adding it to the Project.toml would make it invalid): + +```julia +julia -e 'using Pkg; Pkg.activate(); Pkg.add(name="JuliaFormatter", version="1"); Pkg.pin("JuliaFormatter")' +``` + +#### Formatting Code + +To format all Julia files in the current directory and subdirectories: + +```julia +julia -e 'using JuliaFormatter; format(".")' +``` + +Run this command from the root of the repository before committing your changes. This ensures your code follows the project's formatting standards and maintains consistency across the codebase. + ### Style Guide Turing has a style guide, described below.