Skip to content
21 changes: 6 additions & 15 deletions scribble-lib/scribble/private/define-popup.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,12 @@
[found-open?
(cond
[(char=? char #\})
(regexp-replace
#rx"^[\n ]*"
(regexp-replace
#rx"[\n ]*$"
(apply string (reverse chars))
"")
"")]
[else
(loop (+ pos 1) #t (cons char chars))])]
[else
(cond
[(char=? char #\{)
(loop (+ pos 1) #t '())]
[else
(loop (+ pos 1) #f '())])])]
(regexp-replace #rx"^[\n ]*"
(regexp-replace #rx"[\n ]*$" (apply string (reverse chars)) "")
"")]
[else (loop (+ pos 1) #t (cons char chars))])]
[(char=? char #\{) (loop (+ pos 1) #t '())]
[else (loop (+ pos 1) #f '())])]
[else #f])))

(define define-popup
Expand Down
31 changes: 12 additions & 19 deletions scribble-lib/scribble/private/doc-begin.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,15 @@
#'(check-pre-part s (quote-syntax loc))))]))

(define (check-pre-part v loc-stx)
(if (pre-part? v)
v
(error
(format
"~a: not valid in document body (need a pre-part for decode) in: ~e"
(cond
[(and (syntax-source loc-stx)
(syntax-line loc-stx))
(format "~a:~a:~a"
(syntax-source loc-stx)
(syntax-line loc-stx)
(syntax-column loc-stx))]
[(and (syntax-source loc-stx)
(syntax-position loc-stx))
(format "~a:::~a"
(syntax-source loc-stx)
(syntax-position loc-stx))]
[else 'document])
v))))
(unless (pre-part? v)
(error
(format
"~a: not valid in document body (need a pre-part for decode) in: ~e"
(cond
[(and (syntax-source loc-stx) (syntax-line loc-stx))
(format "~a:~a:~a" (syntax-source loc-stx) (syntax-line loc-stx) (syntax-column loc-stx))]
[(and (syntax-source loc-stx) (syntax-position loc-stx))
(format "~a:::~a" (syntax-source loc-stx) (syntax-position loc-stx))]
[else 'document])
v)))
v)
121 changes: 57 additions & 64 deletions scribble-lib/scribble/private/manual-bind.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@
(define hovers (make-weak-hasheq))
(define (intern-hover-style text)
(let ([text (datum-intern-literal text)])
(or (hash-ref hovers text #f)
(let ([s (make-style #f (list (make-hover-property text)))])
(hash-set! hovers text s)
s))))
(hash-ref! hovers text (λ () (make-style #f (list (make-hover-property text)))))))

(define (annote-exporting-library e)
(make-delayed-element
Expand All @@ -71,15 +68,13 @@
(if (and from (pair? from))
(make-element
(intern-hover-style
(string-append
"Provided from: "
(string-join (map ~s from) ", ")
(let ([from-pkgs (resolve-get/tentative p ri '(exporting-packages #f))])
(if (and from-pkgs (pair? from-pkgs))
(string-append
" | Package: "
(string-join (map ~a from-pkgs) ", "))
""))))
(string-join ", "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackfirth I don't think this is correct. The first argument to string-join must be a list.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#:before-first "Provided from: "
#:after-last
(let ([from-pkgs (resolve-get/tentative p ri '(exporting-packages #f))])
(if (and from-pkgs (pair? from-pkgs))
(string-append " | Package: " (string-join (map ~a from-pkgs) ", "))
""))))
e)
e))
(lambda () e)
Expand Down Expand Up @@ -114,30 +109,30 @@
(lambda (x add) x)))
(let ([lib
(or (for/or ([lib (in-list (or source-libs null))])
(let ([checker
(hash-ref
checkers lib
(lambda ()
(define ns-id
(let ([ns (make-base-empty-namespace)])
(parameterize ([current-namespace ns])
;; A `(namespace-require `(for-label ,lib))` can
;; fail if `lib` provides different bindings of the
;; same name at different phases. We can require phases
;; 1 and 0 separately, in which case the phase-0
;; binding shadows the phase-1 one in that case.
;; This strategy only works for documenting bindings
;; at phases 0 and 1, though.
(namespace-require `(just-meta 1 (for-label ,lib)))
(namespace-require `(just-meta 0 (for-label ,lib)))
(namespace-syntax-introduce (datum->syntax #f 'x)))))
(define (checker id intro)
(free-label-identifier=?
(intro (datum->syntax ns-id (syntax-e id)) 'add)
(intro id 'add)))
(hash-set! checkers lib checker)
checker))])
(and (checker id intro) lib)))
(define checker
(hash-ref checkers
lib
(lambda ()
(define ns-id
(let ([ns (make-base-empty-namespace)])
(parameterize ([current-namespace ns])
;; A `(namespace-require `(for-label ,lib))` can
;; fail if `lib` provides different bindings of the
;; same name at different phases. We can require phases
;; 1 and 0 separately, in which case the phase-0
;; binding shadows the phase-1 one in that case.
;; This strategy only works for documenting bindings
;; at phases 0 and 1, though.
(namespace-require `(just-meta 1 (for-label ,lib)))
(namespace-require `(just-meta 0 (for-label ,lib)))
(namespace-syntax-introduce (datum->syntax #f 'x)))))
(define (checker id intro)
(free-label-identifier=? (intro (datum->syntax ns-id (syntax-e id))
'add)
(intro id 'add)))
(hash-set! checkers lib checker)
checker)))
(and (checker id intro) lib))
(and (pair? libs) (car libs)))])
(and lib (module-path-index->taglet
(module-path-index-join lib #f)))))
Expand Down Expand Up @@ -198,33 +193,31 @@
#:show-libs? [show-libs? #t])
;; This function could have more optional argument to select
;; whether to index the id, include a toc link, etc.
(let ([dep? #t])
(define maker
(if form?
(id-to-form-target-maker id dep?)
(id-to-target-maker id dep?)))
(define-values (elem elem-ref)
(if show-libs?
(definition-site (syntax-e id) id form?)
(values (to-element id #:defn? #t)
(to-element id))))
(if maker
(maker elem
(lambda (tag)
(let ([elem
(if index?
(make-index-element
#f (list elem) tag
(list (datum-intern-literal (symbol->string (syntax-e id))))
(list elem)
(and show-libs?
(with-exporting-libraries
(lambda (libs)
(make-exported-index-desc (syntax-e id)
libs)))))
elem)])
(make-target-element #f (list elem) tag))))
elem)))
(define dep? #t)
(define maker
(if form?
(id-to-form-target-maker id dep?)
(id-to-target-maker id dep?)))
(define-values (elem elem-ref)
(if show-libs?
(definition-site (syntax-e id) id form?)
(values (to-element id #:defn? #t) (to-element id))))
(if maker
(maker elem
(lambda (tag)
(let ([elem (if index?
(make-index-element
#f
(list elem)
tag
(list (datum-intern-literal (symbol->string (syntax-e id))))
(list elem)
(and show-libs?
(with-exporting-libraries
(lambda (libs) (make-exported-index-desc (syntax-e id) libs)))))
elem)])
(make-target-element #f (list elem) tag))))
elem))

(define (make-binding-redirect-elements mod-path redirects)
(define taglet (module-path-index->taglet
Expand Down
39 changes: 15 additions & 24 deletions scribble-lib/scribble/private/manual-class.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,9 @@

(define (id-info id)
(define b (identifier-label-binding id))
(if b
(list (caddr b)
(list-ref b 3)
(list-ref b 4)
(list-ref b 5)
(list-ref b 6))
(error 'scribble "no class/interface/mixin information for identifier: ~e"
id)))
(unless b
(error 'scribble "no class/interface/mixin information for identifier: ~e" id))
(list (caddr b) (list-ref b 3) (list-ref b 4) (list-ref b 5) (list-ref b 6)))

(define (make-inherited-table r d ri decl)
(define start
Expand Down Expand Up @@ -155,11 +150,11 @@
null))

(define (build-body decl body)
`(,@(map (lambda (i)
(cond [(constructor? i) ((constructor-def i))]
[(meth? i) ((meth-def i))]
[else i]))
body)
`(,@(for/list ([i (in-list body)])
(cond
[(constructor? i) ((constructor-def i))]
[(meth? i) ((meth-def i))]
[else i]))
,(make-delayed-block (lambda (r d ri) (make-inherited-table r d ri decl)))))

(define (*include-class/title decl link?)
Expand Down Expand Up @@ -408,17 +403,13 @@
(datum->syntax n (syntax-e n) (list 'src 1 3 4 1)))
(list 'src 1 0 1 5))]
[(((kw ...) ...) ...)
(map (lambda (ids)
(map (lambda (arg)
(if (and (pair? (syntax-e arg))
(eq? (syntax-e #'mode) 'new))
(list (string->keyword
(symbol->string
(syntax-e
(car (syntax-e arg))))))
null))
(syntax->list ids)))
(syntax->list #'((arg ...) ...)))])
(for/list ([ids (in-list (syntax->list #'((arg ...) ...)))])
(map (lambda (arg)
(if (and (pair? (syntax-e arg)) (eq? (syntax-e #'mode) 'new))
(list (string->keyword
(symbol->string (syntax-e (car (syntax-e arg))))))
null))
(syntax->list ids)))])
#'(make-constructor (lambda ()
(defproc* #:mode mode #:within name
[[(make [kw ... . arg] ...) result] ...]
Expand Down
37 changes: 16 additions & 21 deletions scribble-lib/scribble/private/manual-form.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,12 @@
flow-empty-line flow-empty-line)
(list (to-flow nonterm) flow-empty-line (to-flow "=") flow-empty-line
(make-flow (list (car clauses))))
(map (lambda (clause)
(list flow-empty-line flow-empty-line
(to-flow "|") flow-empty-line
(make-flow (list clause))))
(cdr clauses))))
(for/list ([clause (in-list (cdr clauses))])
(list flow-empty-line
flow-empty-line
(to-flow "|")
flow-empty-line
(make-flow (list clause))))))
nonterms clauseses))))

(define (*racketrawgrammar style nonterm clause1 . clauses)
Expand All @@ -426,11 +427,8 @@
(define (*racketgrammar lits s-expr clauseses-thunk)
(define l (clauseses-thunk))
(*racketrawgrammars #f
(map (lambda (x)
(make-element #f
(list (hspace 2)
(car x))))
l)
(for/list ([x (in-list l)])
(make-element #f (list (hspace 2) (car x))))
(map cdr l)))

(define (*var id)
Expand All @@ -445,14 +443,11 @@
(append
(list (list flow-empty-line))
(list (list (make-flow
(map (lambda (c)
(make-table
"argcontract"
(list
(list (to-flow (hspace 2))
(to-flow ((car c)))
flow-spacer
(to-flow ":")
flow-spacer
(make-flow (list ((cadr c))))))))
contract-procs)))))))
(for/list ([c (in-list contract-procs)])
(make-table "argcontract"
(list (list (to-flow (hspace 2))
(to-flow ((car c)))
flow-spacer
(to-flow ":")
flow-spacer
(make-flow (list ((cadr c))))))))))))))
Loading
Loading