Add racketoptionalfont
Scribble used to support a custom style for optional brackets.
In particular, the optional brackets will be given the `'paren-shape`
of value `#\?`[1], and the CSS class `opt-color` will be tagged
to these brackets.
Later, Scribble supports the curry notation. Its implementation
no longer uses `'paren-shape` to indicate optional brackets.
Unfortunately, it accidentally dropped the `opt-color` tagging[2].
This PR restores the original behavior by tagging the class
`opt-color` to optional brackets. It also adds `racketoptionalfont`
so that Scribble users can typeset optional brackets.
Lastly, it cleans up the code that supports the `'paren-shape` of value
`#\?`, since it is effectively a deadcode.
Note that this PR does _not_ change any CSS styling, so there's no
visible change. It would make CSS styling customization easier, however.
[1]: 9b7993ea02 (diff-017add06555fc85fa3ae5f27a3eb52cbR253)
[2]: https://github.com/racket/scribble/commit/95ecb101d1cc61d212c4d520#diff-017add06555fc85fa3ae5f27a3eb52cbR879
This commit is contained in:
parent
cda7efa29c
commit
cbeee2d388
|
@ -8,10 +8,6 @@
|
||||||
|
|
||||||
@(define css tt)
|
@(define css tt)
|
||||||
|
|
||||||
@(define-syntax (opt-example stx)
|
|
||||||
;; A #\? 'paren-shape value triggers RktOpt:
|
|
||||||
#`@racket[#,(syntax-property #'(in-example) 'paren-shape '#\?)])
|
|
||||||
|
|
||||||
@title{Manual All-Styles Document}
|
@title{Manual All-Styles Document}
|
||||||
|
|
||||||
@table-of-contents[]
|
@table-of-contents[]
|
||||||
|
@ -76,7 +72,9 @@
|
||||||
|
|
||||||
@item{@css{RktModLink} (a linked module reference): @racketmodname[racket/base]}
|
@item{@css{RktModLink} (a linked module reference): @racketmodname[racket/base]}
|
||||||
|
|
||||||
@item{@css{RktOpt} (option-argument brackets): brackets in @opt-example[]}
|
@item{@css{RktOpt} (option-argument brackets): brackets in
|
||||||
|
|
||||||
|
@defproc[#:link-target? #f (f [x any/c 1]) any]}
|
||||||
|
|
||||||
@item{@css{RktKw} (not normally used): @racketkeywordfont{example}}
|
@item{@css{RktKw} (not normally used): @racketkeywordfont{example}}
|
||||||
|
|
||||||
|
|
|
@ -555,6 +555,11 @@ sub-form in a procedure being documented).}
|
||||||
@defproc[(racketparenfont [pre-content pre-content?] ...) element?]{Like
|
@defproc[(racketparenfont [pre-content pre-content?] ...) element?]{Like
|
||||||
@racket[racketplainfont], but colored like parentheses.}
|
@racket[racketplainfont], but colored like parentheses.}
|
||||||
|
|
||||||
|
@defproc[(racketoptionalfont [pre-content pre-content?] ...) element?]{Like
|
||||||
|
@racket[racketplainfont], but colored as optional.
|
||||||
|
@history[#:added "1.36"]
|
||||||
|
}
|
||||||
|
|
||||||
@defproc[(racketmetafont [pre-content pre-content?] ...) element?]{Like
|
@defproc[(racketmetafont [pre-content pre-content?] ...) element?]{Like
|
||||||
@racket[racketplainfont], but colored as meta-syntax, such as backquote or
|
@racket[racketplainfont], but colored as meta-syntax, such as backquote or
|
||||||
unquote.}
|
unquote.}
|
||||||
|
@ -596,6 +601,7 @@ in a form definition.}
|
||||||
@defproc[(schemevarfont [pre-content pre-content?] ...) element?]
|
@defproc[(schemevarfont [pre-content pre-content?] ...) element?]
|
||||||
@defproc[(schemekeywordfont [pre-content pre-content?] ...) element?]
|
@defproc[(schemekeywordfont [pre-content pre-content?] ...) element?]
|
||||||
@defproc[(schemeparenfont [pre-content pre-content?] ...) element?]
|
@defproc[(schemeparenfont [pre-content pre-content?] ...) element?]
|
||||||
|
@defproc[(schemeoptionalfont [pre-content pre-content?] ...) element?]
|
||||||
@defproc[(schememetafont [pre-content pre-content?] ...) element?]
|
@defproc[(schememetafont [pre-content pre-content?] ...) element?]
|
||||||
@defproc[(schemeerror [pre-content pre-content?] ...) element?]
|
@defproc[(schemeerror [pre-content pre-content?] ...) element?]
|
||||||
@defproc[(schememodfont [pre-content pre-content?] ...) element?]
|
@defproc[(schememodfont [pre-content pre-content?] ...) element?]
|
||||||
|
|
|
@ -236,7 +236,7 @@
|
||||||
[(eq? (arg-id arg) '_...superclass-args...) (to-element (arg-id arg))]
|
[(eq? (arg-id arg) '_...superclass-args...) (to-element (arg-id arg))]
|
||||||
[else (to-element (make-var-id (arg-id arg)))])]
|
[else (to-element (make-var-id (arg-id arg)))])]
|
||||||
[e (if (arg-ends-optional? arg)
|
[e (if (arg-ends-optional? arg)
|
||||||
(make-element #f (list e "]"))
|
(make-element #f (list e (racketoptionalfont "]")))
|
||||||
e)]
|
e)]
|
||||||
[num-closers (- (arg-depth arg) next-depth)]
|
[num-closers (- (arg-depth arg) next-depth)]
|
||||||
[e (if (zero? num-closers)
|
[e (if (zero? num-closers)
|
||||||
|
@ -244,7 +244,7 @@
|
||||||
(make-element
|
(make-element
|
||||||
#f (list e (make-closers num-closers))))])
|
#f (list e (make-closers num-closers))))])
|
||||||
(if (and show-opt-start? (arg-starts-optional? arg))
|
(if (and show-opt-start? (arg-starts-optional? arg))
|
||||||
(make-element #f (list "[" e))
|
(make-element #f (list (racketoptionalfont "[") e))
|
||||||
e)))
|
e)))
|
||||||
(define (prototype-depth p)
|
(define (prototype-depth p)
|
||||||
(let loop ([p (car p)])
|
(let loop ([p (car p)])
|
||||||
|
@ -514,7 +514,7 @@
|
||||||
(if one-ok?
|
(if one-ok?
|
||||||
(list*
|
(list*
|
||||||
(if (arg-starts-optional? (car args))
|
(if (arg-starts-optional? (car args))
|
||||||
(to-flow (make-element #f (list spacer "[")))
|
(to-flow (make-element #f (list spacer (racketoptionalfont "["))))
|
||||||
flow-spacer)
|
flow-spacer)
|
||||||
(to-flow ((arg->elem #f) (car args) (next-args-depth (cdr args))))
|
(to-flow ((arg->elem #f) (car args) (next-args-depth (cdr args))))
|
||||||
not-end)
|
not-end)
|
||||||
|
@ -533,7 +533,7 @@
|
||||||
(flow-spacer/n 3)
|
(flow-spacer/n 3)
|
||||||
flow-spacer)
|
flow-spacer)
|
||||||
(if (arg-starts-optional? (car args))
|
(if (arg-starts-optional? (car args))
|
||||||
(to-flow (make-element #f (list spacer "[")))
|
(to-flow (make-element #f (list spacer (racketoptionalfont "["))))
|
||||||
flow-spacer)
|
flow-spacer)
|
||||||
(let ([a ((arg->elem #f) (car args) (next-args-depth (cdr args)))]
|
(let ([a ((arg->elem #f) (car args) (next-args-depth (cdr args)))]
|
||||||
[next (if dots-next?
|
[next (if dots-next?
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
(provide/contract [id styling-f/c] ...))
|
(provide/contract [id styling-f/c] ...))
|
||||||
(provide-styling racketmodfont racketoutput
|
(provide-styling racketmodfont racketoutput
|
||||||
racketerror racketfont racketplainfont racketvalfont racketidfont racketvarfont
|
racketerror racketfont racketplainfont racketvalfont racketidfont racketvarfont
|
||||||
racketcommentfont racketparenfont racketkeywordfont racketmetafont
|
racketcommentfont racketparenfont racketoptionalfont racketkeywordfont racketmetafont
|
||||||
onscreen defterm filepath envvar Flag DFlag PFlag DPFlag math
|
onscreen defterm filepath envvar Flag DFlag PFlag DPFlag math
|
||||||
procedure
|
procedure
|
||||||
indexed-file indexed-envvar idefterm pidefterm)
|
indexed-file indexed-envvar idefterm pidefterm)
|
||||||
|
@ -47,6 +47,7 @@
|
||||||
[racketidfont schemeidfont]
|
[racketidfont schemeidfont]
|
||||||
[racketvarfont schemevarfont]
|
[racketvarfont schemevarfont]
|
||||||
[racketparenfont schemeparenfont]
|
[racketparenfont schemeparenfont]
|
||||||
|
[racketoptionalfont schemeoptionalfont]
|
||||||
[racketkeywordfont schemekeywordfont]
|
[racketkeywordfont schemekeywordfont]
|
||||||
[racketmetafont schememetafont])
|
[racketmetafont schememetafont])
|
||||||
|
|
||||||
|
@ -104,6 +105,8 @@
|
||||||
(make-element variable-color (decode-content str)))
|
(make-element variable-color (decode-content str)))
|
||||||
(define (racketparenfont . str)
|
(define (racketparenfont . str)
|
||||||
(make-element paren-color (decode-content str)))
|
(make-element paren-color (decode-content str)))
|
||||||
|
(define (racketoptionalfont . str)
|
||||||
|
(make-element opt-color (decode-content str)))
|
||||||
(define (racketmetafont . str)
|
(define (racketmetafont . str)
|
||||||
(make-element meta-color (decode-content str)))
|
(make-element meta-color (decode-content str)))
|
||||||
(define (racketcommentfont . str)
|
(define (racketcommentfont . str)
|
||||||
|
|
|
@ -606,9 +606,7 @@
|
||||||
quote-depth)]
|
quote-depth)]
|
||||||
[p-color (if (positive? quote-depth)
|
[p-color (if (positive? quote-depth)
|
||||||
value-color
|
value-color
|
||||||
(if (eq? sh #\?)
|
paren-color)])
|
||||||
opt-color
|
|
||||||
paren-color))])
|
|
||||||
(advance c init-line! srcless-step)
|
(advance c init-line! srcless-step)
|
||||||
(let ([quote-depth (if (struct-proxy? (syntax-e c))
|
(let ([quote-depth (if (struct-proxy? (syntax-e c))
|
||||||
quote-depth
|
quote-depth
|
||||||
|
@ -655,7 +653,7 @@
|
||||||
(set! src-col (+ src-col 2))))
|
(set! src-col (+ src-col 2))))
|
||||||
(unless (and expr? (zero? quote-depth))
|
(unless (and expr? (zero? quote-depth))
|
||||||
(out (case sh
|
(out (case sh
|
||||||
[(#\[ #\?) "["]
|
[(#\[) "["]
|
||||||
[(#\{) "{"]
|
[(#\{) "{"]
|
||||||
[else "("])
|
[else "("])
|
||||||
p-color))
|
p-color))
|
||||||
|
@ -738,7 +736,7 @@
|
||||||
srcless-step
|
srcless-step
|
||||||
#f))]))
|
#f))]))
|
||||||
(out (case sh
|
(out (case sh
|
||||||
[(#\[ #\?) "]"]
|
[(#\[) "]"]
|
||||||
[(#\{) "}"]
|
[(#\{) "}"]
|
||||||
[else ")"])
|
[else ")"])
|
||||||
p-color)
|
p-color)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user