-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathgenerate-READMEs.jl
More file actions
34 lines (29 loc) · 894 Bytes
/
generate-READMEs.jl
File metadata and controls
34 lines (29 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# find julia files to be converted into README.md
function gernerate_README(examplestoconvert, folder)
ps = map(examplestoconvert) do str
fs = filter(s -> split(s, ".")[end] == "jl", readdir(folder*str))
if length(fs) > 0
[str, fs[1]]
else
String[]
end
end
filter!(p -> p != String[], ps)
# This code below writes the README.md
for p in ps
s1 = string(folder,p[1],"/",p[2])
str_arr = split(read(open(s1,"r"), String), "\n")
# convert to md format
str_arr = map(str_arr) do s
if length(s) > 2 && s[1] == '#' && s[2] == ' '
string(s[3:end],"\n")
else
string(s,"\n")
end
end
s2 = string(folder,p[1],"/README.md")
f = open(s2,"w")
write(f, string(str_arr...))
close(f)
end
end