commit abc3822ad4db26a447257cf2adc3653e1ad0dec7
parent 73b8f12a0d694e6102fae143eaf887bc9eba58ca
Author: Eli Barzilay <eli@barzilay.org>
Date: Wed, 16 Feb 2011 14:01:08 -0500
Merge in the docs test into the rest of the scribble tests.
Also fixed it to scan all scrbl files in the docs directory, use
runtime-path, and change the rest to racket to get the quoted printout
right.
original commit: 0801525931be9e9542230091748d366a114cbeb9
Diffstat:
12 files changed, 97 insertions(+), 13 deletions(-)
diff --git a/collects/scribble/eval.rkt b/collects/scribble/eval.rkt
@@ -113,7 +113,7 @@
#f
(map (lambda (l)
(list (make-flow (list l))))
- flow-accum))))))))]
+ (reverse flow-accum)))))))))]
[(equal? #\newline v)
(loop #f #f (add-line (add-string string-accum line-accum)
flow-accum))]
diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt
@@ -468,7 +468,7 @@
(loop (cdr flows) (add1 n))]
[else n]))])
(unless (= cnt 1) (printf "\\multicolumn{~a}{l}{" cnt))
- (render-table-cell (car flows) part ri twidth (car cell-styles))
+ (render-table-cell (car flows) part ri (/ twidth cnt) (car cell-styles))
(unless (= cnt 1) (printf "}"))
(unless (null? (list-tail flows cnt)) (printf " &\n"))))
(unless (null? (cdr flows)) (loop (cdr flows)
diff --git a/collects/scribble/private/manual-code.rkt b/collects/scribble/private/manual-code.rkt
@@ -121,7 +121,7 @@
[else null]))]
[has-hash-lang? (regexp-match? #rx"^#lang " bstr)]
[language (if has-hash-lang?
- (let ([m (regexp-match #rx"^#lang ([-a-zA-Z/._+]+)" bstr)])
+ (let ([m (regexp-match #rx"^#lang ([-0-9a-zA-Z/._+]+)" bstr)])
(if m
(link-mod
#:orig? #t
diff --git a/collects/scribblings/scribble/manual.scrbl b/collects/scribblings/scribble/manual.scrbl
@@ -208,7 +208,7 @@ without insetting the code.}
@defform[(RACKETRESULTBLOCK0 datum ...)]
)]{
-Like @racketblock[racketblock], etc., but colors the typeset text as a
+Like @racket[racketblock], etc., but colors the typeset text as a
result (i.e., a single color with no hyperlinks) instead of code.}
@deftogether[(
diff --git a/collects/scribblings/scribble/srcdoc.scrbl b/collects/scribblings/scribble/srcdoc.scrbl
@@ -9,7 +9,7 @@
The @racketmodname[scribble/srcdoc] and
@racketmodname[scribble/extract] libraries support writing
-documentation withing the documentation code along with an export
+documentation within the documentation code along with an export
contract, similar to using @as-index{JavaDoc}. With this approach, a
single contract specification is used both for the run-time contract
and the documentation of an exported binding.
diff --git a/collects/tests/scribble/collect.rkt b/collects/tests/scribble/collect.rkt
@@ -1,4 +1,4 @@
-#lang scheme/base
+#lang racket/base
(require tests/eli-tester scribble/text/syntax-utils)
diff --git a/collects/tests/scribble/docs.rkt b/collects/tests/scribble/docs.rkt
@@ -0,0 +1,43 @@
+#lang racket/base
+
+;; Use text renderer to check some Scribble functionality
+
+(require scribble/base-render (prefix-in text: scribble/text-render)
+ racket/file racket/class racket/runtime-path tests/eli-tester)
+
+(define-runtime-path source-dir "docs")
+(define work-dir (build-path (find-system-path 'temp-dir)
+ "scribble-docs-tests"))
+
+(define (build-text-doc src-file dest-file)
+ (let* ([renderer (new (text:render-mixin render%) [dest-dir work-dir])]
+ [docs (list (dynamic-require src-file 'doc))]
+ [fns (list (build-path work-dir dest-file))]
+ [fp (send renderer traverse docs fns)]
+ [info (send renderer collect docs fns fp)]
+ [r-info (send renderer resolve docs fns info)])
+ (send renderer render docs fns r-info)))
+
+(define (check-text-build src-file expect-file)
+ (build-text-doc src-file "gen.txt")
+ (define (contents file) (regexp-replace #rx"\n+$" (file->string file) ""))
+ (string=? (contents expect-file) (contents (build-path work-dir "gen.txt"))))
+
+(provide docs-tests)
+(define (docs-tests)
+ (when (or (file-exists? work-dir) (directory-exists? work-dir))
+ (delete-directory/files work-dir))
+ (make-directory work-dir)
+ (dynamic-wind void
+ (lambda ()
+ (define files (map path-element->string (directory-list source-dir)))
+ (for ([scrbl (in-list files)]
+ #:when (regexp-match? #rx"\\.scrbl$" scrbl)
+ [txt (in-value (regexp-replace #rx"\\.scrbl$" scrbl ".txt"))]
+ #:when (member txt files))
+ ;; (printf "Testing ~s -> ~s\n" scrbl txt)
+ (test #:failure-message
+ (format "mismatch from: \"~a\" expected: \"~a\"" scrbl txt)
+ (check-text-build (build-path source-dir scrbl)
+ (build-path source-dir txt)))))
+ (lambda () (delete-directory/files work-dir))))
diff --git a/collects/tests/scribble/docs/print-lines.scrbl b/collects/tests/scribble/docs/print-lines.scrbl
@@ -0,0 +1,21 @@
+#lang scribble/manual
+
+@(require scribble/eval)
+
+@title{Pretty-Print-Handler Bug Example}
+
+@(define the-eval (make-base-eval))
+@(interaction-eval
+ #:eval the-eval
+ (begin
+ (require racket/pretty)
+ (current-print pretty-print-handler)))
+
+@examples[#:eval the-eval
+'((x "positional 1")
+ (rest ("positional 2" "positional 3"))
+ (a ())
+ (b ("b-arg"))
+ (c (("first c1" "second c1") ("first c2" "second c2")))
+ (d #f)
+ (e ()))]
diff --git a/collects/tests/scribble/docs/print-lines.txt b/collects/tests/scribble/docs/print-lines.txt
@@ -0,0 +1,18 @@
+
+Pretty-Print-Handler Bug Example
+
+Example:
+ > '((x "positional 1")
+ (rest ("positional 2" "positional 3"))
+ (a ())
+ (b ("b-arg"))
+ (c (("first c1" "second c1") ("first c2" "second c2")))
+ (d #f)
+ (e ()))
+ '((x "positional 1")
+ (rest ("positional 2" "positional 3"))
+ (a ())
+ (b ("b-arg"))
+ (c (("first c1" "second c1") ("first c2" "second c2")))
+ (d #f)
+ (e ()))
diff --git a/collects/tests/scribble/main.rkt b/collects/tests/scribble/main.rkt
@@ -1,7 +1,9 @@
-#lang scheme/base
+#lang racket/base
-(require tests/eli-tester "reader.ss" "preprocessor.ss" "collect.ss")
+(require tests/eli-tester
+ "reader.rkt" "preprocessor.rkt" "collect.rkt" "docs.rkt")
(test do (reader-tests)
do (begin/collect-tests)
- do (preprocessor-tests))
+ do (preprocessor-tests)
+ do (docs-tests))
diff --git a/collects/tests/scribble/preprocessor.rkt b/collects/tests/scribble/preprocessor.rkt
@@ -1,6 +1,6 @@
-#lang scheme/base
+#lang racket/base
-(require tests/eli-tester scheme/runtime-path scheme/port scheme/sandbox
+(require tests/eli-tester racket/runtime-path racket/port racket/sandbox
(prefix-in doc: (lib "scribblings/scribble/preprocessor.scrbl")))
(provide preprocessor-tests)
diff --git a/collects/tests/scribble/reader.rkt b/collects/tests/scribble/reader.rkt
@@ -1,6 +1,6 @@
-#lang scheme/base
+#lang racket/base
-(require tests/eli-tester (prefix-in scr: scribble/reader) scheme/list)
+(require tests/eli-tester (prefix-in scr: scribble/reader) racket/list)
(provide reader-tests)