Style Guide
This section describes the coding style rules that apply to our code and that we recommend you to use it also.
In some cases, our style guide diverges from Julia's official Style Guide (Please read it!). All such cases will be explicitly noted and justified.
Our style guide adopts many recommendations from the BlueStyle. Please read the BlueStyle before contributing to this package. If not following, your pull requests may not be accepted.
The style guide is always a work in progress, and not all LinearElasticityBase code follows the rules. When modifying LinearElasticityBase, please fix the style violations of the surrounding code (i.e., leave the code tidier than when you started). If large changes are needed, consider separating them into another pull request.
Formatting
Run JuliaFormatter
LinearElasticityBase uses JuliaFormatter as an auto-formatting tool.
We use the options contained in .JuliaFormatter.toml.
To format your code, cd to the LinearElasticityBase directory, then run:
julia> using Pkgjulia> Pkg.add("JuliaFormatter")Resolving package versions... Installed Glob ─────────── v1.4.0 Installed JuliaSyntax ──── v0.4.10 Installed JuliaFormatter ─ v2.3.0 Installed CommonMark ───── v0.10.3 Updating `~/work/LinearElasticityBase.jl/LinearElasticityBase.jl/docs/build/developers/Project.toml` [98e50ef6] + JuliaFormatter v2.3.0 Updating `~/work/LinearElasticityBase.jl/LinearElasticityBase.jl/docs/build/developers/Manifest.toml` ⌅ [a80b9123] + CommonMark v0.10.3 [c27321d9] + Glob v1.4.0 [98e50ef6] + JuliaFormatter v2.3.0 ⌅ [70703baa] + JuliaSyntax v0.4.10 [aea7be01] + PrecompileTools v1.3.3 [21216c6a] + Preferences v1.5.2 [loaded: v1.3.0] [ade2ca70] + Dates v1.11.0 [de0858da] + Printf v1.11.0 [fa267f1f] + TOML v1.0.3 [4ec0a83e] + Unicode v1.11.0 Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m` Precompiling packages... 686.5 ms ✓ Glob 15052.8 ms ✓ CommonMark 19503.1 ms ✓ JuliaSyntax 32805.6 ms ✓ JuliaFormatter 4 dependencies successfully precompiled in 52 seconds. 6 already precompiled.julia> using JuliaFormatter: formatPrecompiling packages... 12349.3 ms ✓ CommonMark 32414.6 ms ✓ JuliaFormatter 2 dependencies successfully precompiled in 45 seconds. 8 already precompiled. Precompiling packages... 617.5 ms ✓ CommonMarkMarkdownExt (serial) 1 dependency successfully precompiled in 1 secondsjulia> format("docs");ERROR: IOError: realpath("docs"): no such file or directory (ENOENT)julia> format("src");ERROR: IOError: realpath("src"): no such file or directory (ENOENT)julia> format("test");ERROR: IOError: realpath("test"): no such file or directory (ENOENT)
A continuous integration check verifies that all PRs made to LinearElasticityBase have passed the formatter.
The following sections outline extra style guide points that are not fixed automatically by JuliaFormatter.
Use the Julia extension for Visual Studio Code
Please use VS Code with the Julia extension to edit, format, and test your code. We do not recommend using other editors to edit your code for the time being.
This extension already has JuliaFormatter integrated. So to format your code, follow the steps listed here.