commit a2f430020abbed14f887c2384a67aef04479111c
parent 26eff4c03abed09b10692dad66c794c5407503ce
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Fri, 2 Oct 2015 15:15:31 -0600
scribble/eval: strip away `code:contract`s
Make `code:contract` handled like `code:comment` for evaluation.
Relevant to PR 15161
Diffstat:
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/scribble-doc/scribblings/scribble/eval.scrbl b/scribble-doc/scribblings/scribble/eval.scrbl
@@ -49,7 +49,7 @@ Certain patterns in @racket[datum] are treated specially:
@racket[(@#,indexed-racket[code:line] _code-datum (@#,racketidfont{code:comment} _comment-datum ...))]
is treated as @racket[_code-datum] for evaluation.}
- @item{Other uses of @racketidfont{code:comment} and
+ @item{Other uses of @racketidfont{code:comment}, @racketidfont{code:contract}, and
@racketidfont{code:blank} are stripped from each @racket[datum]
before evaluation.}
diff --git a/scribble-lib/scribble/eval.rkt b/scribble-lib/scribble/eval.rkt
@@ -206,11 +206,13 @@
(define (extract-to-evaluate s)
(let loop ([s s] [expect #f])
- (syntax-case s (code:line code:comment eval:alts eval:check)
+ (syntax-case s (code:line code:comment code:contract eval:alts eval:check)
[(code:line v (code:comment . rest))
(loop (extract s cdr car) expect)]
[(code:comment . rest)
(values (nothing-to-eval) expect)]
+ [(code:contract . rest)
+ (values (nothing-to-eval) expect)]
[(eval:alts p e)
(loop (extract s cdr cdr car) expect)]
[(eval:check e expect)
@@ -346,8 +348,10 @@
(define (comment? a)
(and (pair? a)
(or (eq? (car a) 'code:comment)
+ (eq? (car a) 'code:contract)
(and (identifier? (car a))
- (eq? (syntax-e (car a)) 'code:comment)))))
+ (or (eq? (syntax-e (car a)) 'code:comment)
+ (eq? (syntax-e (car a)) 'code:contract))))))
(if (or (comment? a) (and (syntax? a) (comment? (syntax-e a))))
(strip-comments (cdr stx))
(cons (strip-comments a)