livery.extensions.coverage._render¶
livery.extensions.coverage._render ¶
Draw one package's coverage pages from its files' readings in the line format.
livery.extensions.coverage._render.render writes a package's tree:
an index of its files, an index of its functions and one of its
classes, a page per file with its source highlighted line by line, and
the stylesheet and script every page shares, which ship in this
extension's content/assets. The numbers are coverage.py's
(livery.extensions.coverage._format.numbers): the statements,
branches and percentages its report shows, and the category it draws
each line in. Beyond them, a page shows how many times each line ran
for a measurer that counts runs, a measurer's numbered branches and
its counts of a line's branches, the code of a line that ran which
never did for a measurer that reads columns, who measured each file,
where the measurement comes from, and the package's floor. The pages
depend on the readings alone: drawing the same readings again writes
the same tree.
Classes:
| Name | Description |
|---|---|
Drawn |
One file to draw. |
Report |
One package's pages: what to draw, and what to say about it. |
Functions:
| Name | Description |
|---|---|
render |
Write report's pages into into, replacing what was there; the totals. |
page_name |
The page drawn for the file at name: its name, and its directory's digest. |
line_categories |
The category of each line from 1 to count, as coverage.py draws it. |
jumps |
The jumps from line that never ran: each one's short and long annotation. |
unrun_marks |
The characters of each line that ran whose code never did, by the ranges. |
highlighted |
text as HTML, line by line, highlighted by Pygments' lexer for name. |
source_lines |
text's lines, numbered as coverage.py numbers them. |
Attributes:
| Name | Type | Description |
|---|---|---|
ASSETS |
|
|
STYLE |
|
|
SCRIPT |
|
|
REGION_KINDS |
|
|
CATEGORIES |
|
|
ANYWHERE |
|
|
EMPTY_CONTEXT |
|
|
ARROW |
|
CATEGORIES
module-attribute
¶
ANYWHERE
module-attribute
¶
Drawn
dataclass
¶
One file to draw.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The file's path from the workspace root. |
merged |
Merged
|
Its merged reading. |
text |
str | None
|
The checkout's text of the file when it is the content measured; None when the checkout holds other content. |
digest |
str
|
The checkout's git blob id of the file. |
Report
dataclass
¶
Report(title: str, files: tuple[Drawn, ...], contexts: tuple[str, ...] = (), notes: tuple[str, ...] = (), absent: tuple[str, ...] = (), precision: int = 0, floor: str = '')
One package's pages: what to draw, and what to say about it.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str
|
What the pages cover: |
files |
tuple[Drawn, ...]
|
The files to draw. |
contexts |
tuple[str, ...]
|
The contexts a reading's |
notes |
tuple[str, ...]
|
Lines the index states under its heading: where the measurement comes from, and the commit drawn. |
absent |
tuple[str, ...]
|
The measured files the checkout no longer has. |
precision |
int
|
The decimals a percentage shows. |
floor |
str
|
The line each index states under its heading about the package's floor; empty for none. |
render ¶
Write report's pages into into, replacing what was there; the totals.
into is removed and written afresh, so a file that left the report leaves no page behind. Each page is written with LF line endings, so one report gives the same bytes on every platform.
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_render.py
page_name ¶
The page drawn for the file at name: its name, and its directory's digest.
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_render.py
line_categories ¶
The category of each line from 1 to count, as coverage.py draws it.
Excluded first, then missing, then partial, then run; a later line
of a statement written over several lines takes its first line's
category with a 2, and any other line has none, an empty string.
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_render.py
jumps ¶
The jumps from line that never ran: each one's short and long annotation.
coverage.py's wording: 12 ↛ 15 and 12 ↛ exit beside the
sentence that says why, or 12 ↛ anywhere when no branch of the
line ran. A measurer that numbers branches names them branch 1,
an exception's path branch 1 (throw), and one that counts a
line's branches says how many of them ran.
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_render.py
unrun_marks ¶
The characters of each line that ran whose code never did, by the ranges.
Per line of text, each stretch from its first character's index to the index after its last. A range's columns count bytes, so a line with characters beyond ASCII has its stretches moved to the characters those bytes belong to. A line that never ran is drawn missing whole and has none.
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_render.py
highlighted ¶
highlighted(name: str, text: str, marks: Mapping[int, Sequence[tuple[int, int]]] | None = None) -> list[str]
text as HTML, line by line, highlighted by Pygments' lexer for name.
A name no lexer claims is drawn as plain text. Each line is HTML
without its line ending; a token over several lines is split at
each, and a CRLF or a lone CR ends a line as LF does
(livery.extensions.coverage._render.source_lines). marks
names, by line, the stretches of characters that never ran, as
unrun_marks gives them: each piece of a token inside one is drawn
with the class nr beside the token's own.
Source code in packages/extensions/coverage/src/livery/extensions/coverage/_render.py
source_lines ¶
text's lines, numbered as coverage.py numbers them.
coverage.py reads a source's CRLF and lone CR line endings as LF, so a file checked out with CRLF on Windows has the lines it has elsewhere, and none of them ends in a carriage return.