From a2f430020abbed14f887c2384a67aef04479111c Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 2 Oct 2015 15:15:31 -0600 Subject: [PATCH] scribble/eval: strip away `code:contract`s Make `code:contract` handled like `code:comment` for evaluation. Relevant to PR 15161 --- scribble-doc/scribblings/scribble/eval.scrbl | 2 +- scribble-lib/scribble/eval.rkt | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scribble-doc/scribblings/scribble/eval.scrbl b/scribble-doc/scribblings/scribble/eval.scrbl index 8d20d725..b781ed2b 100644 --- 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 index ea3c81fb..c48b22fb 100644 --- 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)