Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ EzXML = "1"
LibGit2 = "1.10"
OrderedCollections = "1"
Pkg = "1.10"
PrettyTables = "0.12, 1.0, 2"
PrettyTables = "0.12, 1.0, 2, 3.0.11"
julia = "1.10"
56 changes: 42 additions & 14 deletions src/LocalCoverage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module LocalCoverage
import CoverageTools
using Coverage: process_folder, process_file
using DocStringExtensions: SIGNATURES, FIELDS
using PrettyTables: pretty_table, Highlighter
using PrettyTables: PrettyTables, pretty_table
import DefaultApplication
import LibGit2
import Pkg
Expand Down Expand Up @@ -119,6 +119,13 @@ function Base.show(io::IO, summary::PackageCoverage)
else
rows = map(row -> Base.structdiff(row, NamedTuple{(:gaps,)}), rows)
end
# PrettyTables 3.0 changed Highlighter to TextHighlighter, so we have to select the correct constructor based on the PrettyTables version
Highlighter = @static if pkgversion(PrettyTables) < v"3.0.0"
PrettyTables.Highlighter
else
PrettyTables.TextHighlighter
end

highlighters = (
Highlighter(
(data, i, j) -> j == percentage_column && row_coverage[i] <= 50,
Expand All @@ -131,19 +138,40 @@ function Base.show(io::IO, summary::PackageCoverage)
foreground = :green),
)

pretty_table(
io,
rows;
title = "Coverage of $(package_dir)",
header,
alignment,
crop = :none,
linebreaks = true,
columns_width,
autowrap = true,
highlighters,
body_hlines = [length(rows) - 1],
)
# Kwargs of `pretty_table` itself also changed in PrettyTables 3.0, so we have to branch here as well
@static if pkgversion(PrettyTables) < v"3.0.0"
pretty_table(
io,
rows;
title = "Coverage of $(package_dir)",
header,
alignment,
crop = :none,
linebreaks = true,
columns_width,
autowrap = true,
highlighters,
body_hlines = [length(rows) - 1],
)
else
pretty_table(
io,
rows;
title = "Coverage of $(package_dir)",
column_labels = [header],
alignment,
# The crop kwarg is not present anymore, split into the next two ones
fit_table_in_display_horizontally = false,
fit_table_in_display_vertically = false,
line_breaks = true,
fixed_data_column_widths = columns_width,
auto_wrap = true,
highlighters = collect(highlighters), # v3 expects a vector instead of a Tuple
table_format = PrettyTables.TextTableFormat(;
horizontal_lines_at_data_rows = [length(rows) - 1],
),
)
end
end

"""
Expand Down
Loading