Skip to content

Adding some formatting instructions for contributing #626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions developers/contributing/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down