add cross-reference between data and read/print descriptions

Closes PR 11096
(cherry picked from commit d4f7020cd2)
This commit is contained in:
Matthew Flatt 2011-10-15 07:18:01 -07:00 committed by Eli Barzilay
parent 7ad41cd9dc
commit 394e62a31e
12 changed files with 175 additions and 139 deletions

View File

@ -9,7 +9,9 @@ depend on a boolean value typically treat anything other than
@racket[#f] as true. The @racket[#t] value is always @racket[eq?] to @racket[#f] as true. The @racket[#t] value is always @racket[eq?] to
itself, and @racket[#f] is always @racket[eq?] to itself. itself, and @racket[#f] is always @racket[eq?] to itself.
See also: @racket[and], @racket[or], @racket[andmap], @racket[ormap]. @see-read-print["boolean" #:print "booleans"]{booleans}
See also @racket[and], @racket[or], @racket[andmap], and @racket[ormap].
@defproc[(boolean? [v any/c]) boolean?]{ @defproc[(boolean? [v any/c]) boolean?]{

View File

@ -22,6 +22,8 @@ A byte string can be used as a single-valued sequence (see
@secref["sequences"]). The bytes of the string serve as elements @secref["sequences"]). The bytes of the string serve as elements
of the sequence. See also @racket[in-bytes]. of the sequence. See also @racket[in-bytes].
@see-read-print["string"]{byte strings}
See also: @racket[immutable?]. See also: @racket[immutable?].
@; ---------------------------------------- @; ----------------------------------------

View File

@ -18,6 +18,8 @@ Two characters are @racket[eqv?] if they correspond to the same scalar
value. For each scalar value less than 256, character values that are value. For each scalar value less than 256, character values that are
@racket[eqv?] are also @racket[eq?]. @racket[eqv?] are also @racket[eq?].
@see-read-print["character"]{characters}
@; ---------------------------------------- @; ----------------------------------------
@section{Characters and Scalar Values} @section{Characters and Scalar Values}

View File

@ -59,6 +59,8 @@ disappear when placed into a weak box (see @secref["weakbox"]) used as
the key in a weak @tech{hash table} (see @secref["hashtables"]), or the key in a weak @tech{hash table} (see @secref["hashtables"]), or
used as an ephemeron key (see @secref["ephemerons"]). used as an ephemeron key (see @secref["ephemerons"]).
@see-read-print["symbol"]{symbols}
@defproc[(symbol? [v any/c]) boolean?]{Returns @racket[#t] if @racket[v] is @defproc[(symbol? [v any/c]) boolean?]{Returns @racket[#t] if @racket[v] is
a symbol, @racket[#f] otherwise. a symbol, @racket[#f] otherwise.
@ -141,6 +143,8 @@ Two keywords are @racket[eq?] if and only if they print the same.
Like symbols, keywords are only weakly held by the internal keyword Like symbols, keywords are only weakly held by the internal keyword
table; see @secref["symbols"] for more information. table; see @secref["symbols"] for more information.
@see-read-print["keyword"]{keywords}
@defproc[(keyword? [v any/c]) boolean?]{ @defproc[(keyword? [v any/c]) boolean?]{
Returns @racket[#t] if @racket[v] is a keyword, @racket[#f] otherwise.} Returns @racket[#t] if @racket[v] is a keyword, @racket[#f] otherwise.}
@ -178,6 +182,8 @@ for each pair of keywords is the same as using
A @deftech{box} is like a single-element vector, normally used as A @deftech{box} is like a single-element vector, normally used as
minimal mutable storage. minimal mutable storage.
A literal or printed box starts with @litchar{#&}. @see-read-print["box"]{boxes}
@defproc[(box? [v any/c]) boolean?]{ @defproc[(box? [v any/c]) boolean?]{
Returns @racket[#t] if @racket[v] is a box, @racket[#f] otherwise.} Returns @racket[#t] if @racket[v] is a box, @racket[#f] otherwise.}

View File

@ -80,6 +80,9 @@ keys:}} If a key in an @racket[equal?]-based hash table is mutated
hash table's behavior for insertion and lookup operations becomes hash table's behavior for insertion and lookup operations becomes
unpredictable. unpredictable.
A literal or printed hash table starts with @litchar{#hash},
@litchar{#hasheqv}, or
@litchar{#hasheq}. @see-read-print["hashtable"]{hash tables}
@defproc[(hash? [v any/c]) boolean?]{ @defproc[(hash? [v any/c]) boolean?]{

View File

@ -1,137 +1,145 @@
(module mz racket/base #lang at-exp racket/base
(require scribble/struct
scribble/manual (require scribble/struct
scribble/eval scribble/manual
scribble/decode scribble/eval
racket/contract scribble/decode
"../icons.rkt") racket/contract
"../icons.rkt")
(provide (all-from-out scribble/manual)
(all-from-out scribble/eval) (provide (all-from-out scribble/manual)
(all-from-out racket/contract)) (all-from-out scribble/eval)
(all-from-out racket/contract))
(require (for-label racket))
(provide (for-label (all-from-out racket))) (require (for-label racket))
(provide (for-label (all-from-out racket)))
(provide mz-examples)
(define mz-eval (make-base-eval)) (provide mz-examples)
(define-syntax mz-examples (define mz-eval (make-base-eval))
(syntax-rules () (define-syntax mz-examples
[(_ #:eval . rest) (syntax-rules ()
(examples #:eval . rest)] [(_ #:eval . rest)
[(_ . rest) (examples #:eval . rest)]
(examples #:eval mz-eval . rest)])) [(_ . rest)
(examples #:eval mz-eval . rest)]))
(define AllUnix "Unix and Mac OS X")
(provide AllUnix) (define AllUnix "Unix and Mac OS X")
(provide AllUnix)
(provide note-lib)
(define-syntax note-lib (provide note-lib)
(syntax-rules () (define-syntax note-lib
[(_ lib #:use-sources (src ...) . more) (syntax-rules ()
(begin [(_ lib #:use-sources (src ...) . more)
(declare-exporting lib racket #:use-sources (src ...)) (begin
(defmodule*/no-declare (lib) (declare-exporting lib racket #:use-sources (src ...))
(t (make-collect-element (defmodule*/no-declare (lib)
#f null (t (make-collect-element
(lambda (ci) #f null
(collect-put! ci `(racket-extra-lib ,'lib) (racketmodname lib)))) (lambda (ci)
"The bindings documented in this section are provided by the " (collect-put! ci `(racket-extra-lib ,'lib) (racketmodname lib))))
(racketmodname lib) "The bindings documented in this section are provided by the "
" and " (racketmodname lib)
(racketmodname racket) " and "
" libraries, but not " (racketmodname racket/base) (racketmodname racket)
"." " libraries, but not " (racketmodname racket/base)
. more)))] "."
[(_ lib . more) . more)))]
(note-lib lib #:use-sources () . more)])) [(_ lib . more)
(note-lib lib #:use-sources () . more)]))
(provide note-init-lib)
(define-syntax note-init-lib (provide note-init-lib)
(syntax-rules () (define-syntax note-init-lib
[(_ lib #:use-sources (src ...) . more) (syntax-rules ()
(begin [(_ lib #:use-sources (src ...) . more)
(declare-exporting lib racket/init #:use-sources (src ...)) (begin
(defmodule*/no-declare (lib) (declare-exporting lib racket/init #:use-sources (src ...))
(t "The bindings documented in this section are provided by the " (defmodule*/no-declare (lib)
(racketmodname lib)
" and "
(racketmodname racket/init)
" libraries, which means that they are available when "
" the Racket executable is started with no command-line arguments."
" They are not provided by " (racketmodname racket/base)
" or " (racketmodname racket) "."
. more)))]
[(_ lib . more)
(note-init-lib lib #:use-sources () . more)]))
(provide note-lib-only)
(define-syntax note-lib-only
(syntax-rules ()
[(_ lib #:use-sources (src ...) . more)
(defmodule lib #:use-sources (src ...)
(t "The bindings documented in this section are provided by the " (t "The bindings documented in this section are provided by the "
(racketmodname lib) (racketmodname lib)
" library, not " (racketmodname racket/base) " and "
" or " (racketmodname racket) (racketmodname racket/init)
"." " libraries, which means that they are available when "
. more))] " the Racket executable is started with no command-line arguments."
[(_ lib . more) " They are not provided by " (racketmodname racket/base)
(note-lib-only lib #:use-sources () . more)])) " or " (racketmodname racket) "."
. more)))]
[(_ lib . more)
(note-init-lib lib #:use-sources () . more)]))
(define (*exnraise s) (provide note-lib-only)
(make-element #f (list s " exception is raised"))) (define-syntax note-lib-only
(define-syntax exnraise (syntax-rules ()
(syntax-rules () [(_ lib #:use-sources (src ...) . more)
[(_ s) (*exnraise (racket s))])) (defmodule lib #:use-sources (src ...)
(define-syntax Exn (t "The bindings documented in this section are provided by the "
(syntax-rules () (racketmodname lib)
[(_ s) (racket s)])) " library, not " (racketmodname racket/base)
(provide exnraise Exn) " or " (racketmodname racket)
"."
(provide margin-note/ref . more))]
refalso moreref Guide guideintro guidealso guidesecref [(_ lib . more)
raco-doc) (note-lib-only lib #:use-sources () . more)]))
(define (margin-note/ref . s)
(apply margin-note
(decode-content (cons magnify s))))
(define (refalso tag . s)
(apply margin-note
(decode-content (append (list magnify (secref tag) " also provides information on ")
s
(list ".")))))
(define (moreref tag . s)
(apply margin-note
(decode-content (append (list magnify (secref tag) " provides more information on ")
s
(list ".")))))
(define (guidesecref s)
(secref #:doc '(lib "scribblings/guide/guide.scrbl") s))
(define (guideintro tag . s)
(apply margin-note
(decode-content (append (list finger (guidesecref tag) " in " Guide " introduces ")
s
(list ".")))))
(define (guidealso tag) (define (*exnraise s)
(apply margin-note (make-element #f (list s " exception is raised")))
(decode-content (append (list finger "See also " (guidesecref tag) " in " Guide "."))))) (define-syntax exnraise
(syntax-rules ()
(define Guide [(_ s) (*exnraise (racket s))]))
(other-manual '(lib "scribblings/guide/guide.scrbl"))) (define-syntax Exn
(syntax-rules ()
[(_ s) (racket s)]))
(provide exnraise Exn)
(define raco-doc (provide margin-note/ref
'(lib "scribblings/raco/raco.scrbl")) refalso moreref Guide guideintro guidealso guidesecref
raco-doc)
(provide speed)
(define-syntax speed (define (margin-note/ref . s)
(syntax-rules () (apply margin-note
[(_ id what) (decode-content (cons magnify s))))
(t "An " (racket id) " application can provide better performance for "
(elem what) (define (refalso tag . s)
" iteration when it appears directly in a " (racket for) " clause.")]))) (apply margin-note
(decode-content (append (list magnify (secref tag) " also provides information on ")
s
(list ".")))))
(define (moreref tag . s)
(apply margin-note
(decode-content (append (list magnify (secref tag) " provides more information on ")
s
(list ".")))))
(define (guidesecref s)
(secref #:doc '(lib "scribblings/guide/guide.scrbl") s))
(define (guideintro tag . s)
(apply margin-note
(decode-content (append (list finger (guidesecref tag) " in " Guide " introduces ")
s
(list ".")))))
(define (guidealso tag)
(apply margin-note
(decode-content (append (list finger "See also " (guidesecref tag) " in " Guide ".")))))
(define Guide
(other-manual '(lib "scribblings/guide/guide.scrbl")))
(define raco-doc
'(lib "scribblings/raco/raco.scrbl"))
(provide see-read-print)
(define (see-read-print tag-part #:print [print-tag-part tag-part] vals)
@elem{See @secref[(string-append "parse-" tag-part)]
for information on @racket[read]ing
@|vals| and @secref[(string-append "print-" print-tag-part)]
for information on @racket[print]ing @|vals|.})
(provide speed)
(define-syntax speed
(syntax-rules ()
[(_ id what)
(t "An " (racket id) " application can provide better performance for "
(elem what)
" iteration when it appears directly in a " (racket for) " clause.")]))

View File

@ -87,6 +87,8 @@ exact, and when they are @racket[=] (except for @racket[+nan.0], @racket[+nan.f]
@racket[+0.0], @racket[+0.0f0], @racket[-0.0], and @racket[-0.0f0], as noted above). Two numbers are @racket[+0.0], @racket[+0.0f0], @racket[-0.0], and @racket[-0.0f0], as noted above). Two numbers are
@racket[equal?] when they are @racket[eqv?]. @racket[equal?] when they are @racket[eqv?].
@see-read-print["number"]{numbers}
@local-table-of-contents[] @local-table-of-contents[]
@; ---------------------------------------- @; ----------------------------------------

View File

@ -97,6 +97,8 @@ Cyclic data structures can be created using only immutable pairs via
and using some number of @racket[cdr]s returns to the starting pair, and using some number of @racket[cdr]s returns to the starting pair,
then the pair is not a list. then the pair is not a list.
@see-read-print["pair" #:print "pairs"]{pairs and lists}
@; ---------------------------------------- @; ----------------------------------------
@section{Pair Constructors and Selectors} @section{Pair Constructors and Selectors}

View File

@ -97,7 +97,7 @@ Symbols @racket[print] the same as they @racket[write], unless
@racket[print]ed form is prefixed with @litchar{'}. For the purposes @racket[print]ed form is prefixed with @litchar{'}. For the purposes
of printing enclosing datatypes, a symbol is @tech{quotable}. of printing enclosing datatypes, a symbol is @tech{quotable}.
@section{Printing Numbers} @section[#:tag "print-number"]{Printing Numbers}
A @tech{number} prints the same way in @racket[write], @racket[display], and A @tech{number} prints the same way in @racket[write], @racket[display], and
@racket[print] modes. For the purposes of printing enclosing @racket[print] modes. For the purposes of printing enclosing
@ -126,7 +126,7 @@ determined by @racket[numerator] and @racket[denominator]).
A negative @tech{exact number} prints with a @litchar{-} prefix on the A negative @tech{exact number} prints with a @litchar{-} prefix on the
printed form of the number's exact negation. printed form of the number's exact negation.
@section{Printing Booleans} @section[#:tag "print-booleans"]{Printing Booleans}
The @tech{boolean} constant @racket[#t] prints as @litchar{#true} or @litchar{#t} in The @tech{boolean} constant @racket[#t] prints as @litchar{#true} or @litchar{#t} in
all modes (@racket[display], @racket[write], and @racket[print]), all modes (@racket[display], @racket[write], and @racket[print]),
@ -219,7 +219,7 @@ always @tech{quotable}, a pair is @tech{quotable} when its
@racket[car] and @racket[cdr] are @tech{quotable}, and a mutable list @racket[car] and @racket[cdr] are @tech{quotable}, and a mutable list
is never @tech{quotable}. is never @tech{quotable}.
@section{Printing Strings} @section[#:tag "print-string"]{Printing Strings}
All @tech{strings} @racket[display] as their literal character sequences. All @tech{strings} @racket[display] as their literal character sequences.
@ -419,7 +419,7 @@ When the @racket[print-box] parameter is set to @racket[#f], a box
prints as @litchar{#<box>} and counts as @tech{quotable}. prints as @litchar{#<box>} and counts as @tech{quotable}.
@section{Printing Characters} @section[#:tag "print-character"]{Printing Characters}
@tech{Characters} with the special names described in @tech{Characters} with the special names described in
@secref["parse-character"] @racket[write] and @racket[print] using the @secref["parse-character"] @racket[write] and @racket[print] using the
@ -439,7 +439,7 @@ For the purposes of printing enclosing datatypes, a character is
@tech{quotable}. @tech{quotable}.
@section{Printing Keywords} @section[#:tag "print-keyword"]{Printing Keywords}
@tech{Keywords} @racket[write], @racket[print], and @racket[display] the same @tech{Keywords} @racket[write], @racket[print], and @racket[display] the same
as symbols (see @secref["print-symbol"]) except with a leading as symbols (see @secref["print-symbol"]) except with a leading
@ -452,7 +452,7 @@ For the purposes of printing enclosing datatypes, a keyword is
@tech{quotable}. @tech{quotable}.
@section{Printing Regular Expressions} @section[#:tag "print-regexp"]{Printing Regular Expressions}
@tech{Regexp values} @racket[write], @racket[display], and @racket[print] @tech{Regexp values} @racket[write], @racket[display], and @racket[print]
starting with @litchar{#px} (for @racket[pregexp]-based regexps) or starting with @litchar{#px} (for @racket[pregexp]-based regexps) or

View File

@ -54,6 +54,9 @@ compatible with Perl. In addition, Racket constants written with
@litchar{#rx} or @litchar{#px} (see @secref["reader"]) produce @litchar{#rx} or @litchar{#px} (see @secref["reader"]) produce
compiled regexp values. compiled regexp values.
A literal or printed regular expression starts with @litchar{#rx} or
@litchar{#px}. @see-read-print["regexp"]{regular expressions}
The internal size of a regexp value is limited to 32 kilobytes; this The internal size of a regexp value is limited to 32 kilobytes; this
limit roughly corresponds to a source string with 32,000 literal limit roughly corresponds to a source string with 32,000 literal
characters or 5,000 operators. characters or 5,000 operators.

View File

@ -22,6 +22,8 @@ A string can be used as a single-valued sequence (see
@secref["sequences"]). The characters of the string serve as elements @secref["sequences"]). The characters of the string serve as elements
of the sequence. See also @racket[in-string]. of the sequence. See also @racket[in-string].
@see-read-print["string"]{strings}
See also: @racket[immutable?], @racket[symbol->string], See also: @racket[immutable?], @racket[symbol->string],
@racket[bytes->string/utf-8]. @racket[bytes->string/utf-8].

View File

@ -22,6 +22,10 @@ A vector can be used as a single-valued sequence (see
@secref["sequences"]). The elements of the vector serve as elements @secref["sequences"]). The elements of the vector serve as elements
of the sequence. See also @racket[in-vector]. of the sequence. See also @racket[in-vector].
A literal or printed vector starts with @litchar{#(}, optionally with
a number between the @litchar{#} and
@litchar{(}. @see-read-print["vector" #:print "vectors"]{vectors}
@defproc[(vector? [v any/c]) boolean?]{ @defproc[(vector? [v any/c]) boolean?]{
Returns @racket[#t] if @racket[v] is a vector, @racket[#f] otherwise.} Returns @racket[#t] if @racket[v] is a vector, @racket[#f] otherwise.}