diff --git a/README.rst b/README.rst index 0e9b9ac..d2d5796 100644 --- a/README.rst +++ b/README.rst @@ -20,10 +20,10 @@ The JuliaFEM project develops open-source software for reliable, scalable, distr .. image:: https://coveralls.io/repos/JuliaFEM/JuliaFEM.jl/badge.svg?branch=master :target: https://coveralls.io/r/JuliaFEM/JuliaFEM.jl?branch=master -.. image:: http://juliafem.kapsi.fi/badges/notebooks-status.svg +.. image:: http://juliafem.kapsi.fi/_static/notebooks-status.svg :target: http://juliafem.kapsi.fi/tutorials/index.html -.. image:: http://juliafem.kapsi.fi/badges/lint-status.svg +.. image:: http://juliafem.kapsi.fi/_static/lint-status.svg :target: http://juliafem.kapsi.fi/quality/index.html#lint-report .. image:: https://img.shields.io/github/issues/JuliaFEM/JuliaFEM.jl.svg diff --git a/docs/badges.jl b/docs/badges.jl new file mode 100644 index 0000000..2a1f774 --- /dev/null +++ b/docs/badges.jl @@ -0,0 +1,53 @@ +using Requests + + +function make_badge_simple(subject::String, status::String, color::String, outfile::String) + subject = replace(subject, " ", "%20") + url = "https://img.shields.io/badge/$subject-$status-$color.svg" + res = get(url) + open(outfile, "w") do fid + write(fid, res.data) + end +end + +""" +Make badge based on two numbers +""" +function make_badge(subject::String, a::Int, b::Int, outfile::String) + limits = Float64[100, 80, 60, 40, 20, 0] + colors = ["brightgreen", "green", "yellowgreen", "yellow", "orange", "red"] + picked_color = "lightgray" + perce = a/b*100 + println("perce: $perce") + for (i, limit) in enumerate(limits) + if perce >= limit + picked_color = colors[i] + break + end + end + println("color: $picked_color") + message = "$a/$b" + make_badge_simple(subject, message, picked_color, outfile) +end + +""" +Make badge based on one number +""" +function make_badge(subject::String, a::Int, outfile::ASCIIString) + limits = Float64[0, 20, 40, 60, 80, 100] + colors = ["brightgreen", "green", "yellowgreen", "yellow", "orange", "red"] + picked_color = "red" + for (i, limit) in enumerate(limits) + if a <= limit + picked_color = colors[i] + break + end + end + println("color: $picked_color") + a = 100 - a + if a < 0 + a = 0 + end + message = "$a" + make_badge_simple(subject, message, picked_color, outfile) +end diff --git a/docs/build_lint.jl b/docs/build_lint.jl index 2de74ee..f6bb08b 100644 --- a/docs/build_lint.jl +++ b/docs/build_lint.jl @@ -1,11 +1,17 @@ using Lint + +include("badges.jl") + d = lintpkg("JuliaFEM", returnMsgs=true) cd(dirname(@__FILE__)) do + k = 0 open("quality/lint_report.rst", "w") do fid for i in d i = string(i) i = i[search(i, "JuliaFEM")[2]-1:end] write(fid, "| "*i*"\n") + k += 1 end end -end \ No newline at end of file + make_badge("code quality", k, "badges/lint-status.svg") +end