From 9927b0b576063d2ee99a2089825098aa9a7e7781 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 16 Feb 2009 22:04:51 +0000 Subject: [PATCH] changed htdp languages to allow identifier module paths; scribble improvements to latex back-end; added definterface svn: r13681 --- collects/lang/private/teach.ss | 10 ++++ collects/scheme/include.ss | 4 +- collects/scribble/latex-render.ss | 47 ++++++++++--------- collects/scribble/manual.ss | 1 + collects/scribble/private/manual-bind.ss | 32 +++++++++++++ collects/scribble/private/manual-class.ss | 19 ++++++-- collects/scribble/scribble.tex | 5 +- .../scribblings/htdp-langs/advanced.scrbl | 2 +- .../htdp-langs/beginner-abbr.scrbl | 2 +- .../scribblings/htdp-langs/beginner.scrbl | 7 +++ .../htdp-langs/intermediate-lambda.scrbl | 2 +- .../scribblings/htdp-langs/intermediate.scrbl | 2 +- collects/scribblings/reference/class.scrbl | 8 ++-- collects/scribblings/reference/sandbox.scrbl | 3 +- collects/scribblings/scribble/basic.scrbl | 4 +- collects/scribblings/scribble/manual.scrbl | 23 +++++++++ .../2htdp/scribblings/universe.scrbl | 4 +- 17 files changed, 133 insertions(+), 42 deletions(-) diff --git a/collects/lang/private/teach.ss b/collects/lang/private/teach.ss index 7e305d8989..5330e7b815 100644 --- a/collects/lang/private/teach.ss +++ b/collects/lang/private/teach.ss @@ -1183,6 +1183,16 @@ (begin (check-string-form stx #'s) #'(require s))] + [(_ id) + (identifier? #'id) + (begin + (unless (module-path? (syntax-e #'id)) + (teach-syntax-error + 'require + stx + #'id + "bad syntax for a module path")) + #'(require id))] [(_ (lib . rest)) (let ([s (syntax->list #'rest)]) (unless ((length s) . >= . 2) diff --git a/collects/scheme/include.ss b/collects/scheme/include.ss index 45657159a7..94cace375b 100644 --- a/collects/scheme/include.ss +++ b/collects/scheme/include.ss @@ -32,7 +32,9 @@ [(pair? e) (or (loop (car e)) (loop (cdr e)))] [else #f]))) - read-syntax)]) + (lambda (src in) + (parameterize ([read-accept-reader #t]) + (read-syntax src in))))]) (unless (and (procedure? read-syntax) (procedure-arity-includes? read-syntax 2)) (raise-syntax-error diff --git a/collects/scribble/latex-render.ss b/collects/scribble/latex-render.ss index 0c6724b273..e125e8fd24 100644 --- a/collects/scribble/latex-render.ss +++ b/collects/scribble/latex-render.ss @@ -228,14 +228,6 @@ (define/override (render-table t part ri inline-table?) (let* ([boxed? (eq? 'boxed (table-style t))] [index? (eq? 'index (table-style t))] - [inline? - (and (not boxed?) (not index?) - (or (null? (table-flowss t)) - (= 1 (length (car (table-flowss t))))) - (let ([m (current-table-mode)]) - (and m - (equal? "bigtabular" (car m)) - (= 1 (length (car (table-flowss (cadr m))))))))] [tableform (cond [index? "list"] [(and (not (current-table-mode)) (not inline-table?)) @@ -244,7 +236,21 @@ [opt (cond [(equal? tableform "bigtabular") "[l]"] [(equal? tableform "tabular") "[t]"] [else ""])] - [flowss (if index? (cddr (table-flowss t)) (table-flowss t))]) + [flowss (if index? (cddr (table-flowss t)) (table-flowss t))] + [row-styles (cdr (or (and (list? (table-style t)) + (assoc 'row-styles (table-style t))) + (cons #f (map (lambda (x) #f) flowss))))] + [inline? + (and (not boxed?) + (not index?) + (ormap (lambda (rs) (equal? rs "inferencetop")) row-styles) + (or (null? (table-flowss t)) + (= 1 (length (car (table-flowss t))))) + (let ([m (current-table-mode)]) + (and m + (equal? "bigtabular" (car m)) + (= 1 (length (car (table-flowss (cadr m))))))))] + [boxline "{\\setlength{\\unitlength}{\\linewidth}\\begin{picture}(1,0)\\put(0,0){\\line(1,0){1}}\\end{picture}}"]) (unless (or (null? flowss) (null? (car flowss))) (parameterize ([current-table-mode (if inline? (current-table-mode) (list tableform t))] @@ -254,14 +260,7 @@ [index? (printf "\\begin{list}{}{\\parsep=0pt \\itemsep=1pt \\leftmargin=2ex \\itemindent=-2ex}\n")] [inline? (void)] [else - (printf "\n\n~a\\begin{~a}~a{@{}~a}\n" - (if boxed? - (format "{~a\\begin{picture}(1,0)\\put(0,0){\\line(1,0){1}}\\end{picture}}~a\n\\nopagebreak\n" - "\\setlength{\\unitlength}{\\linewidth}" - (if (equal? tableform "bigtabular") - "\\bigtabline" - "\n\n")) - "") + (printf "\n\n\\begin{~a}~a{@{}~a}\n~a" tableform opt (string-append* @@ -276,12 +275,16 @@ (assoc 'alignment (or (table-style t) null))) (cons #f (map (lambda (x) #f) - (car flowss))))))))]) + (car flowss))))))) + (if boxed? + (if (equal? tableform "bigtabular") + (format "~a \\endfirsthead\n" boxline) + (format "\\multicolumn{~a}{@{}l@{}}{~a} \\\\\n" + (length (car flowss)) + boxline)) + ""))]) (let loop ([flowss flowss] - [row-styles - (cdr (or (and (list? (table-style t)) - (assoc 'row-styles (table-style t))) - (cons #f (map (lambda (x) #f) flowss))))]) + [row-styles row-styles]) (let ([flows (car flowss)] [row-style (car row-styles)]) (let loop ([flows flows]) diff --git a/collects/scribble/manual.ss b/collects/scribble/manual.ss index 1680771048..c902936141 100644 --- a/collects/scribble/manual.ss +++ b/collects/scribble/manual.ss @@ -14,6 +14,7 @@ (provide unsyntax make-binding-redirect-elements + defidentifier (all-from-out "basic.ss" "private/manual-style.ss" "private/manual-scheme.ss" diff --git a/collects/scribble/private/manual-bind.ss b/collects/scribble/private/manual-bind.ss index 331aa024b8..b136277545 100644 --- a/collects/scribble/private/manual-bind.ss +++ b/collects/scribble/private/manual-bind.ss @@ -26,6 +26,7 @@ with-exporting-libraries id-to-target-maker id-to-form-target-maker + defidentifier *sig-elem (struct-out sig) ;; public: @@ -170,6 +171,37 @@ (lambda () (car content)) (lambda () (car content)))))) +(define (defidentifier id + #:form? [form? #f] + #:index? [index? #t] + #: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]) + (let ([maker (if form? + (id-to-form-target-maker id dep?) + (id-to-target-maker id dep?))] + [elem (if show-libs? + (definition-site (syntax-e id) id form?) + (to-element id))]) + (if maker + (maker (list elem) + (lambda (tag) + (let ([elem + (if index? + (make-index-element + #f (list elem) tag + (list (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) (let ([taglet (module-path-index->taglet (module-path-index-join mod-path #f))]) diff --git a/collects/scribble/private/manual-class.ss b/collects/scribble/private/manual-class.ss index c76dbb224f..9d3a4968b7 100644 --- a/collects/scribble/private/manual-class.ss +++ b/collects/scribble/private/manual-class.ss @@ -173,11 +173,20 @@ (make-decl-collect decl) (append ((decl-mk-head decl) #f) - (list - (make-blockquote - "leftindent" - (flow-paragraphs - (decode-flow (build-body decl (decl-body decl)))))))))) + (let-values ([(pre post) + (let loop ([l (decl-body decl)][accum null]) + (cond + [(null? l) (values (reverse accum) null)] + [(or (constructor? (car l)) (meth? (car l))) + (values (reverse accum) l)] + [else (loop (cdr l) (cons (car l) accum))]))]) + (append + (flow-paragraphs (decode-flow pre)) + (list + (make-blockquote + "leftindent" + (flow-paragraphs + (decode-flow (build-body decl post))))))))))) (define (*class-doc kind stx-id super intfs ranges whole-page? make-index-desc) (make-table diff --git a/collects/scribble/scribble.tex b/collects/scribble/scribble.tex index 54d304a7a8..abd2ae20fd 100644 --- a/collects/scribble/scribble.tex +++ b/collects/scribble/scribble.tex @@ -15,6 +15,7 @@ \usepackage{hyperref} \renewcommand{\rmdefault}{ptm} \usepackage{longtable} +\usepackage{relsize} \usepackage[htt]{hyphenat} \usepackage[usenames,dvipsnames]{color} \hypersetup{bookmarks=true,bookmarksopen=true,bookmarksnumbered=true} @@ -67,8 +68,8 @@ \newcommand{\indexlink}[1]{#1} \newcommand{\noborder}[1]{#1} \newcommand{\imageleft}[1]{} % drop it -\newcommand{\smaller}[1]{{\footnotesize #1}} -\newcommand{\refpara}[1]{\marginpar{\footnotesize #1}} +\renewcommand{\smaller}[1]{\textsmaller{#1}} +\newcommand{\refpara}[1]{\marginpar{\raggedright \footnotesize #1}} \newcommand{\titleAndEmptyVersion}[2]{\title{#1}\maketitle} \newcommand{\titleAndVersion}[2]{\title{#1\\{\normalsize Version #2}}\maketitle} diff --git a/collects/scribblings/htdp-langs/advanced.scrbl b/collects/scribblings/htdp-langs/advanced.scrbl index 9bc2d3983b..97fef1bd5d 100644 --- a/collects/scribblings/htdp-langs/advanced.scrbl +++ b/collects/scribblings/htdp-langs/advanced.scrbl @@ -349,6 +349,6 @@ The same as Beginning's @|beg-check-expect|, etc.} Constants for the empty list, true, and false.} -@defform[(require string)]{ +@defform[(require module-path)]{ The same as Beginning's @|beg-require|.} diff --git a/collects/scribblings/htdp-langs/beginner-abbr.scrbl b/collects/scribblings/htdp-langs/beginner-abbr.scrbl index bba47aa84f..37962fa30d 100644 --- a/collects/scribblings/htdp-langs/beginner-abbr.scrbl +++ b/collects/scribblings/htdp-langs/beginner-abbr.scrbl @@ -184,6 +184,6 @@ The same as Beginning's @|beg-check-expect|, etc.} Constants for the empty list, true, and false.} -@defform[(require string)]{ +@defform[(require module-path)]{ The same as Beginning's @|beg-require|.} diff --git a/collects/scribblings/htdp-langs/beginner.scrbl b/collects/scribblings/htdp-langs/beginner.scrbl index 1147bde639..170d3febd6 100644 --- a/collects/scribblings/htdp-langs/beginner.scrbl +++ b/collects/scribblings/htdp-langs/beginner.scrbl @@ -318,6 +318,13 @@ lowercase), @litchar{0} through @litchar{9}, @litchar{-}, @litchar{_}, and @litchar{.}, and the string cannot be empty or contain a leading or trailing @litchar{/}.} +@defform/none[#:literals (require) + (require module-id)]{ + +Accesses a file in an installed library. The library name is an +identifier with the same constraints as for a relative-path string, +with the additional constraint that it must not contain a +@litchar{.}.} @defform/none[#:literals (require lib) (require (lib string string ...))]{ diff --git a/collects/scribblings/htdp-langs/intermediate-lambda.scrbl b/collects/scribblings/htdp-langs/intermediate-lambda.scrbl index 0ba2862bb4..f3c63795ce 100644 --- a/collects/scribblings/htdp-langs/intermediate-lambda.scrbl +++ b/collects/scribblings/htdp-langs/intermediate-lambda.scrbl @@ -187,6 +187,6 @@ The same as Beginning's @|beg-check-expect|, etc.} Constants for the empty list, true, and false.} -@defform[(require string)]{ +@defform[(require module-path)]{ The same as Beginning's @|beg-require|.} diff --git a/collects/scribblings/htdp-langs/intermediate.scrbl b/collects/scribblings/htdp-langs/intermediate.scrbl index 37fbd3c0e7..3f2b96991f 100644 --- a/collects/scribblings/htdp-langs/intermediate.scrbl +++ b/collects/scribblings/htdp-langs/intermediate.scrbl @@ -231,6 +231,6 @@ The same as Beginning's @|beg-check-expect|, etc.} Constants for the empty list, true, and false.} -@defform[(require string)]{ +@defform[(require module-path)]{ The same as Beginning's @|beg-require|.} diff --git a/collects/scribblings/reference/class.scrbl b/collects/scribblings/reference/class.scrbl index 8f50eacd4b..a64ce5728f 100644 --- a/collects/scribblings/reference/class.scrbl +++ b/collects/scribblings/reference/class.scrbl @@ -1494,7 +1494,7 @@ To customize the way that a class instance is compared to other instances by @scheme[equal?], implement the @scheme[equal<%>] interface. -@definterface[equal<%> ()]{} +@definterface[equal<%> ()]{ The @scheme[equal<%>] interface includes three methods, which are analogous to the functions provided for a structure type with @@ -1531,7 +1531,7 @@ classes whose most specific ancestor to explicitly implement See @scheme[prop:equal+hash] for more information on equality comparisons and hash codes. The @scheme[equal<%>] interface is -implemented with @scheme[interface*] and @scheme[prop:equal+hash]. +implemented with @scheme[interface*] and @scheme[prop:equal+hash].} @; ------------------------------------------------------------------------ @@ -1610,11 +1610,11 @@ Like @scheme[define-serializable-class*], but with not interface expressions (analogous to @scheme[class]).} -@definterface[externalizable<%> ()]{} +@definterface[externalizable<%> ()]{ The @scheme[externalizable<%>] interface includes only the @scheme[externalize] and @scheme[internalize] methods. See -@scheme[define-serializable-class*] for more information. +@scheme[define-serializable-class*] for more information.} @; ------------------------------------------------------------------------ diff --git a/collects/scribblings/reference/sandbox.scrbl b/collects/scribblings/reference/sandbox.scrbl index 34eb823c43..386a62df8d 100644 --- a/collects/scribblings/reference/sandbox.scrbl +++ b/collects/scribblings/reference/sandbox.scrbl @@ -478,7 +478,8 @@ specifications in @scheme[sandbox-path-permissions], and it uses @defparam[sandbox-path-permissions perms - (listof (list/c (or/c 'execute 'write 'delete 'read-bytecode 'read 'exists) + (listof (list/c (or/c 'execute 'write 'delete + 'read-bytecode 'read 'exists) (or/c byte-regexp? bytes? string? path?)))]{ A parameter that configures the behavior of the default sandbox diff --git a/collects/scribblings/scribble/basic.scrbl b/collects/scribblings/scribble/basic.scrbl index 2492ae3436..6a68027557 100644 --- a/collects/scribblings/scribble/basic.scrbl +++ b/collects/scribblings/scribble/basic.scrbl @@ -163,7 +163,9 @@ an element with style @scheme[#f].} @def-style-proc[subscript] @def-style-proc[superscript] -@def-elem-proc[smaller]{Like @scheme[elem], but with style @scheme["smaller"].} +@def-elem-proc[smaller]{Like @scheme[elem], but with style +@scheme["smaller"]. When uses of @scheme[smaller] are nested, text +gets progressively smaller.} @defproc[(hspace [n exact-nonnegative-integer?]) element?]{ diff --git a/collects/scribblings/scribble/manual.scrbl b/collects/scribblings/scribble/manual.scrbl index 9434c4999c..8fb1b956bb 100644 --- a/collects/scribblings/scribble/manual.scrbl +++ b/collects/scribblings/scribble/manual.scrbl @@ -613,6 +613,29 @@ typeset as with @scheme[scheme].} Like @scheme[schemegrammar], but for typesetting multiple productions at once, aligned around the @litchar{=} and @litchar{|}.} +@defproc[(defidentifier [id identifier?] + [#:form? form? any/c #f] + [#:index? index? any/c #t] + [#:show-libs? show-libs? any/c #t]) + element?]{ + +Typesets @scheme[id] as a Scheme identifier, and also establishes the +identifier as the definition of a binding in the same way as +@scheme[defproc], @scheme[defform], etc. As always, the library that +provides the identifier must be declared via @scheme[defmodule] or +@scheme[declare-exporting] for an enclosing section. + +If @scheme[form?] is a true value, then the identifier is documented +as a syntactic form, so that uses of the identifier (normally +including @scheme[id] itself) are typeset as a syntactic form. + +If @scheme[index?] is a true value, then the identifier is registered +in the index. + +If @scheme[show-libs?] is a true value, then the identifier's defining +module may be exposed in the typeset form (e.g., when viewing HTML and +the mouse hovers over the identifier).} + @; ------------------------------------------------------------------------ @section[#:tag "doc-classes"]{Documenting Classes and Interfaces} diff --git a/collects/teachpack/2htdp/scribblings/universe.scrbl b/collects/teachpack/2htdp/scribblings/universe.scrbl index a64bcff87f..b875e0a297 100644 --- a/collects/teachpack/2htdp/scribblings/universe.scrbl +++ b/collects/teachpack/2htdp/scribblings/universe.scrbl @@ -25,6 +25,8 @@ @author{Matthias Felleisen} +@defmodule[2htdp/universe #:use-sources (teachpack/htdp/image)] + @;{FIXME: the following paragraph uses `defterm' instead of `deftech', because the words "world" and "universe" are used as datatypes, and datatypes are currently linked as technical terms --- which is a hack. @@ -52,8 +54,6 @@ The purpose of this documentation is to give experienced Schemers and HtDP have a series of projects available as a small booklet on @link["http://world.cs.brown.edu/"]{How to Design Worlds}. -@declare-exporting[teachpack/2htdp/universe #:use-sources (teachpack/htdp/image)] - @; ----------------------------------------------------------------------------- @section[#:tag "basics"]{Basics}