add defidform/inline and use it to document on-draw

This commit is contained in:
Matthew Flatt 2010-04-28 06:41:43 -06:00
parent 65f4bcb9dc
commit b61a99c433
3 changed files with 39 additions and 23 deletions

View File

@ -20,7 +20,7 @@
(provide defform defform* defform/subs defform*/subs defform/none
defidform
defidform defidform/inline
specform specform/subs
specsubform specsubform/subs specspecsubform specspecsubform/subs
specsubform/inline
@ -173,6 +173,12 @@
(syntax/loc stx
(fm #:literals () spec desc ...))]))
(define-syntax (defidform/inline stx)
(syntax-case stx ()
[(_ id)
(identifier? #'id)
#'(defform-site (quote-syntax id))]))
(define-syntax (defidform stx)
(syntax-case stx ()
[(_ spec-id desc ...)
@ -307,6 +313,29 @@
(define (meta-symbol? s) (memq s '(... ...+ ?)))
(define (defform-site kw-id)
(let ([target-maker (id-to-form-target-maker kw-id #t)]
[content (list (definition-site (syntax-e kw-id)
kw-id #t))])
(if target-maker
(target-maker
content
(lambda (tag)
(make-toc-target-element
#f
(if kw-id
(list (make-index-element
#f content tag
(list (symbol->string (syntax-e kw-id)))
content
(with-exporting-libraries
(lambda (libs)
(make-form-index-desc (syntax-e kw-id)
libs)))))
content)
tag)))
(car content))))
(define (*defforms kw-id forms form-procs subs sub-procs contract-procs content-thunk)
(parameterize ([current-meta-list '(... ...+)])
(make-box-splice
@ -325,27 +354,7 @@
(list (to-element `(,x . ,(cdr form)))))))
(and kw-id
(eq? form (car forms))
(let ([target-maker (id-to-form-target-maker kw-id #t)]
[content (list (definition-site (syntax-e kw-id)
kw-id #t))])
(if target-maker
(target-maker
content
(lambda (tag)
(make-toc-target-element
#f
(if kw-id
(list (make-index-element
#f content tag
(list (symbol->string (syntax-e kw-id)))
content
(with-exporting-libraries
(lambda (libs)
(make-form-index-desc (syntax-e kw-id)
libs)))))
content)
tag)))
(car content)))))))))
(defform-site kw-id)))))))
forms form-procs)
(if (null? sub-procs)
null

View File

@ -549,6 +549,13 @@ Like @scheme[defform], but without registering a definition.}
Like @scheme[defform], but with a plain @scheme[id] as the form.}
@defform[(defidform/inline id)]{
Like @scheme[defidform], but @racket[id] is typeset as an inline
element. Use this form sparingly, because the typeset form does not
stand out to the reader as a specification of @racket[id].}
@defform[(specform maybe-literals datum maybe-contracts
pre-flow ...)]{

View File

@ -410,7 +410,7 @@ All @tech{MouseEvent}s are represented via strings:
}
For compatibility reasons, the teachpack also supports the keyword
@tt{on-draw} in lieu of @scheme[to-draw] but the latter is preferred
@defidform/inline[on-draw] in lieu of @scheme[to-draw] but the latter is preferred
now.
}