Repository navigation
Extend description of JuliaFormatter.jl and add Runic.jl #150
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -161,22 +161,42 @@ For local coverage analysis, [LocalCoverage.jl](https://github.com/JuliaCI/Local | |||||
| ## Style | ||||||
|
|
||||||
| To make your code easy to read, it is essential to follow a consistent set of guidelines. | ||||||
| The official [style guide](https://docs.julialang.org/en/v1/manual/style-guide/) is very short, so most people use third party style guides like [BlueStyle](https://github.com/JuliaDiff/BlueStyle) or [SciMLStyle](https://github.com/SciML/SciMLStyle). | ||||||
| The official [style guide](https://docs.julialang.org/en/v1/manual/style-guide/) is very short, so most people use third party style guides like [BlueStyle](https://github.com/JuliaDiff/BlueStyle), [SciMLStyle](https://github.com/SciML/SciMLStyle), or [YASGuide](https://github.com/jrevels/YASGuide). | ||||||
|
|
||||||
| [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) is an automated formatter for Julia files which can help you enforce the style guide of your choice. | ||||||
| ### JuliaFormatter.jl | ||||||
|
|
||||||
| [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) is an automated formatter for Julia files which can help you enforce the style of your choice, being either a predefined style (["default"](https://juliaeditorsupport.github.io/JuliaFormatter.jl/stable/default_style/), ["blue"](https://juliaeditorsupport.github.io/JuliaFormatter.jl/stable/blue_style/), ["sciml"](https://juliaeditorsupport.github.io/JuliaFormatter.jl/stable/sciml_style/), or ["yas"](https://juliaeditorsupport.github.io/JuliaFormatter.jl/stable/yas_style/)) or a customized version of them. | ||||||
| Just add a file `.JuliaFormatter.toml` at the root of your repository, containing a single line like | ||||||
|
|
||||||
| ```toml | ||||||
| style = "blue" | ||||||
| ``` | ||||||
|
|
||||||
| To override the defaults of the chosen style, you can add additional lines: | ||||||
|
|
||||||
| ```toml | ||||||
| style = "blue" | ||||||
| indent = 2 | ||||||
| margin = 100 | ||||||
| remove_extra_newlines = false | ||||||
| ``` | ||||||
|
|
||||||
|
Comment on lines
+175
to
+183
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could keep MoJuWo a bit more concise by linking to the JuliaFormatter options instead: https://juliaeditorsupport.github.io/JuliaFormatter.jl/stable/formatting_options/#formatting-options This also helps avoid drift. |
||||||
| Then, the package directory will be formatted in the BlueStyle whenever you call | ||||||
|
|
||||||
| ```>format | ||||||
| using JuliaFormatter | ||||||
| JuliaFormatter.format(MyAwesomePackage) | ||||||
| ``` | ||||||
|
|
||||||
| Or you can install it as a command-line application: | ||||||
| ```bash | ||||||
| # Install it once with: | ||||||
| julia -e 'using Pkg; Pkg.Apps.add("JuliaFormatter")' | ||||||
|
|
||||||
| # Then you can use it to format all files in a directory with multiple threads: | ||||||
| jlfmt --threads=6 -- --inplace -v src/ | ||||||
| ``` | ||||||
|
Comment on lines
+191
to
+198
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this section is a great addition.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also wondering what the extra |
||||||
|
|
||||||
| {% <vscode> %} | ||||||
|
|
||||||
| The [default formatter](https://www.julia-vscode.org/docs/stable/userguide/formatter/) falls back on JuliaFormatter.jl. | ||||||
|
|
@@ -187,6 +207,20 @@ The [default formatter](https://www.julia-vscode.org/docs/stable/userguide/forma | |||||
| You can format code automatically in GitHub pull requests with the [`julia-format` action](https://github.com/julia-actions/julia-format), or add the formatting check directly to your test suite. | ||||||
| {% </advanced> %} | ||||||
|
|
||||||
| ### Runic.jl | ||||||
|
|
||||||
| Another approach, taken by [Runic.jl](https://github.com/fredrikekre/Runic.jl), is not to allow any customization, and format the code with a fixed set of rules (_"A code formatter with rules set in stone."_). It is known for its ease of use and very fast execution. | ||||||
|
|
||||||
| Run the following to install and run as a command-line application: | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ```bash | ||||||
| # Install it once as a Julia App: | ||||||
| julia -e 'using Pkg; Pkg.Apps.add("Runic")' | ||||||
|
|
||||||
| # Run this to format all files in-place in the current directory (recursively) | ||||||
| runic --inplace . | ||||||
| ``` | ||||||
|
|
||||||
|
|
||||||
| ## Code quality | ||||||
|
|
||||||
| Of course, there is more to code quality than just formatting. | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think "YASGuide" is as popular as Blue/SciML/Runic, is there a particular reason you want to add it?