Skip to content

Commit

Permalink
automatic code formatting (#11)
Browse files Browse the repository at this point in the history
* add format check

* format

* fix deleted comment
  • Loading branch information
ranocha authored Nov 3, 2023
1 parent 74114bc commit ea33703
Show file tree
Hide file tree
Showing 11 changed files with 458 additions and 372 deletions.
8 changes: 8 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Use SciML style: https://github.com/SciML/SciMLStyle
style = "sciml"

# Python style alignment. See https://github.com/domluna/JuliaFormatter.jl/pull/732.
yas_style_nesting = true

# Align struct fields for better readability of large struct definitions
align_struct_field = true
41 changes: 41 additions & 0 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: format-check

on:
push:
branches:
- 'main'
tags: '*'
pull_request:

jobs:
check-format:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1]
julia-arch: [x86]
os: [ubuntu-latest]
steps:
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v4
- name: Install JuliaFormatter and format
# This will use the latest version by default but you can set the version like so:
#
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name = "JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose = true)'
- name: Format check
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
out_verbose = Cmd(`git diff`) |> read |> String
if out == ""
exit(0)
else
@error "Some files have not been formatted !!!" out out_verbose
exit(1)
end'
88 changes: 41 additions & 47 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,55 @@ using PositiveIntegrators

# Define module-wide setups such that the respective modules are available in doctests
DocMeta.setdocmeta!(PositiveIntegrators,
:DocTestSetup, :(using PositiveIntegrators); recursive=true)
:DocTestSetup, :(using PositiveIntegrators); recursive = true)

# Copy some files from the top level directory to the docs and modify them
# as necessary
open(joinpath(@__DIR__, "src", "license.md"), "w") do io
# Point to source license file
println(io, """
```@meta
EditURL = "https://github.com/SKopecz/PositiveIntegrators.jl/blob/main/LICENSE.md"
```
""")
# Write the modified contents
println(io, "# License")
println(io, "")
for line in eachline(joinpath(dirname(@__DIR__), "LICENSE"))
line = replace(line, "[LICENSE.md](LICENSE.md)" => "[License](@ref)")
println(io, "> ", line)
end
# Point to source license file
println(io, """
```@meta
EditURL = "https://github.com/SKopecz/PositiveIntegrators.jl/blob/main/LICENSE.md"
```
""")
# Write the modified contents
println(io, "# License")
println(io, "")
for line in eachline(joinpath(dirname(@__DIR__), "LICENSE"))
line = replace(line, "[LICENSE.md](LICENSE.md)" => "[License](@ref)")
println(io, "> ", line)
end
end

open(joinpath(@__DIR__, "src", "contributing.md"), "w") do io
# Point to source license file
println(io, """
```@meta
EditURL = "https://github.com/SKopecz/PositiveIntegrators.jl/blob/main/CONTRIBUTING.md"
```
""")
# Write the modified contents
println(io, "# Contributing")
println(io, "")
for line in eachline(joinpath(dirname(@__DIR__), "CONTRIBUTING.md"))
line = replace(line, "[LICENSE.md](LICENSE.md)" => "[License](@ref)")
println(io, "> ", line)
end
# Point to source license file
println(io, """
```@meta
EditURL = "https://github.com/SKopecz/PositiveIntegrators.jl/blob/main/CONTRIBUTING.md"
```
""")
# Write the modified contents
println(io, "# Contributing")
println(io, "")
for line in eachline(joinpath(dirname(@__DIR__), "CONTRIBUTING.md"))
line = replace(line, "[LICENSE.md](LICENSE.md)" => "[License](@ref)")
println(io, "> ", line)
end
end

# Make documentation
makedocs(
modules = [PositiveIntegrators],
sitename="PositiveIntegrators.jl",
format = Documenter.HTML(
prettyurls = get(ENV, "CI", nothing) == "true",
canonical = "https://SKopecz.github.io/PositiveIntegrators.jl/stable"
),
# Explicitly specify documentation structure
pages = [
"Home" => "index.md",
"API reference" => "api_reference.md",
"Contributing" => "contributing.md",
"License" => "license.md"
]
)
makedocs(modules = [PositiveIntegrators],
sitename = "PositiveIntegrators.jl",
format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true",
canonical = "https://SKopecz.github.io/PositiveIntegrators.jl/stable"),
# Explicitly specify documentation structure
pages = [
"Home" => "index.md",
"API reference" => "api_reference.md",
"Contributing" => "contributing.md",
"License" => "license.md",
])

deploydocs(
repo = "github.com/SKopecz/PositiveIntegrators.jl",
devbranch = "main",
push_preview = true
)
deploydocs(repo = "github.com/SKopecz/PositiveIntegrators.jl",
devbranch = "main",
push_preview = true)
Loading

0 comments on commit ea33703

Please sign in to comment.