Skip to content

Commit ac6db6e

Browse files
authored
Merge pull request #49 from JuliaComputing/sp/formatter
chore: formatting and gh-action
2 parents 27a4f6a + 36fd938 commit ac6db6e

File tree

7 files changed

+169
-112
lines changed

7 files changed

+169
-112
lines changed

.github/workflows/CI.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,24 @@ jobs:
3939
${{ runner.os }}-
4040
- uses: julia-actions/julia-buildpkg@v1
4141
- uses: julia-actions/julia-runtest@v1
42+
julia-format:
43+
name: Formatter
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: julia-actions/setup-julia@latest
47+
- uses: actions/checkout@v1
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'

docs/make.jl

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,9 @@ using MultiDocumenter
33
clonedir = mktempdir()
44

55
docs = [
6-
MultiDocumenter.DropdownNav("Debugging", [
7-
MultiDocumenter.MultiDocRef(
8-
upstream = joinpath(clonedir, "Infiltrator"),
9-
path = "inf",
10-
name = "Infiltrator",
11-
giturl = "https://github.com/JuliaDebug/Infiltrator.jl.git",
12-
),
13-
MultiDocumenter.MultiDocRef(
14-
upstream = joinpath(clonedir, "JuliaInterpreter"),
15-
path = "debug",
16-
name = "JuliaInterpreter",
17-
giturl = "https://github.com/JuliaDebug/JuliaInterpreter.jl.git",
18-
),
19-
]),
20-
MultiDocumenter.MegaDropdownNav("Mega Debugger", [
21-
MultiDocumenter.Column("Column 1", [
6+
MultiDocumenter.DropdownNav(
7+
"Debugging",
8+
[
229
MultiDocumenter.MultiDocRef(
2310
upstream = joinpath(clonedir, "Infiltrator"),
2411
path = "inf",
@@ -31,22 +18,47 @@ docs = [
3118
name = "JuliaInterpreter",
3219
giturl = "https://github.com/JuliaDebug/JuliaInterpreter.jl.git",
3320
),
34-
]),
35-
MultiDocumenter.Column("Column 2", [
36-
MultiDocumenter.MultiDocRef(
37-
upstream = joinpath(clonedir, "Infiltrator"),
38-
path = "inf",
39-
name = "Infiltrator",
40-
giturl = "https://github.com/JuliaDebug/Infiltrator.jl.git",
21+
],
22+
),
23+
MultiDocumenter.MegaDropdownNav(
24+
"Mega Debugger",
25+
[
26+
MultiDocumenter.Column(
27+
"Column 1",
28+
[
29+
MultiDocumenter.MultiDocRef(
30+
upstream = joinpath(clonedir, "Infiltrator"),
31+
path = "inf",
32+
name = "Infiltrator",
33+
giturl = "https://github.com/JuliaDebug/Infiltrator.jl.git",
34+
),
35+
MultiDocumenter.MultiDocRef(
36+
upstream = joinpath(clonedir, "JuliaInterpreter"),
37+
path = "debug",
38+
name = "JuliaInterpreter",
39+
giturl = "https://github.com/JuliaDebug/JuliaInterpreter.jl.git",
40+
),
41+
],
4142
),
42-
MultiDocumenter.MultiDocRef(
43-
upstream = joinpath(clonedir, "JuliaInterpreter"),
44-
path = "debug",
45-
name = "JuliaInterpreter",
46-
giturl = "https://github.com/JuliaDebug/JuliaInterpreter.jl.git",
43+
MultiDocumenter.Column(
44+
"Column 2",
45+
[
46+
MultiDocumenter.MultiDocRef(
47+
upstream = joinpath(clonedir, "Infiltrator"),
48+
path = "inf",
49+
name = "Infiltrator",
50+
giturl = "https://github.com/JuliaDebug/Infiltrator.jl.git",
51+
),
52+
MultiDocumenter.MultiDocRef(
53+
upstream = joinpath(clonedir, "JuliaInterpreter"),
54+
path = "debug",
55+
name = "JuliaInterpreter",
56+
giturl = "https://github.com/JuliaDebug/JuliaInterpreter.jl.git",
57+
),
58+
],
4759
),
48-
]),
49-
]),
60+
],
61+
),
5062
MultiDocumenter.MultiDocRef(
5163
upstream = joinpath(clonedir, "DataSets"),
5264
path = "data",
@@ -64,7 +76,7 @@ MultiDocumenter.make(
6476
docs;
6577
search_engine = MultiDocumenter.SearchConfig(
6678
index_versions = ["stable"],
67-
engine = MultiDocumenter.FlexSearch
79+
engine = MultiDocumenter.FlexSearch,
6880
),
6981
rootpath = "/MultiDocumenter.jl/",
7082
)
@@ -98,4 +110,4 @@ if success(`git commit -m 'Aggregate documentation'`)
98110
run(`git checkout main`)
99111
else
100112
@info "No changes to aggregated documentation."
101-
end
113+
end

src/MultiDocumenter.jl

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ struct DropdownNav
4040
end
4141

4242
struct Column
43-
name
43+
name::Any
4444
children::Vector{MultiDocRef}
4545
end
4646

4747
struct MegaDropdownNav
48-
name
48+
name::Any
4949
columns::Vector{Column}
5050
end
5151

@@ -144,7 +144,12 @@ function make(
144144
)
145145

146146
if search_engine != false
147-
search_engine.engine.build_search_index(dir, flatten_multidocrefs(docs), search_engine, rootpath)
147+
search_engine.engine.build_search_index(
148+
dir,
149+
flatten_multidocrefs(docs),
150+
search_engine,
151+
rootpath,
152+
)
148153
end
149154

150155
cp(dir, outdir; force = true)
@@ -242,17 +247,13 @@ function make_global_stylesheet(custom_stylesheets, path)
242247
out = []
243248

244249
for stylesheet in custom_stylesheets
245-
stylesheet = startswith(stylesheet, r"https?://") ?
246-
stylesheet :
250+
stylesheet =
251+
startswith(stylesheet, r"https?://") ? stylesheet :
247252
replace(joinpath(path, stylesheet), raw"\\" => "/")
248253
style = Gumbo.HTMLElement{:link}(
249254
[],
250255
Gumbo.NullNode(),
251-
Dict(
252-
"rel" => "stylesheet",
253-
"type" => "text/css",
254-
"href" => stylesheet,
255-
),
256+
Dict("rel" => "stylesheet", "type" => "text/css", "href" => stylesheet),
256257
)
257258
push!(out, style)
258259
end
@@ -268,29 +269,26 @@ function make_global_scripts(custom_scripts, path)
268269
js = Gumbo.HTMLElement{:script}(
269270
[],
270271
Gumbo.NullNode(),
271-
Dict(
272-
"type" => "text/javascript",
273-
"charset" => "utf-8",
274-
),
272+
Dict("type" => "text/javascript", "charset" => "utf-8"),
275273
)
276274
push!(js, Gumbo.HTMLText(js, script.content))
277275
push!(out, js)
278276
elseif script isa AbstractString
279-
script = startswith(script, r"https?://") ?
280-
script :
277+
script =
278+
startswith(script, r"https?://") ? script :
281279
replace(joinpath(path, script), raw"\\" => "/")
282280
js = Gumbo.HTMLElement{:script}(
283281
[],
284282
Gumbo.NullNode(),
285-
Dict(
286-
"src" => script,
287-
"type" => "text/javascript",
288-
"charset" => "utf-8",
289-
),
283+
Dict("src" => script, "type" => "text/javascript", "charset" => "utf-8"),
290284
)
291285
push!(out, js)
292286
else
293-
throw(ArgumentError("`custom_scripts` may only contain elements of type `AbstractString` or `Docs.HTML`."))
287+
throw(
288+
ArgumentError(
289+
"`custom_scripts` may only contain elements of type `AbstractString` or `Docs.HTML`.",
290+
),
291+
)
294292
end
295293
end
296294

@@ -360,7 +358,7 @@ function inject_styles_and_global_navigation(
360358
elseif Gumbo.tag(el) == :body && !isempty(el.children)
361359
documenter_div = first(el.children)
362360
if documenter_div isa Gumbo.HTMLElement &&
363-
Gumbo.getattr(documenter_div, "id", "") == "documenter"
361+
Gumbo.getattr(documenter_div, "id", "") == "documenter"
364362
@debug "Could not detect Documenter page layout in $path. This may be due to an old version of Documenter."
365363
end
366364
# inject global navigation as first element in body
@@ -388,4 +386,4 @@ function inject_styles_and_global_navigation(
388386
end
389387
end
390388

391-
end
389+
end

src/renderers.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
render(::Nothing, args...) = nothing
22

33
function render(brand_image::BrandImage, dir, thispagepath)
4-
href = startswith(brand_image.path, r"https?://") ?
5-
brand_image.path :
4+
href =
5+
startswith(brand_image.path, r"https?://") ? brand_image.path :
66
relpath(joinpath(dir, brand_image.path), thispagepath)
7-
src = startswith(brand_image.imagepath, r"https?://") ?
8-
brand_image.imagepath :
7+
src =
8+
startswith(brand_image.imagepath, r"https?://") ? brand_image.imagepath :
99
relpath(joinpath(dir, brand_image.imagepath), thispagepath)
1010
return @htl """
1111
<a class="brand" href="$(href)">
@@ -27,8 +27,9 @@ function render(doc::MultiDocRef, dir, thispagepath, prettyurls)
2727
rp = relpath(path, thispagepath)
2828
href = string(rp, prettyurls ? "/" : "/index.html")
2929
# need to force a trailing pathsep here
30-
class = startswith(thispagepath, joinpath(dir, doc.path, "")) ?
31-
"nav-link active nav-item" : "nav-link nav-item"
30+
class =
31+
startswith(thispagepath, joinpath(dir, doc.path, "")) ? "nav-link active nav-item" :
32+
"nav-link nav-item"
3233

3334
return @htl """
3435
<a href="$href" class="$class">$(doc.name)</a>

src/search/flexsearch.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ end
9797
function inject_script!(custom_scripts, rootpath)
9898
pushfirst!(custom_scripts, joinpath("assets", "default", "flexsearch_integration.js"))
9999
pushfirst!(custom_scripts, joinpath("assets", "default", "flexsearch.bundle.js"))
100-
pushfirst!(custom_scripts, Docs.HTML("window.MULTIDOCUMENTER_ROOT_PATH = '$(rootpath)'"))
100+
pushfirst!(
101+
custom_scripts,
102+
Docs.HTML("window.MULTIDOCUMENTER_ROOT_PATH = '$(rootpath)'"),
103+
)
101104
end
102105

103106
function inject_styles!(custom_styles)
@@ -148,10 +151,8 @@ function build_search_index(root, docs, config, rootpath)
148151
file = config.lowfi ? "gensearch-lowfi.js" : "gensearch.js"
149152
println("Writing $(config.lowfi ? "lowfi" : "") flexsearch index:")
150153
cd(root) do
151-
run(
152-
`$(NodeJS.nodejs_cmd()) $(joinpath(@__DIR__, "..", "..", "flexsearch", file))`,
153-
)
154+
run(`$(NodeJS.nodejs_cmd()) $(joinpath(@__DIR__, "..", "..", "flexsearch", file))`)
154155
end
155156
return nothing
156157
end
157-
end
158+
end

src/search/stork.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ function render()
7979
</div>
8080
"""
8181
end
82-
end
82+
end

0 commit comments

Comments
 (0)