Documentation
¶
Overview ¶
Package render composes what loupe shows and sends.
Index ¶
- Constants
- Variables
- func AnchorsAsNotes(body string) string
- func Body(in Input) string
- func CodeSpan(s string) string
- func CommentPillsAsWords(comment string) string
- func Comments(in Input) []github.ReviewComment
- func EscapeHTML(s string) string
- func Fence(s string) string
- func ForDisplay(s string) string
- func ForDisplayANSI(s string) string
- func ForDisplayMarkdown(md string) string
- func IsLoupe(body string) bool
- func MetaRound(body string) int
- func MetaSource(body string) string
- func OneLine(s string) string
- func PillsAsWords(body string) string
- func PreviousRound(earlier []string) (int, string)
- func PublicationID(body string) string
- func ReadRecord(body string) ([]RecordFinding, []RecordAssessment, error)
- func RecordAsNote(body string) string
- func StickyRounds(body string) (rounds int, sticky bool)
- type Finding
- type Input
- type Location
- type RecordAssessment
- type RecordEarlier
- type RecordFiledIn
- type RecordFinding
- type RecordLocation
- type Risk
- type Round
- type StickyInput
Constants ¶
const MetaPrefix = "<!-- loupe-meta "
MetaPrefix opens the hidden loupe-meta comment; publish's round count reads it to recognize a loupe review's body without needing that attempt's digest.
Variables ¶
var ( ErrNoRecord = errors.New("it carries no findings record") ErrRecordOmitted = errors.New("its findings record was left out to fit GitHub's length limit") )
Functions ¶
func AnchorsAsNotes ¶
AnchorsAsNotes shows each anchor as the number of the round it opens, for a terminal: its checksum means nothing to a reader, and the payload view still shows the exact bytes.
func CodeSpan ¶
CodeSpan follows the CommonMark rule so no content can close the span early. Contents are not HTML-escaped because GitHub shows character references inside a span literally.
func CommentPillsAsWords ¶
CommentPillsAsWords is PillsAsWords for an inline comment, whose row is its first line.
func Comments ¶
func Comments(in Input) []github.ReviewComment
func EscapeHTML ¶
func ForDisplay ¶
ForDisplay makes controls and bidirectional formatting characters visible so a preview cannot hide or reorder text. It is for display only; payloads are sent verbatim.
func ForDisplayANSI ¶
ForDisplayANSI is ForDisplay for styled terminal output: well-formed SGR sequences survive and every other escape sequence is left inert and visible.
func ForDisplayMarkdown ¶
ForDisplayMarkdown is ForDisplay for Markdown handed to glamour, which decodes character references in text with html.UnescapeString after any escaping of the source, so a reference to a hidden character is escaped in its decoded form.
func IsLoupe ¶
IsLoupe reports whether body carries a loupe-meta line outside a fence, which is how loupe knows its own reviews.
func MetaSource ¶
MetaSource is the src= value on the marker line StickyRounds reads, or on a plain review's last marker line, empty when there is none.
func PillsAsWords ¶
PillsAsWords shows each severity pill in a body's rows as its word, for a terminal that shows the body as raw Markdown, where a pill would otherwise be a line of HTML. Only the <summary> lines loupe generates are touched, so authored text, fenced or not, keeps its bytes.
func PreviousRound ¶
PreviousRound reads the newest collapsed round's number and commit, preferring the full SHA its footer links to over the abbreviated one in its summary. It returns 0 when there is no earlier round or it cannot be read.
func PublicationID ¶
MetaRound is the round= value on the marker line MetaSource reads, 0 when there is none. PublicationID is the publication id of body's current round, empty when it has none. A sticky body keeps each earlier round's reconciliation marker above its own, so the last one outside a fence is the current round's.
func ReadRecord ¶
func ReadRecord(body string) ([]RecordFinding, []RecordAssessment, error)
ReadRecord reads back the findings and assessments a body's record holds. Any doubt is an error and never a partial list, because a wrong previous round makes a reviewer drop an unfixed finding.
func RecordAsNote ¶
RecordAsNote shows the record as a line a person can read, for a terminal that shows the body as raw Markdown. The record copies findings the body already shows, so the note names how many rather than repeating them.
func StickyRounds ¶
StickyRounds is the sticky= count on body's loupe-meta line, and whether the line carries the key at all. A key whose count is not a number still marks the review as sticky, so it is read back and refused rather than skipped.
Types ¶
type Input ¶
type Input struct {
Owner, Repo string
Number, Round int
HeadSHA string
Inline string
Summary string
Digest string
PublicationID string
// Source is name[@version], already validated; empty omits it from the footer and loupe-meta.
Source string
// Model is the reviewer's model id, already validated; empty omits it from the footer and loupe-meta.
Model string
// Unattended marks a review published without a human's confirmation, per constitution 2.0.0.
Unattended bool
// Findings are the published findings; render does no filtering.
Findings []Finding
// Excluded, Withdrawn, Reinstated and Regraded are draft.GateCountsOf, over the whole draft, published findings
// included.
Excluded, Withdrawn, Reinstated, Regraded int
// Sticky marks a body that later rounds edit in place; nil is an ordinary review.
Sticky *StickyInput
// Assessments rides in the findings record only, so the next round can carry an open finding forward.
Assessments []RecordAssessment
// Lenses are the ways of reviewing that ran, and Risk the reviewer's verdict on the change. Both render in the
// context block, from these fields and never from the summary, which an attended review does not post.
Lenses []string
Risk *Risk
}
type RecordAssessment ¶
type RecordAssessment struct {
Ref string `json:"ref"`
Status string `json:"status"`
Finding RecordEarlier `json:"finding"`
}
RecordAssessment is draft.Assessment as the record holds it: the round's status for an earlier finding.
type RecordEarlier ¶
type RecordEarlier struct {
RecordFinding
FiledIn RecordFiledIn `json:"filedIn"`
}
type RecordFiledIn ¶
type RecordFinding ¶
type RecordFinding struct {
ID string `json:"id"`
Title string `json:"title"`
Body string `json:"body"`
Location *RecordLocation `json:"location"`
Label string `json:"label"`
Blocking bool `json:"blocking"`
}
RecordFinding is one published finding as the record holds it. Its JSON is publish.EnvelopeFinding's, so a round read back from GitHub and one read from a receipt have one shape.
type RecordLocation ¶
type Risk ¶ added in v0.27.0
Risk is the reviewer's tier and its one-line reasons. Publish has checked the tier, the reasons and each lens, so they are written as they are.
type Round ¶
type Round struct {
N int
Commit string
Anchor string
Block string
// Edited marks a round whose checksum did not match what GitHub returned. It is carried as found, and its anchor
// is written again over what was found, so the edit is named by one publication only.
Edited bool
}
Round is one collapsed round as the next body carries it: its anchor line, then its <details> block. The length limit drops a round whole, so a block never loses its anchor.
func ReadSticky ¶
ReadSticky reads a sticky body back into the collapsed rounds the next body holds, newest first: the round the body shows, demoted, then the rounds it already held. rounds is its sticky= count. A body with anchors is read by them alone. One without is read by the legacy reader once, and what it returns is anchored, so the next body has anchors.
type StickyInput ¶
type StickyInput struct {
// Rounds is how many rounds have been published into the review, this one included, dropped ones too.
Rounds int
// Earlier holds the collapsed rounds as ReadSticky returns them, newest first.
Earlier []Round
// PrevRound and PrevSHA name the round before this one for the footer's compare link. They are kept apart from
// Earlier, which the length limit may empty, and when unset they are Earlier's newest round's.
PrevRound int
PrevSHA string
// Note is shown under this round's footer while the round is the newest, and dropped when a later round collapses
// it. Empty writes no note.
Note string
}
StickyInput is what a sticky body carries beyond its own round.