Skip to content

Commit 087e465

Browse files
authored
chore: impose JuliaFormatter on the codebase (#49)
1 parent 3a4702a commit 087e465

File tree

9 files changed

+287
-140
lines changed

9 files changed

+287
-140
lines changed

.JuliaFormatter.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
style = "blue"
2+
indent = 4
3+
margin = 100
4+
always_for_in = "nothing"
5+
whitespace_typedefs = true
6+
whitespace_ops_in_indices = true
7+
remove_extra_newlines = false
8+
import_to_using = false
9+
pipe_to_function_call = false
10+
short_to_long_function_def = false
11+
always_use_return = false
12+
whitespace_in_kwargs = false
13+
annotate_untyped_fields_with_any = false
14+
format_docstrings = false
15+
align_struct_field = true
16+
align_assignment = true
17+
align_conditional = true
18+
align_pair_arrow = true
19+
conditional_to_if = false
20+
normalize_line_endings = "auto"
21+
align_matrix = false
22+
join_lines_based_on_source = true
23+
trailing_comma = true
24+
indent_submodule = true
25+
ignore = [".git"]

.github/workflows/format-julia.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Format: Julia"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- "**.jl"
8+
- ".JuliaFormatter.toml"
9+
- ".github/workflows/format-julia.yaml"
10+
# Note: no path filtering when running on PRs, since the formatter
11+
# is a required check, and therefore needs to always run.
12+
pull_request:
13+
types:
14+
- opened
15+
- reopened
16+
- synchronize
17+
- ready_for_review
18+
- labeled
19+
20+
env:
21+
CI: true
22+
23+
jobs:
24+
format:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: julia-actions/julia-format@v4
28+
with:
29+
# Version compat for JuliaFormatter.jl (default: '1')
30+
# E.g. set to '1.0.54' if you need to use JuliaFormatter.jl v1.0.54
31+
version: '1'
32+
# GitHub PR label that enabled formatting suggestions.
33+
# Leave this unset or empty to show suggestions for all PRs.
34+
suggestion-label: 'format-suggest'

bin/structure.jl

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,28 @@ import InteractiveUtils, Markdown, TextWrap
55

66
# Rather than generating the file directly, we'll write the output to a buffer
77
# first, so that we wouldn't end up with a partial file if there is some error.
8-
buffer = let buffer = IOBuffer(write=true)
9-
write(buffer, """
10-
# Internal State Machine
8+
buffer = let buffer = IOBuffer(; write=true)
9+
write(
10+
buffer,
11+
"""
12+
# Internal State Machine
1113
12-
The authentication control flow is implemented as the following state machine, starting from the `NeedAuthentication`
13-
state (or `NoAuthentication` if `force=true` is passed to `authenticate`), and finishing in either `Success` or `Failure`.
14+
The authentication control flow is implemented as the following state machine, starting from the `NeedAuthentication`
15+
state (or `NoAuthentication` if `force=true` is passed to `authenticate`), and finishing in either `Success` or `Failure`.
1416
15-
```mermaid
16-
---
17-
title: PkgAuthentication state machine diagram
18-
---
17+
```mermaid
18+
---
19+
title: PkgAuthentication state machine diagram
20+
---
1921
20-
stateDiagram-v2
22+
stateDiagram-v2
2123
22-
[*] --> NeedAuthentication
23-
[*] --> NoAuthentication
24-
""")
24+
[*] --> NeedAuthentication
25+
[*] --> NoAuthentication
26+
""",
27+
)
2528

26-
all_targets = Dict{String,Vector{String}}()
29+
all_targets = Dict{String, Vector{String}}()
2730
ignore_errors = (
2831
PkgAuthentication.Failure, PkgAuthentication.Success
2932
)
@@ -34,7 +37,7 @@ buffer = let buffer = IOBuffer(write=true)
3437
end
3538
end
3639
choice_index = 0
37-
for state in sort(InteractiveUtils.subtypes(PkgAuthentication.State), by=string)
40+
for state in sort(InteractiveUtils.subtypes(PkgAuthentication.State); by=string)
3841
println(buffer)
3942
state_str = string(nameof(state))
4043
# Generate the connecting arrows between the states
@@ -64,8 +67,8 @@ buffer = let buffer = IOBuffer(write=true)
6467
docstr_text = docstr.meta[:results][1].text[1]
6568
println(buffer, " note left of $(state_str)")
6669
TextWrap.print_wrapped(
67-
buffer, docstr_text, width=65,
68-
initial_indent = 8, subsequent_indent = 8,
70+
buffer, docstr_text; width=65,
71+
initial_indent=8, subsequent_indent=8,
6972
)
7073
println(buffer)
7174
println(buffer, " end note")
@@ -76,13 +79,16 @@ buffer = let buffer = IOBuffer(write=true)
7679
end
7780
end
7881

79-
write(buffer, """
80-
Success --> [*]
81-
Failure --> [*]
82-
```
82+
write(
83+
buffer,
84+
"""
85+
Success --> [*]
86+
Failure --> [*]
87+
```
8388
84-
> **Note** This file is automatically generated by the `bin/structure.jl` script.
85-
""")
89+
> **Note** This file is automatically generated by the `bin/structure.jl` script.
90+
""",
91+
)
8692

8793
take!(buffer)
8894
end

0 commit comments

Comments
 (0)