commit 1617e8d8ae6299ba99cf6d18d41f1a35b9a934e1
parent 0d96872a1a5706712a33bb067fa4008dfa517eb5
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Mon, 16 Feb 2009 22:04:51 +0000
changed htdp languages to allow identifier module paths; scribble improvements to latex back-end; added definterface
svn: r13681
original commit: 9927b0b576063d2ee99a2089825098aa9a7e7781
Diffstat:
7 files changed, 101 insertions(+), 30 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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
@@ -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/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
@@ -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}