Documentation
¶
Index ¶
- Constants
- Variables
- func FormatActionLabel(action ActionType, deco Decoration) string
- func FormatLineRef(startLine, endLine int) string
- func FormatReview(result *ReviewResult, d *Document, filePath string) string
- func SaveViewedState(path string, state *ViewedState) error
- func StatePath(filePath string) string
- type ActionType
- type Decoration
- type Document
- type ReviewComment
- type ReviewResult
- type Section
- type Status
- type ViewedState
Constants ¶
const DefaultAction = ActionQuestion
DefaultAction is the default action type for new comments.
const OverviewSectionID = "overview"
OverviewSectionID is the virtual section ID used for file-level comments on the overview/preamble.
Variables ¶
var ActionLabels = []ActionType{ ActionSuggestion, ActionIssue, ActionQuestion, ActionNitpick, ActionTodo, ActionThought, ActionNote, ActionPraise, ActionChore, }
ActionLabels is the ordered list of action labels for Tab cycling.
var DecorationLabels = []Decoration{ DecorationNone, DecorationNonBlocking, DecorationBlocking, DecorationIfMinor, }
DecorationLabels is the ordered list of decoration labels for cycling.
Functions ¶
func FormatActionLabel ¶
func FormatActionLabel(action ActionType, deco Decoration) string
FormatActionLabel formats an action and decoration pair for display.
func FormatLineRef ¶ added in v0.6.0
FormatLineRef formats a line reference from start and end line numbers. Returns "L10" for single line, "L10-L15" for range, or "" if startLine is 0.
func FormatReview ¶
func FormatReview(result *ReviewResult, d *Document, filePath string) string
FormatReview formats a ReviewResult as a Markdown string. Section-level comments are grouped under section headings. Line-level comments are listed separately by line number.
func SaveViewedState ¶
func SaveViewedState(path string, state *ViewedState) error
SaveViewedState writes the viewed state to a JSON file.
Types ¶
type ActionType ¶
type ActionType string
ActionType is the type of review action, based on Conventional Comments labels.
const ( ActionSuggestion ActionType = "suggestion" ActionIssue ActionType = "issue" ActionQuestion ActionType = "question" ActionNitpick ActionType = "nitpick" ActionTodo ActionType = "todo" ActionThought ActionType = "thought" ActionNote ActionType = "note" ActionPraise ActionType = "praise" ActionChore ActionType = "chore" )
type Decoration ¶
type Decoration string
Decoration is the decoration modifier for a Conventional Comment.
const ( DecorationNone Decoration = "" DecorationNonBlocking Decoration = "non-blocking" DecorationBlocking Decoration = "blocking" DecorationIfMinor Decoration = "if-minor" )
type Document ¶
type Document struct {
Title string // H1 heading text (or filename if no H1)
Preamble string // Text before the first heading
Sections []*Section // Top-level sections
SourceLines []string // Raw source lines (for line-level commenting)
}
Document is the parsed structure of an entire Markdown file.
func Parse ¶
Parse parses a Markdown source into a Document structure. It uses goldmark to build an AST and walks headings to create sections.
func (*Document) AllSections ¶
AllSections returns a flat list of all sections in depth-first order.
func (*Document) FindSection ¶
FindSection returns the section with the given ID, or nil if not found.
type ReviewComment ¶
type ReviewComment struct {
SectionID string // Target section ID
Action ActionType // Comment action type
Decoration Decoration // Comment decoration (e.g. non-blocking, blocking)
Body string // Comment body text
StartLine int // 1-based start line (0 = section-level comment)
EndLine int // 1-based end line (0 = single line if StartLine > 0)
Side string // "RIGHT" or "LEFT" (for PR diff comments)
}
ReviewComment is a review comment on a single section.
func (*ReviewComment) FormatLabel ¶
func (c *ReviewComment) FormatLabel() string
FormatLabel returns the formatted label string for display. With decoration: "action (decoration)", without: "action".
func (*ReviewComment) FormatLineRef ¶ added in v0.6.0
func (c *ReviewComment) FormatLineRef() string
FormatLineRef returns a line reference string for display. Returns "L10" for single line, "L10-L15" for range, or "" for section-level.
type ReviewResult ¶
type ReviewResult struct {
Comments []ReviewComment
}
ReviewResult holds the entire review output.
type Section ¶
type Section struct {
ID string // Auto-numbered: "S1", "S1.1", "S2", etc.
Title string // Heading text (without the "## " prefix)
Level int // Heading level (2=##, 3=###, ...)
Body string // Markdown text from heading to next heading
Children []*Section // Sub-sections (lower-level headings)
Parent *Section // Parent section (nil for top-level)
StartLine int // 1-based line number of heading (0 = not set)
EndLine int // 1-based line number of last body line (0 = not set)
}
Section is a single section in a document, corresponding to one heading.
type ViewedState ¶
ViewedState tracks which sections have been viewed and their content hashes.
func LoadViewedState ¶
func LoadViewedState(path string) *ViewedState
LoadViewedState reads a viewed state file. Returns an empty state on any error.
func NewViewedState ¶
func NewViewedState() *ViewedState
NewViewedState creates an empty ViewedState.
func (*ViewedState) IsSectionViewed ¶
func (vs *ViewedState) IsSectionViewed(s *Section) bool
IsSectionViewed returns true if the section's title is tracked and its content hash matches.
func (*ViewedState) MarkViewed ¶
func (vs *ViewedState) MarkViewed(s *Section)
MarkViewed records a section as viewed with its current content hash.
func (*ViewedState) UnmarkViewed ¶
func (vs *ViewedState) UnmarkViewed(s *Section)
UnmarkViewed removes a section's viewed status.