Skip to content

Commit 7713a29

Browse files
committed
chore: use runic instead of JuliaFormatter
1 parent 7d48b09 commit 7713a29

File tree

12 files changed

+200
-167
lines changed

12 files changed

+200
-167
lines changed

.JuliaFormatter.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/CI.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,15 @@ jobs:
3939
${{ runner.os }}-
4040
- uses: julia-actions/julia-buildpkg@v1
4141
- uses: julia-actions/julia-runtest@v1
42-
julia-format:
43-
name: Formatter
42+
runic:
43+
name: Runic formatting
4444
runs-on: ubuntu-latest
4545
steps:
46-
- uses: julia-actions/setup-julia@latest
4746
- uses: actions/checkout@v4
48-
- name: Install JuliaFormatter and format
49-
run: |
50-
julia --color=yes -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
51-
julia --color=yes -e 'using JuliaFormatter; format(".", verbose=true)'
52-
- name: Format check
53-
run: |
54-
julia --color=yes -e '
55-
out = Cmd(`git diff --name-only`) |> read |> String
56-
if out == ""
57-
exit(0)
58-
else
59-
@error "Some files have not been formatted !!!"
60-
write(stdout, out)
61-
exit(1)
62-
end'
47+
- uses: julia-actions/setup-julia@v2
48+
with:
49+
version: '1.11'
50+
- uses: julia-actions/cache@v2
51+
- uses: fredrikekre/runic-action@v1
52+
with:
53+
version: '1'

docs/make.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ open(joinpath(@__DIR__, "src", "index.md"), write = true) do io
2323
io,
2424
"""
2525
26-
## Docstrings
26+
## Docstrings
2727
28-
```@autodocs
29-
Modules = [MultiDocumenter]
30-
```
31-
""",
28+
```@autodocs
29+
Modules = [MultiDocumenter]
30+
```
31+
""",
3232
)
3333
end
3434
cp(

src/MultiDocumenter.jl

Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ using HypertextLiteral
55
import Git: git
66

77
module DocumenterTools
8-
import Gumbo, AbstractTrees
9-
include("documentertools/walkdocs.jl")
10-
include("documentertools/canonical_urls.jl")
8+
import Gumbo, AbstractTrees
9+
include("documentertools/walkdocs.jl")
10+
include("documentertools/canonical_urls.jl")
1111
end
1212

1313
"""
@@ -72,14 +72,14 @@ struct MultiDocRef <: DropdownComponent
7272
end
7373

7474
function MultiDocRef(;
75-
upstream,
76-
name,
77-
path,
78-
giturl = "",
79-
branch = "gh-pages",
80-
fix_canonical_url = true,
81-
)
82-
MultiDocRef(upstream, path, name, fix_canonical_url, giturl, branch)
75+
upstream,
76+
name,
77+
path,
78+
giturl = "",
79+
branch = "gh-pages",
80+
fix_canonical_url = true,
81+
)
82+
return MultiDocRef(upstream, path, name, fix_canonical_url, giturl, branch)
8383
end
8484

8585
"""
@@ -128,6 +128,7 @@ function walk_outputs(f, root, docs::Vector, dirs::Vector{String})
128128
break
129129
end
130130
end
131+
return
131132
end
132133

133134
include("renderers.jl")
@@ -175,22 +176,22 @@ Aggregates multiple Documenter.jl-based documentation pages `docs` into `outdir`
175176
- `sitemap_filename` can be used to override the default sitemap filename (`sitemap.xml`)
176177
"""
177178
function make(
178-
outdir,
179-
docs::Vector;
180-
assets_dir = nothing,
181-
brand_image::Union{Nothing,BrandImage} = nothing,
182-
custom_stylesheets = [],
183-
custom_scripts = [],
184-
search_engine = DEFAULT_ENGINE,
185-
prettyurls = true,
186-
rootpath = "/",
187-
hide_previews = true,
188-
canonical_domain::Union{AbstractString,Nothing} = nothing,
189-
sitemap::Bool = false,
190-
sitemap_filename::AbstractString = "sitemap.xml",
191-
# This keyword is for internal test use only:
192-
_override_windows_isinteractive_check::Bool = false,
193-
)
179+
outdir,
180+
docs::Vector;
181+
assets_dir = nothing,
182+
brand_image::Union{Nothing, BrandImage} = nothing,
183+
custom_stylesheets = [],
184+
custom_scripts = [],
185+
search_engine = DEFAULT_ENGINE,
186+
prettyurls = true,
187+
rootpath = "/",
188+
hide_previews = true,
189+
canonical_domain::Union{AbstractString, Nothing} = nothing,
190+
sitemap::Bool = false,
191+
sitemap_filename::AbstractString = "sitemap.xml",
192+
# This keyword is for internal test use only:
193+
_override_windows_isinteractive_check::Bool = false,
194+
)
194195
if Sys.iswindows() && !isinteractive()
195196
if _override_windows_isinteractive_check || isinteractive()
196197
@warn """
@@ -214,9 +215,13 @@ function make(
214215
else
215216
!isnothing(canonical_domain)
216217
if !startswith(canonical_domain, r"^https?://")
217-
throw(ArgumentError("""
218-
Invalid value for canonical_domain: $(canonical_domain)
219-
Must start with http:// or https://"""))
218+
throw(
219+
ArgumentError(
220+
"""
221+
Invalid value for canonical_domain: $(canonical_domain)
222+
Must start with http:// or https://"""
223+
)
224+
)
220225
end
221226
# We'll strip any trailing /-s though, in case the user passed something like
222227
# https://example.org/, because we want to concatenate the file paths with `/`
@@ -337,15 +342,15 @@ function maybe_clone(docs::Vector)
337342
end
338343
end
339344
end
340-
return nothing
345+
return
341346
end
342347

343348
function make_output_structure(
344-
docs::Vector{DropdownComponent},
345-
prettyurls,
346-
hide_previews;
347-
canonical::Union{AbstractString,Nothing},
348-
)
349+
docs::Vector{DropdownComponent},
350+
prettyurls,
351+
hide_previews;
352+
canonical::Union{AbstractString, Nothing},
353+
)
349354
dir = mktempdir()
350355

351356
for doc in Iterators.filter(x -> x isa MultiDocRef, docs)
@@ -381,13 +386,13 @@ function make_output_structure(
381386
end
382387

383388
function make_global_nav(
384-
dir,
385-
docs::Vector,
386-
thispagepath,
387-
brand_image,
388-
search_engine,
389-
prettyurls,
390-
)
389+
dir,
390+
docs::Vector,
391+
thispagepath,
392+
brand_image,
393+
search_engine,
394+
prettyurls,
395+
)
391396
nav = @htl """
392397
<nav id="multi-page-nav">
393398
$(render(brand_image, dir, thispagepath))
@@ -464,15 +469,15 @@ end
464469

465470

466471
function inject_styles_and_global_navigation(
467-
dir,
468-
docs::Vector,
469-
brand_image,
470-
custom_stylesheets,
471-
custom_scripts,
472-
search_engine,
473-
prettyurls,
474-
rootpath,
475-
)
472+
dir,
473+
docs::Vector,
474+
brand_image,
475+
custom_stylesheets,
476+
custom_scripts,
477+
search_engine,
478+
prettyurls,
479+
rootpath,
480+
)
476481

477482
if search_engine != false
478483
search_engine.engine.inject_script!(custom_scripts, rootpath)
@@ -491,9 +496,9 @@ function inject_styles_and_global_navigation(
491496
isfile(path) || continue
492497
page = read(path, String)
493498
if startswith(
494-
page,
495-
"<!--This file is automatically generated by Documenter.jl-->",
496-
)
499+
page,
500+
"<!--This file is automatically generated by Documenter.jl-->",
501+
)
497502
continue
498503
end
499504

@@ -521,7 +526,7 @@ function inject_styles_and_global_navigation(
521526
elseif Gumbo.tag(el) == :body && !isempty(el.children)
522527
documenter_div = first(el.children)
523528
if documenter_div isa Gumbo.HTMLElement &&
524-
Gumbo.getattr(documenter_div, "id", "") == "documenter"
529+
Gumbo.getattr(documenter_div, "id", "") == "documenter"
525530
@debug "Could not detect Documenter page layout in $path. This may be due to an old version of Documenter."
526531
end
527532
# inject global navigation as first element in body
@@ -547,6 +552,8 @@ function inject_styles_and_global_navigation(
547552
end
548553
end
549554
end
555+
556+
return
550557
end
551558

552559
end

src/canonical.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# This files contains the functions used to implement the canonical URL
22
# update functionality.
33
function fix_canonical_url!(
4-
doc::MultiDocRef;
5-
canonical::Union{AbstractString,Nothing},
6-
root_dir::AbstractString,
7-
)
4+
doc::MultiDocRef;
5+
canonical::Union{AbstractString, Nothing},
6+
root_dir::AbstractString,
7+
)
88
# If the user didn't set `canonical`, then we don't need to do anything
9-
isnothing(canonical) && return nothing
9+
isnothing(canonical) && return
1010
# The user can also disable the canonical URL fixing on a per-package basis
11-
doc.fix_canonical_url || return nothing
11+
doc.fix_canonical_url || return
1212
# Determine the canonical URL and fix them in the HTML files
1313
documenter_directory_root = joinpath(root_dir, doc.path)
1414
try
@@ -20,4 +20,6 @@ function fix_canonical_url!(
2020
@error "Unable to update canonical URLs for this package" doc exception =
2121
(e, catch_backtrace())
2222
end
23+
24+
return
2325
end

src/documentertools/canonical_urls.jl

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
specifying the root of the canonical URL.
1717
"""
1818
function update_canonical_links_for_version(
19-
docs_directory::AbstractString;
20-
canonical::AbstractString,
21-
)
19+
docs_directory::AbstractString;
20+
canonical::AbstractString,
21+
)
2222
canonical = rstrip(canonical, '/')
2323

2424
walkdocs(docs_directory, isdochtml) do fileinfo
2525
@debug "update_canonical_links: checking $(fileinfo.relpath)"
2626
# Determine the
2727
filepath = splitpath(fileinfo.relpath)
2828
new_canonical_href = if filepath[end] == "index.html"
29-
joinurl(canonical, filepath[1:end-1]...) * '/'
29+
joinurl(canonical, filepath[1:(end - 1)]...) * '/'
3030
else
3131
joinurl(canonical, filepath[1:end]...)
3232
end
@@ -66,6 +66,7 @@ function update_canonical_links_for_version(
6666
@error "Multiple canonical tags!" file = fileinfo.relpath
6767
end
6868
end
69+
return
6970
end
7071

7172
is_canonical_element(e) =
@@ -123,14 +124,15 @@ function update_canonical_links(docs_directory::AbstractString; canonical::Abstr
123124
@debug "Updating canonical URLs for a version" path canonical_full_root
124125
update_canonical_links_for_version(path; canonical = canonical_full_root)
125126
end
127+
return
126128
end
127129

128130
function canonical_directory_from_redirect_index_html(docs_directory::AbstractString)
129131
redirect_index_html_path = joinpath(docs_directory, "index.html")
130132
isfile(redirect_index_html_path) || return nothing
131133
redirect_url = get_meta_redirect_url(redirect_index_html_path)
132134
isnothing(redirect_url) && return nothing
133-
splitpath(normpath(redirect_url))
135+
return splitpath(normpath(redirect_url))
134136
end
135137

136138
"""
@@ -235,16 +237,24 @@ function extract_versions_list(versions_js::AbstractString)
235237
versions_js_content = read(versions_js, String)
236238
m = match(r"var\s+DOC_VERSIONS\s*=\s*\[([0-9A-Za-z\"\s.,+-]+)\]", versions_js_content)
237239
if isnothing(m)
238-
throw(ArgumentError("""
239-
Could not find DOC_VERSIONS in $(versions_js):
240-
$(versions_js_content)"""))
240+
throw(
241+
ArgumentError(
242+
"""
243+
Could not find DOC_VERSIONS in $(versions_js):
244+
$(versions_js_content)"""
245+
)
246+
)
241247
end
242248
versions = strip.(c -> isspace(c) || (c == '"'), split(m[1], ","))
243249
filter!(!isempty, versions)
244250
if isempty(versions)
245-
throw(ArgumentError("""
246-
DOC_VERSIONS empty in $(versions_js):
247-
$(versions_js_content)"""))
251+
throw(
252+
ArgumentError(
253+
"""
254+
DOC_VERSIONS empty in $(versions_js):
255+
$(versions_js_content)"""
256+
)
257+
)
248258
end
249259
return versions
250260
end

0 commit comments

Comments
 (0)