Skip to content

Instantly share code, notes, and snippets.

@SimonDanisch
Created November 26, 2017 13:30
Show Gist options
  • Save SimonDanisch/6f1b7097fde57272ca96c2e01355c37e to your computer and use it in GitHub Desktop.
Save SimonDanisch/6f1b7097fde57272ca96c2e01355c37e to your computer and use it in GitHub Desktop.
function find_jl_files(dir, files = String[])
for file in readdir(dir)
path = joinpath(dir, file)
if endswith(path, ".jl")
push!(files, path)
elseif isdir(path)
find_jl_files(path, files)
end
end
files
end
function count_lines(file)
str = readstring(file)
str = replace(str, r"#=.*=#"m, "")
str = replace(str, r"#.*\n", "")
lines = split(str, "\n")
lines = filter(x->!isempty(x), lines)
length(lines)
end
function recursive_loc(pkg, reclevel = typemax(Int), visited = Set(String[]); excludes = ())
result = mapreduce(count_lines, +, find_jl_files(Pkg.dir(pkg, "src")))
println(pkg, ": ", result)
require = readstring(Pkg.dir(pkg, "REQUIRE"))
deps = matchall(r"[a-zA-Z_]+", require)
if reclevel > 0
for dep in deps
if isdir(Pkg.dir(dep)) && !(dep in excludes) && !(dep in visited)
push!(visited, dep)
depnum, visited = recursive_loc(dep, reclevel - 1, visited, excludes = excludes)
result += depnum
end
end
end
result, visited
end
excludes = (
"Images",
"Interact",
"Hiccup",
"Media",
"Juno",
"BinDeps",
"AxisArrays",
"IndirectArrays",
"ImageAxes",
"DualNumbers",
"IterTools",
"Reexport",
"SpecialFunctions",
"JSON",
"ColorBrewer",
"Compat",
"DataStructures",
"StatsBase",
"Contour"
)
# recursive_loc("Mads")
recursive_loc("Makie", excludes = excludes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment