{"size": 1958, "ext": "scrbl", "max_stars_repo_path": "scribblings/reporter.scrbl", "max_stars_repo_name": "racket-tw/reporter", "max_stars_repo_stars_event_min_datetime": "2020-12-21T08:54:31.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-15T17:36:52.000Z", "max_issues_repo_path": "scribblings/reporter.scrbl", "max_issues_repo_name": "dannypsnl/reporter", "max_issues_repo_issues_event_min_datetime": "2020-05-24T15:16:55.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-05T10:51:19.000Z", "max_forks_repo_path": "scribblings/reporter.scrbl", "max_forks_repo_name": "dannypsnl/reporter", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 12, "max_forks_count": null, "avg_line_length": 37.6538461538, "max_line_length": 198, "alphanum_fraction": 0.6547497446}
#lang scribble/manual
@require[@for-label[reporter
                    racket]]

@title{reporter}
@author[(author+email "racket.tw" "racket@racket.tw")]

@defmodule[reporter]

@defstruct*[Report ()]{
 The report structure, all fields were private to avoid any hack based on this. @racket[report] constructs this structure, directly print it would get report to stdout.
}

@defproc[(report [#:target target srcloc?]
                 [#:message msg string?]
                 [#:labels label* (listof Label)]
                 [#:error-code err-code string? #f]
                 [#:hint hint string? #f])
         Report?]{
 constructor of @code{Report}.

 Usage:
 @racketblock[
 (report #:target loc
         #:message "type mismatched"
         #:labels (list (label expect-type-loc (format "expected ~a" expect-type) #:color (color:blue))
                        (label actual-expr-loc (format "actual ~a" actual-type) #:color (color:red)))
         #:error-code "E0001")]

 Recommend using @racket[(raise Report?)] and catch it in any place you want to collect them.
}

@defproc[(label [target srcloc?]
                [msg string?]
                [#:color color color? #f])
         Label?]{
 @racket[target] points out where the hint are going to, @racket[msg] is the hint message, @racket[color] is the color of hint message.
}

@defform[(collect-report body ...)]{
 This form works like most normal block like @racket[when], with its wrapping one can collect a raised @racket[Report], find a suitable level put it can help one report more error at once.
}
@defparam[current-report-collection reports (listof Report)]{
 This parameter stands for collecting report from @racket[collect-report], using it can get all reports current collected, with this one can simply print out all reports or do more operations on it.
}

@defstruct*[color ()]{
 It could be @code{color:red} or @code{color:blue}
}
@defstruct*[color:red ()]{}
@defstruct*[color:blue ()]{}
