How can I change the CSS of Devel::Cover in Perl?
Asked Answered
D

2

5

When running ./Build testcover to test the code coverage, is there a way I can pass in some kind of option for using my own stylesheet, maybe as an override?

I have looked at the Devel::Cover CPAN documentation to no avail.

Dram answered 24/2, 2014 at 18:16 Comment(0)
O
4

Looking at the source of Devel::Cover::Report::Html_minimal, it seems you would need to make your own report format by subclassing that and overriding print_stylesheet() to do what you want. That's the "easy" part...

Next you would need to get Module::Build to use your custom report format when running cover. Again, looking at the source, the default testcover action in Module::Build simply runs $self->do_system('cover') and as the cover script doesn't allow you to override the report format using an environment variable, you would have to override ACTION_testcover() in the build class for the given module.

It seems like just mangling the default CSS file after running ./Build testcover as suggested in another answer is a much easier solution.

Onslaught answered 24/2, 2014 at 19:16 Comment(1)
Marking this as the correct answer since I went with subclassing and overriding.Dram
D
5

The CSS file is cover_db/cover.css. Change at will.

Decigram answered 24/2, 2014 at 18:20 Comment(2)
Yes, I have already thought of that, but it seems tacky to have to change the generated css file. It would be nice if Devel::Cover could accept an additional override stylesheet.Dram
You could always copy the HTML files to a directory with the corrected CSS file.Decigram
O
4

Looking at the source of Devel::Cover::Report::Html_minimal, it seems you would need to make your own report format by subclassing that and overriding print_stylesheet() to do what you want. That's the "easy" part...

Next you would need to get Module::Build to use your custom report format when running cover. Again, looking at the source, the default testcover action in Module::Build simply runs $self->do_system('cover') and as the cover script doesn't allow you to override the report format using an environment variable, you would have to override ACTION_testcover() in the build class for the given module.

It seems like just mangling the default CSS file after running ./Build testcover as suggested in another answer is a much easier solution.

Onslaught answered 24/2, 2014 at 19:16 Comment(1)
Marking this as the correct answer since I went with subclassing and overriding.Dram

© 2022 - 2024 — McMap. All rights reserved.