@@ -281,12 +281,13 @@ end
281281"""
282282$(SIGNATURES)
283283
284- Generate, and optionally open, the HTML coverage summary in a browser for `pkg`
285- inside `dir`.
284+ Generate, and optionally open, the HTML coverage summary in a browser
285+ for `pkg` inside `dir`. The optional keyword argument `css` can be
286+ used to set the path to a custom CSS file styling the coverage report.
286287
287288See [`generate_coverage`](@ref).
288289"""
289- function html_coverage (coverage:: PackageCoverage ; gitroot = " ." , open = false , dir = tempdir ())
290+ function html_coverage (coverage:: PackageCoverage ; gitroot = " ." , open = false , dir = tempdir (), css :: Union{Nothing,AbstractString} = nothing )
290291 cd (coverage. package_dir) do
291292 branch = try
292293 LibGit2. headname (GitRepo (gitroot))
@@ -298,7 +299,13 @@ function html_coverage(coverage::PackageCoverage; gitroot = ".", open = false, d
298299 tracefile = joinpath (COVDIR, LCOVINFO)
299300
300301 try
301- run (` genhtml -t $(title) -o $(dir) $(tracefile) ` )
302+ cmd = ` genhtml -t $(title) -o $(dir) $(tracefile) `
303+ if ! isnothing (css)
304+ css_file = abspath (css)
305+ isfile (css_file) || throw (ArgumentError (" Could not find CSS file at $(css_file) " ))
306+ cmd = ` $(cmd) --css-file $(css_file) `
307+ end
308+ run (cmd)
302309 catch e
303310 error (
304311 " Failed to run genhtml. Check that lcov is installed (see the README)." ,
@@ -318,9 +325,10 @@ function html_coverage(pkg = nothing;
318325 dir = tempdir (),
319326 test_args = [" " ],
320327 folder_list = [" src" ],
321- file_list = [])
328+ file_list = [],
329+ css = nothing )
322330 gen_cov () = generate_coverage (pkg; test_args = test_args, folder_list = folder_list, file_list = file_list)
323- html_coverage (gen_cov (); gitroot = gitroot, open = open, dir = dir)
331+ html_coverage (gen_cov (); gitroot = gitroot, open = open, dir = dir, css = css )
324332end
325333
326334"""
0 commit comments