Skip to content

Commit 1eb18f1

Browse files
henry2coxoberpar
authored andcommitted
genhtml: Add option to change HTML header text
Introduce new command-line option --header-title and associated lcovrc option genhtml_header that can be used to change the header text shown at the top of each generated HTML page. [oberpar: Split original commit, added commit message, fixed typos and capitalization, reworded --title text to make difference more visible, some man-page rewording] Signed-off-by: Henry Cox <[email protected]>
1 parent eb2ce0b commit 1eb18f1

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

Diff for: bin/genhtml

+10-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ our %test_description; # Hash containing test descriptions if available
257257
our $date = get_date_string();
258258

259259
our @info_filenames; # List of .info files to use as data source
260-
our $test_title; # Title for output as written to each page header
260+
our $header_title; # Title at top of HTML report page (above table)
261+
our $test_title; # Title shown in header table of each page
261262
our $output_directory; # Name of directory in which to store output
262263
our $base_filename; # Optional name of file containing baseline data
263264
our $desc_filename; # Name of file containing test descriptions
@@ -354,6 +355,7 @@ if ($config || %opt_rc)
354355
# Copy configuration file and --rc values to variables
355356
apply_config({
356357
"genhtml_css_file" => \$css_filename,
358+
"genhtml_header" => \$header_title,
357359
"genhtml_hi_limit" => \$hi_limit,
358360
"genhtml_med_limit" => \$med_limit,
359361
"genhtml_line_field_width" => \$line_field_width,
@@ -401,6 +403,7 @@ $br_coverage = $lcov_branch_coverage if (!defined($br_coverage));
401403

402404
# Parse command line options
403405
if (!GetOptions("output-directory|o=s" => \$output_directory,
406+
"header-title=s" => \$header_title,
404407
"title|t=s" => \$test_title,
405408
"description-file|d=s" => \$desc_filename,
406409
"keep-descriptions|k" => \$keep_descriptions,
@@ -451,6 +454,10 @@ if (!GetOptions("output-directory|o=s" => \$output_directory,
451454
if ($no_sort) {
452455
$sort = 0;
453456
}
457+
458+
if (defined($header_title)) {
459+
$title = $header_title;
460+
}
454461
}
455462

456463
@info_filenames = @ARGV;
@@ -622,8 +629,9 @@ Operation:
622629
623630
HTML output:
624631
-f, --frames Use HTML frames for source code view
625-
-t, --title TITLE Display TITLE in header of all pages
632+
-t, --title TITLE Show TITLE in header table of each page
626633
-c, --css-file CSSFILE Use external style sheet file CSSFILE
634+
--header-title BANNER Banner text at top of each HTML page
627635
--no-source Do not create source code view
628636
--num-spaces NUM Replace tabs with NUM spaces in source view
629637
--highlight Highlight lines with converted-only data

Diff for: lcovrc

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# same as 'genhtml --dark-mode ....'
1313
#genhtml_dark_mode = 1
1414

15+
# Header text to use at top of each page
16+
# Default is "LCOV - coverage report"
17+
#genhtml_header = Coverage report for my project
18+
1519
# Specify coverage rate limits (in %) for classifying file entries
1620
# HI: hi_limit <= rate <= 100 graph color: green
1721
# MED: med_limit <= rate < hi_limit graph color: orange

Diff for: man/genhtml.1

+23-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ genhtml \- Generate HTML view from LCOV coverage data files
1717
.RB [ \-o | \-\-output\-directory
1818
.IR output\-directory ]
1919
.br
20+
.RB [ \-\-header-title
21+
.IR banner ]
22+
.br
2023
.RB [ \-t | \-\-title
2124
.IR title ]
2225
.br
@@ -204,13 +207,30 @@ project size, a lot of files and subdirectories may be created.
204207
.RS
205208
Display
206209
.I title
207-
in header of all pages.
210+
in header table of all pages.
208211

209212
.I title
210-
is written to the header portion of each generated HTML page to
211-
identify the context in which a particular output
213+
is written to the "Test:"-field in the header table at the top of each
214+
generated HTML page to identify the context in which a particular output
212215
was created. By default this is the name of the tracefile.
213216

217+
A potential use is to specify a test run name, or a version control system
218+
identifier that indicates the code level that was tested.
219+
220+
.RE
221+
.BI "\-\-header\-title " BANNER
222+
.RS
223+
Display
224+
.I BANNER
225+
in header of all pages.
226+
227+
.I BANNER
228+
is written to the header portion of each generated HTML page. By default this
229+
simply identifies this as an LCOV coverage report.
230+
231+
A potential use is to specify the name of the project or project branch and
232+
build ID.
233+
214234
.RE
215235
.BI "\-d " description\-file
216236
.br

Diff for: man/lcovrc.5

+17
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ section 'OPTIONS' below.
5454
#genhtml_dark_mode = 1
5555
.br
5656

57+
# Alternate header text to use at top of each page
58+
.br
59+
#genhtml_header = Coverage report for my project
60+
5761
# Coverage rate limits
5862
.br
5963
genhtml_hi_limit = 90
@@ -323,6 +327,19 @@ This option corresponds to the \-\-css\-file command line option of
323327
By default, a standard CSS file is generated.
324328
.PP
325329

330+
.BR genhtml_header " ="
331+
.I string
332+
.IP
333+
Specify header text to use at top of each HTML page.
334+
.br
335+
336+
This option corresponds to the \-\-header\-title command line option of
337+
.BR genhtml .
338+
.br
339+
340+
Default is "LCOV - coverage report".
341+
.PP
342+
326343
.BR genhtml_dark_mode " ="
327344
.IR 0 | 1
328345
.IP

0 commit comments

Comments
 (0)