Devel-XSCover

 view release on metacpan or  search on metacpan

lib/Devel/Cover/Report/XSCover.pm  view on Meta::CPAN

td.pc{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
td.pc meter{width:60px;height:10px;margin-right:6px;vertical-align:middle}
td.pc.c0 meter::-webkit-meter-optimum-value{background:var(--c0)}td.pc.c1 meter::-webkit-meter-optimum-value{background:var(--c1)}td.pc.c2 meter::-webkit-meter-optimum-value{background:var(--c2)}td.pc.c3 meter::-webkit-meter-optimum-value{background:...
td.pc.c0 meter::-moz-meter-bar{background:var(--c0)}td.pc.c1 meter::-moz-meter-bar{background:var(--c1)}td.pc.c2 meter::-moz-meter-bar{background:var(--c2)}td.pc.c3 meter::-moz-meter-bar{background:var(--c3)}
td.pc.c0 span{color:var(--c0)}td.pc.c1 span{color:var(--c1)}td.pc.c2 span{color:var(--c2)}td.pc.c3 span{color:var(--c3)}
td.na{color:var(--muted)}
a.xs{font-size:.75rem;border:1px solid var(--accent);border-radius:4px;padding:0 4px;text-decoration:none;margin-left:6px}
.toggles{display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin:10px 0}
.toggles label{cursor:pointer}
table.src{font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
table.src td{padding:0 8px;border-bottom:0}
table.src td.br,table.src td.sb,table.src td.cd{white-space:normal;max-width:18em;line-height:1.3}
table.src tr.why{display:none}table.src tr.why.open{display:table-row}
table.src tr.why td{background:var(--c0bg);font:14px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;white-space:normal;padding:4px 12px}
table.src tr.why ul{margin:0;padding-left:18px}
table.src tr.miss td.n{cursor:pointer}
details.legend{margin:0 0 10px;color:var(--muted);font-size:.9rem}details.legend summary{cursor:pointer}details.legend ul{margin:4px 0 0;padding-left:18px}
table.src td.n{color:var(--muted);text-align:right;user-select:none;width:1%}
table.src td.code{width:100%;white-space:pre}
table.src td.code pre{margin:0;font:inherit;white-space:pre}
table.src tr.miss td.code{background:var(--c0bg)}
table.src tr.miss td.n{color:var(--c0);font-weight:600}
table.src tr.here td{outline:2px solid var(--here);outline-offset:-2px}
table.src tr.dim td.code{color:var(--muted)}
table.src td.st span,table.src td.pd span{display:inline-block;min-width:1.5em;text-align:right;padding:0 4px;border-radius:4px;font-size:.85em}
table.src td.st span.c3,table.src td.pd span.c3{background:var(--c3bg);color:var(--c3)}
table.src td.st span.c0,table.src td.pd span.c0{background:var(--c0bg);color:var(--c0)}
table.src td.tm span{color:var(--muted);font-size:.85em}
span.branch{display:inline-flex;margin-right:4px;border-radius:4px;overflow:hidden;border:1px solid var(--line);font-size:.75em;vertical-align:middle}
span.branch b{padding:0 5px;font-weight:600;white-space:nowrap}
span.branch{margin:1px 4px 1px 0}
span.branch b.c3{background:var(--c3bg);color:var(--c3)}span.branch b.c0{background:var(--c0bg);color:var(--c0)}span.branch b.un{background:var(--unbg);color:var(--un)}
span.sub{display:inline-block;padding:0 6px;border-radius:4px;font-size:.85em;margin-right:4px}
span.sub.c3{background:var(--c3bg);color:var(--c3)}span.sub.c0{background:var(--c0bg);color:var(--c0)}
details.cond{display:inline-block;margin-right:4px;font-size:.85em}
details.cond summary{cursor:pointer;padding:0 6px;border-radius:4px;list-style:none}
details.cond summary.c0{background:var(--c0bg);color:var(--c0)}details.cond summary.c1{background:var(--c1bg);color:var(--c1)}details.cond summary.c2{background:var(--c2bg);color:var(--c2)}details.cond summary.c3{background:var(--c3bg);color:var(--c3...
details.cond[open]{position:relative}
details.cond table{position:absolute;z-index:2;background:var(--card);border:1px solid var(--line);border-radius:6px;padding:4px;width:auto;box-shadow:0 4px 16px rgba(0,0,0,.15)}
details.cond td,details.cond th{padding:1px 6px;border:0;text-align:center}
details.cond .c0{color:var(--c0)}details.cond .c3{color:var(--c3)}
details.cond p.expr{margin:0;color:var(--muted);display:none}
.hide-st .st,.hide-br .br,.hide-cd .cd,.hide-sb .sb,.hide-pd .pd,.hide-tm .tm{display:none}
@media (max-width:600px){header{flex-direction:column}td.pc meter{display:none}}
CSS
}

sub _script {
    return <<'JS';
<script>
(function(){
var root=document.documentElement;
try{var saved=localStorage.getItem('xs-cover-theme');if(saved)root.setAttribute('data-theme',saved)}catch(e){}
var theme=document.getElementById('theme');
if(theme)theme.onclick=function(){var cur=root.getAttribute('data-theme');var dark=cur?cur==='dark':window.matchMedia('(prefers-color-scheme: dark)').matches;var next=dark?'light':'dark';root.setAttribute('data-theme',next);try{localStorage.setItem('...
var files=document.getElementById('files');
if(files){
var ths=files.querySelectorAll('thead th');
Array.prototype.forEach.call(ths,function(th,i){th.onclick=function(){var num=th.getAttribute('data-sort')==='num';var body=files.tBodies[0];var rows=Array.prototype.slice.call(body.rows);var asc=th.getAttribute('data-dir')!=='asc';Array.prototype.fo...
function key(r){var c=r.cells[i];var v=c.getAttribute('data-v');if(v===null)v=c.textContent.trim();return num?parseFloat(v):v.toLowerCase()}
rows.sort(function(a,b){var x=key(a),y=key(b);if(num){if(isNaN(x))x=-1;if(isNaN(y))y=-1;return asc?x-y:y-x}return asc?x.localeCompare(y):y.localeCompare(x)});
rows.forEach(function(r){body.appendChild(r)})}});
var filter=document.getElementById('filter');
if(filter)filter.oninput=function(){var q=filter.value.toLowerCase();Array.prototype.forEach.call(files.tBodies[0].rows,function(r){r.hidden=q!==''&&r.cells[0].textContent.toLowerCase().indexOf(q)<0})};
}
Array.prototype.forEach.call(document.querySelectorAll('input[data-crit]'),function(c){c.onchange=function(){root.classList.toggle('hide-'+c.getAttribute('data-crit'),!c.checked)}});
var miss=Array.prototype.slice.call(document.querySelectorAll('tr.miss')),at=-1;
Array.prototype.forEach.call(document.querySelectorAll('tr.miss'),function(r){r.onclick=function(e){if(e.target.closest('details'))return;var w=r.nextElementSibling;if(w&&w.classList.contains('why'))w.classList.toggle('open')}});
document.addEventListener('keydown',function(e){if(e.target&&(e.target.tagName==='INPUT'||e.target.tagName==='TEXTAREA'))return;if(e.key!=='n'&&e.key!=='p')return;if(!miss.length)return;at=e.key==='n'?(at+1)%miss.length:(at-1+miss.length)%miss.length...
})();
</script>
JS
}

1;

__END__

=head1 NAME

Devel::Cover::Report::XSCover - a self-contained HTML report for Devel::Cover

=head1 SYNOPSIS

    cover -report XSCover
    xs_cover

The name is typed as C<XSCover>: C<cover> upper-cases only the first letter of a
report name to find its module, so C<xscover> would look for C<Xscover>.

=head1 DESCRIPTION

An HTML report for any Devel::Cover database, Perl only or with the C side that
L<xs_cover> adds. It writes F<coverage.html> and one page per file into the
database directory, and nothing else. Every page stands on its own: the styles
are inline, there is a dark theme that follows the system and a button to
override it, a few lines of script sort and filter the summary and move between
uncovered lines, and no library or external resource is loaded.

The summary page shows the totals as tiles, then a table of every file with a bar
and a percentage for each criterion, sortable by any column and filtered by a
search box. A module whose XS file is in the report has a link to it on its row.

A file page shows the source with the coverage drawn beside each line: the
statement count, each branch as chips with the times each arm was taken (T and
F for a Perl branch, A and B for a C branch, the arm into the body first, one chip per arm of a
C<switch>), each condition as a percentage that
opens into its truth table (for C under gcc 14 and later, one per term of a
decision, with its true and false outcomes), each subroutine as a chip with its name, and the pod
and time columns where they exist. Lines with an uncovered item are marked, and
clicking one opens a row that says in words what is missing. C<n> and C<p> move
between them and open that row. Checkboxes hide and show each kind of mark, a
legend explains them, and pod and anything after C<__END__> is dimmed.

=head1 OPTIONS

The same as the other HTML reports: C<-outputfile> for the summary page's name,
C<-summarytitle> for its title, and C<-report_c0>, C<-report_c1> and
C<-report_c2> for the thresholds below which a percentage is red, orange and
yellow (75, 90 and 100).



( run in 1.826 second using v1.01-cache-2.11-cpan-60884a8df76 )