@@ -3,7 +3,7 @@ module LocalCoverage
33import CoverageTools
44using Coverage: process_folder, process_file
55using DocStringExtensions: SIGNATURES, FIELDS
6- using PrettyTables: pretty_table, Highlighter
6+ using PrettyTables: PrettyTables, pretty_table
77import DefaultApplication
88import LibGit2
99import Pkg
@@ -119,6 +119,13 @@ function Base.show(io::IO, summary::PackageCoverage)
119119 else
120120 rows = map (row -> Base. structdiff (row, NamedTuple{(:gaps ,)}), rows)
121121 end
122+ # PrettyTables 3.0 changed Highlighter to TextHighlighter, so we have to select the correct constructor based on the PrettyTables version
123+ Highlighter = @static if pkgversion (PrettyTables) < v " 3.0.0"
124+ PrettyTables. Highlighter
125+ else
126+ PrettyTables. TextHighlighter
127+ end
128+
122129 highlighters = (
123130 Highlighter (
124131 (data, i, j) -> j == percentage_column && row_coverage[i] <= 50 ,
@@ -131,19 +138,40 @@ function Base.show(io::IO, summary::PackageCoverage)
131138 foreground = :green ),
132139 )
133140
134- pretty_table (
135- io,
136- rows;
137- title = " Coverage of $(package_dir) " ,
138- header,
139- alignment,
140- crop = :none ,
141- linebreaks = true ,
142- columns_width,
143- autowrap = true ,
144- highlighters,
145- body_hlines = [length (rows) - 1 ],
146- )
141+ # Kwargs of `pretty_table` itself also changed in PrettyTables 3.0, so we have to branch here as well
142+ @static if pkgversion (PrettyTables) < v " 3.0.0"
143+ pretty_table (
144+ io,
145+ rows;
146+ title = " Coverage of $(package_dir) " ,
147+ header,
148+ alignment,
149+ crop = :none ,
150+ linebreaks = true ,
151+ columns_width,
152+ autowrap = true ,
153+ highlighters,
154+ body_hlines = [length (rows) - 1 ],
155+ )
156+ else
157+ pretty_table (
158+ io,
159+ rows;
160+ title = " Coverage of $(package_dir) " ,
161+ column_labels = [header],
162+ alignment,
163+ # The crop kwarg is not present anymore, split into the next two ones
164+ fit_table_in_display_horizontally = false ,
165+ fit_table_in_display_vertically = false ,
166+ line_breaks = true ,
167+ fixed_data_column_widths = columns_width,
168+ auto_wrap = true ,
169+ highlighters = collect (highlighters), # v3 expects a vector instead of a Tuple
170+ table_format = PrettyTables. TextTableFormat (;
171+ horizontal_lines_at_data_rows = [length (rows) - 1 ],
172+ ),
173+ )
174+ end
147175end
148176
149177"""
0 commit comments