Documentation
¶
Overview ¶
Package docreview is the logic of review annotations on project documents: finding an annotation's quote again in the current text and rendering the annotations of a review round as the feedback an agent receives. It reads no files and holds no state: the entry layers read the document, the stage service decides when to send the feedback.
Index ¶
- Variables
- func Section(content string, a jobstore.DocAnnotation) string
- func Summary(lang i18n.Lang, round int, anns []jobstore.DocAnnotation, content ContentFunc) string
- type Annotation
- type ContentFunc
- type CreateInput
- type Deps
- type Located
- type Service
- func (s *Service) Create(in CreateInput) (Annotation, error)
- func (s *Service) Delete(projectKey, id string) error
- func (s *Service) Diff(projectKey, base, path, from, to string) (project.DocDiffResult, error)
- func (s *Service) ItemDiff(id, path string, from, to int) (project.DocDiffResult, error)
- func (s *Service) ListDoc(projectKey, base, path, state, workItem string, round int) ([]Annotation, error)
- func (s *Service) ListItem(id string, round int, state string) (int, []Annotation, error)
- func (s *Service) SetState(projectKey, id, state, by string) (Annotation, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoDocInRound = errors.New("the review round did not record this document")
ErrNoDocInRound is returned when a review round did not record the document.
var ErrNoRound = errors.New("review round not found")
ErrNoRound is returned by the round-based diff when the flow has no such review round.
var ErrUnknownProject = errors.New("unknown project")
ErrUnknownProject is returned when the project key is not registered.
Functions ¶
func Section ¶
func Section(content string, a jobstore.DocAnnotation) string
Section is the title of the nearest markdown heading above the annotation's quote ("" when the quote cannot be found or sits above every heading).
func Summary ¶
func Summary(lang i18n.Lang, round int, anns []jobstore.DocAnnotation, content ContentFunc) string
Summary renders annotations as the structured feedback of a review round:
## 评审意见(第 N 轮,M 条) 1. [change] docs/design/x.md §「2.1 存储」 原文:> … 建议改成:…
It is "" for no annotations. content may be nil (no section is named then).
Types ¶
type Annotation ¶
type Annotation struct {
jobstore.DocAnnotation
Located *Located `json:"located,omitempty"`
}
Annotation is a stored annotation with where its quote sits in the current document text.
type ContentFunc ¶
ContentFunc returns the current text of a project document ("" when it cannot be read); it lets the summary name the section an annotation sits in.
type CreateInput ¶
type CreateInput struct {
Project, Base, Path string
Quote, Prefix, Suffix string
Kind, Body, Replacement string
WorkItemID, Author string
}
CreateInput is a new annotation. Path is as the doc reader takes it (Base, when set, is the reader's base): the stored path is the resolved project-root-relative one.
type Deps ¶
type Deps struct {
Store *jobstore.Store
// Config returns the current server configuration; it is called per request.
Config func() *config.Config
// Project resolves a project key (the registry's Get).
Project func(key string) (config.ProjectConfig, error)
}
Deps is what the service needs from the process.
type Located ¶
type Located struct {
// Found is false when the quote cannot be found any more (the annotation is stale).
Found bool `json:"found"`
// Line is the 1-based line of the quote's first character (0 when not found).
Line int `json:"line,omitempty"`
}
Located is where an annotation sits in a document.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service stores and serves review annotations and the document diffs between review rounds.
func (*Service) Create ¶
func (s *Service) Create(in CreateInput) (Annotation, error)
Create stores an annotation on a document. The document must be readable by the doc reader and still contain the quote. In a work item's context (WorkItemID set) the item must belong to the project, and the annotation joins the flow's newest review round.
func (*Service) Diff ¶
func (s *Service) Diff(projectKey, base, path, from, to string) (project.DocDiffResult, error)
Diff is the line diff of a document between two commits (to "" = HEAD).
func (*Service) ItemDiff ¶
ItemDiff is the diff of a flow's document between review round from and round to (to 0 = the document's HEAD now); the commits are the ones the rounds recorded.
func (*Service) ListDoc ¶
func (s *Service) ListDoc(projectKey, base, path, state, workItem string, round int) ([]Annotation, error)
ListDoc lists the annotations of a project: of one document when path is set (resolved like the doc reader), narrowed by state, work item and round (round < 0 = any).