Skip to content
This repository was archived by the owner on Mar 31, 2022. It is now read-only.

Commit 876a5e8

Browse files
authored
(#28) Simplify code and improve automation:
* Separate the preamble from the main body; * Automate the creation of documentation based on KIC ID.
1 parent d13aea5 commit 876a5e8

File tree

6 files changed

+41
-41222
lines changed

6 files changed

+41
-41222
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: julia
2-
dist: bionic
2+
dist: focal
33

44
notifications:
55
email: false

docs/convert.jl

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ notebooks_folder = normpath(joinpath(@__DIR__, "..", notebooks_folder_name))
1010
# Get paths to notebooks and their (base)names
1111
names = String[]
1212
notebooks = String[]
13+
preambles = String[]
1314
for (root, dirs, files) in walkdir(notebooks_folder)
1415
for file in files
15-
endswith(file, ".ipynb") && push!(notebooks, joinpath(root, file))
16+
if endswith(file, ".ipynb")
17+
name = replace(basename(file), ".ipynb" => "")
18+
push!(notebooks, joinpath(root, file))
19+
push!(names, name)
20+
contains(name, "KIC") && push!(preambles, name)
21+
end
1622
end
1723
end
18-
names = replace.(basename.(notebooks), ".ipynb" => "")
1924

2025
# Get path to the `make.jl` script
2126
make = joinpath(@__DIR__, "make.jl")
@@ -32,9 +37,20 @@ for (index, notebook) in enumerate(notebooks)
3237
# Get the name of the notebook
3338
name = names[index]
3439

35-
# Go to the folder of the notebook
36-
!isdir(name) && mkdir(name)
37-
cd(name)
40+
# Determine the preamble
41+
for preamble in preambles
42+
if name == preamble
43+
!isdir(name) && mkdir(name)
44+
cd(name)
45+
break
46+
elseif count(preamble, notebook) == 1
47+
!isdir(preamble) && mkdir(preamble)
48+
cd(preamble)
49+
!isdir(name) && mkdir(name)
50+
cd(name)
51+
break
52+
end
53+
end
3854

3955
# Construct the name of a Markdown file
4056
md = "$name.md"
@@ -89,9 +105,13 @@ for (index, notebook) in enumerate(notebooks)
89105
'\n',
90106
)
91107

108+
# Write the meta block
92109
open("$md", "w") do io
93110
lines[1] = meta_block * lines[1]
94111
print(io, join(lines, '\n'))
95112
end
96113

114+
# Go back to the output folder
115+
cd(output_folder)
116+
97117
end

docs/make.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@ makedocs(
1515
pages = [
1616
"Home" => "index.md",
1717
"Notebooks" => [
18-
"Kernels" => map(
19-
s -> "$s" => "generated/$notebooks_folder_name/$s/$s.md", names,
20-
),
18+
"$preamble" => pushfirst!(
19+
map(
20+
s -> "$s" => "generated/$notebooks_folder_name/$preamble/$s/$s.md",
21+
replace.(
22+
basename.(
23+
filter(notebook -> count(preamble, notebook) == 1, notebooks)
24+
),
25+
".ipynb" => ""
26+
),
27+
),
28+
"Preamble" => "generated/$notebooks_folder_name/$preamble/$preamble.md",
29+
)
30+
for preamble in preambles
2131
],
2232
],
2333

notebooks/DSS/DSS.ipynb

Lines changed: 0 additions & 41213 deletions
This file was deleted.

notebooks/KIC1430163/EQP/EQP.ipynb

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

notebooks/KIC1430163/KIC1430163.ipynb

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)