Skip to content
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

automatic code formatting #11

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
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
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