a start on getting text rendering running automatically via 'raco setup'
This commit is contained in:
parent
2d8f41bfb9
commit
6b5cd10670
|
@ -67,7 +67,7 @@
|
||||||
worker-count ; number of cores to use to create documentation
|
worker-count ; number of cores to use to create documentation
|
||||||
program-name ; name of program that calls setup-scribblings
|
program-name ; name of program that calls setup-scribblings
|
||||||
only-dirs ; limits doc builds
|
only-dirs ; limits doc builds
|
||||||
latex-dest ; if not #f, generate Latex output
|
latex-dest ; #f => html, 'text => text, otherwise Latex output
|
||||||
auto-start-doc? ; if #t, expands `only-dir' with [user-]start to
|
auto-start-doc? ; if #t, expands `only-dir' with [user-]start to
|
||||||
; catch new docs
|
; catch new docs
|
||||||
make-user? ; are we making user stuff?
|
make-user? ; are we making user stuff?
|
||||||
|
@ -383,8 +383,39 @@
|
||||||
(for ([i infos] #:when (info-need-in-write? i)) (write-in/info latex-dest i))))
|
(for ([i infos] #:when (info-need-in-write? i)) (write-in/info latex-dest i))))
|
||||||
|
|
||||||
(define (make-renderer latex-dest doc)
|
(define (make-renderer latex-dest doc)
|
||||||
(if latex-dest
|
(cond
|
||||||
(new (latex:render-mixin render%)
|
[(not latex-dest)
|
||||||
|
(let* ([flags (doc-flags doc)]
|
||||||
|
[multi? (memq 'multi-page flags)]
|
||||||
|
[main? (doc-under-main? doc)]
|
||||||
|
[ddir (doc-dest-dir doc)]
|
||||||
|
[root? (or (memq 'main-doc-root flags)
|
||||||
|
(memq 'user-doc-root flags))])
|
||||||
|
(new ((if multi? html:render-multi-mixin values)
|
||||||
|
(html:render-mixin render%))
|
||||||
|
[dest-dir (if multi?
|
||||||
|
(let-values ([(base name dir?) (split-path ddir)]) base)
|
||||||
|
ddir)]
|
||||||
|
[alt-paths (if main?
|
||||||
|
(let ([std-path (lambda (s)
|
||||||
|
(cons (collection-file-path s "scribble")
|
||||||
|
(format "../~a" s)))])
|
||||||
|
(list (std-path "scribble.css")
|
||||||
|
(std-path "scribble-style.css")
|
||||||
|
(std-path "racket.css")
|
||||||
|
(std-path "scribble-common.js")))
|
||||||
|
null)]
|
||||||
|
;; For main-directory, non-start files, up-path is #t, which makes the
|
||||||
|
;; "up" link go to the (user's) start page using cookies. For other files,
|
||||||
|
;;
|
||||||
|
[up-path (and (not root?)
|
||||||
|
(if main?
|
||||||
|
#t
|
||||||
|
(build-path (find-user-doc-dir) "index.html")))]
|
||||||
|
[search-box? #t]))]
|
||||||
|
[(eq? latex-dest 'text) 'not-a-renderer]
|
||||||
|
[(path? latex-dest)
|
||||||
|
(new (latex:render-mixin render%)
|
||||||
[dest-dir latex-dest]
|
[dest-dir latex-dest]
|
||||||
;; Use PLT manual style:
|
;; Use PLT manual style:
|
||||||
[prefix-file (collection-file-path "manual-prefix.tex" "scribble")]
|
[prefix-file (collection-file-path "manual-prefix.tex" "scribble")]
|
||||||
|
@ -393,45 +424,23 @@
|
||||||
;; generated/copied file names to keep them separate:
|
;; generated/copied file names to keep them separate:
|
||||||
[helper-file-prefix (let-values ([(base name dir?) (split-path
|
[helper-file-prefix (let-values ([(base name dir?) (split-path
|
||||||
(doc-dest-dir doc))])
|
(doc-dest-dir doc))])
|
||||||
(path-element->string name))])
|
(path-element->string name))])]))
|
||||||
(let* ([flags (doc-flags doc)]
|
|
||||||
[multi? (memq 'multi-page flags)]
|
|
||||||
[main? (doc-under-main? doc)]
|
|
||||||
[ddir (doc-dest-dir doc)]
|
|
||||||
[root? (or (memq 'main-doc-root flags)
|
|
||||||
(memq 'user-doc-root flags))])
|
|
||||||
(new ((if multi? html:render-multi-mixin values)
|
|
||||||
(html:render-mixin render%))
|
|
||||||
[dest-dir (if multi?
|
|
||||||
(let-values ([(base name dir?) (split-path ddir)]) base)
|
|
||||||
ddir)]
|
|
||||||
[alt-paths (if main?
|
|
||||||
(let ([std-path (lambda (s)
|
|
||||||
(cons (collection-file-path s "scribble")
|
|
||||||
(format "../~a" s)))])
|
|
||||||
(list (std-path "scribble.css")
|
|
||||||
(std-path "scribble-style.css")
|
|
||||||
(std-path "racket.css")
|
|
||||||
(std-path "scribble-common.js")))
|
|
||||||
null)]
|
|
||||||
;; For main-directory, non-start files, up-path is #t, which makes the
|
|
||||||
;; "up" link go to the (user's) start page using cookies. For other files,
|
|
||||||
;;
|
|
||||||
[up-path (and (not root?)
|
|
||||||
(if main?
|
|
||||||
#t
|
|
||||||
(build-path (find-user-doc-dir) "index.html")))]
|
|
||||||
[search-box? #t]))))
|
|
||||||
|
|
||||||
(define (pick-dest latex-dest doc)
|
(define (pick-dest latex-dest doc)
|
||||||
(cond [latex-dest
|
(cond [(eq? latex-dest 'text) (build-path (doc-dest-dir doc) "doc.txt")]
|
||||||
|
[latex-dest
|
||||||
(let-values ([(base name dir?) (split-path (doc-src-file doc))])
|
(let-values ([(base name dir?) (split-path (doc-src-file doc))])
|
||||||
(build-path latex-dest (path-replace-suffix name #".tex")))]
|
(build-path latex-dest (path-replace-suffix name #".tex")))]
|
||||||
[(memq 'multi-page (doc-flags doc)) (doc-dest-dir doc)]
|
[else
|
||||||
[else (build-path (doc-dest-dir doc) "index.html")]))
|
(cond
|
||||||
|
[(memq 'multi-page (doc-flags doc)) (doc-dest-dir doc)]
|
||||||
|
[else (build-path (doc-dest-dir doc) "index.html")])]))
|
||||||
|
|
||||||
(define (sxref-path latex-dest doc file)
|
(define (sxref-path latex-dest doc file)
|
||||||
(cond [latex-dest
|
(cond [(eq? latex-dest 'text)
|
||||||
|
;; can this be the same as the last case?
|
||||||
|
(build-path (doc-dest-dir doc) "txt" file)]
|
||||||
|
[latex-dest
|
||||||
(let-values ([(base name dir?) (split-path (doc-src-file doc))])
|
(let-values ([(base name dir?) (split-path (doc-src-file doc))])
|
||||||
(build-path latex-dest (path-replace-suffix name (string-append "." file))))]
|
(build-path latex-dest (path-replace-suffix name (string-append "." file))))]
|
||||||
[else (build-path (doc-dest-dir doc) file)]))
|
[else (build-path (doc-dest-dir doc) file)]))
|
||||||
|
@ -510,7 +519,7 @@
|
||||||
(let* ([info-out-file (sxref-path latex-dest doc "out.sxref")]
|
(let* ([info-out-file (sxref-path latex-dest doc "out.sxref")]
|
||||||
[info-in-file (sxref-path latex-dest doc "in.sxref")]
|
[info-in-file (sxref-path latex-dest doc "in.sxref")]
|
||||||
[stamp-file (sxref-path latex-dest doc "stamp.sxref")]
|
[stamp-file (sxref-path latex-dest doc "stamp.sxref")]
|
||||||
[out-file (build-path (doc-dest-dir doc) "index.html")]
|
[out-file (build-path (doc-dest-dir doc) "index.html")] ;; this is suspicious: what if we are building .pdfs?
|
||||||
[src-zo (let-values ([(base name dir?) (split-path (doc-src-file doc))])
|
[src-zo (let-values ([(base name dir?) (split-path (doc-src-file doc))])
|
||||||
(build-path base "compiled" (path-add-suffix name ".zo")))]
|
(build-path base "compiled" (path-add-suffix name ".zo")))]
|
||||||
[renderer (make-renderer latex-dest doc)]
|
[renderer (make-renderer latex-dest doc)]
|
||||||
|
@ -526,9 +535,10 @@
|
||||||
[renderer-path (build-path (collection-path "scribble")
|
[renderer-path (build-path (collection-path "scribble")
|
||||||
"compiled"
|
"compiled"
|
||||||
(path-add-suffix
|
(path-add-suffix
|
||||||
(if latex-dest
|
(cond
|
||||||
"latex-render.rkt"
|
[(eq? latex-dest 'text) "text-render.rkt"]
|
||||||
"html-render.rkt")
|
[latex-dest "latex-render.rkt"]
|
||||||
|
[else "html-render.rkt"])
|
||||||
".zo"))]
|
".zo"))]
|
||||||
[css-path (collection-file-path "scribble.css" "scribble")]
|
[css-path (collection-file-path "scribble.css" "scribble")]
|
||||||
[aux-time (max (file-or-directory-modify-seconds/stamp
|
[aux-time (max (file-or-directory-modify-seconds/stamp
|
||||||
|
@ -559,6 +569,7 @@
|
||||||
;; it runs some documents without rendering them:
|
;; it runs some documents without rendering them:
|
||||||
(info-time . >= . src-time)))]
|
(info-time . >= . src-time)))]
|
||||||
[can-run? (and (or (not latex-dest)
|
[can-run? (and (or (not latex-dest)
|
||||||
|
(eq? latex-dest 'text)
|
||||||
(not (omit? (doc-category doc))))
|
(not (omit? (doc-category doc))))
|
||||||
(or can-run?
|
(or can-run?
|
||||||
(and auto-main?
|
(and auto-main?
|
||||||
|
@ -727,7 +738,8 @@
|
||||||
|
|
||||||
(define (build-again! latex-dest info with-record-error)
|
(define (build-again! latex-dest info with-record-error)
|
||||||
(define (cleanup-dest-dir doc)
|
(define (cleanup-dest-dir doc)
|
||||||
(unless latex-dest
|
(when (or (not latex-dest)
|
||||||
|
(eq? latex-dest 'text))
|
||||||
(let ([dir (doc-dest-dir doc)])
|
(let ([dir (doc-dest-dir doc)])
|
||||||
(if (not (directory-exists? dir))
|
(if (not (directory-exists? dir))
|
||||||
(make-directory*/ignore-exists-exn dir)
|
(make-directory*/ignore-exists-exn dir)
|
||||||
|
|
|
@ -991,8 +991,11 @@
|
||||||
(with-handlers ([exn:fail?
|
(with-handlers ([exn:fail?
|
||||||
(lambda (exn)
|
(lambda (exn)
|
||||||
(setup-printf #f "docs failure: ~a" (exn->string exn)))])
|
(setup-printf #f "docs failure: ~a" (exn->string exn)))])
|
||||||
(doc:setup-scribblings #f (and (not (null? (archives)))
|
(define auto-start-doc?
|
||||||
(archive-implies-reindex)))))
|
(and (not (null? (archives)))
|
||||||
|
(archive-implies-reindex)))
|
||||||
|
(doc:setup-scribblings #f auto-start-doc?)
|
||||||
|
(doc:setup-scribblings 'text auto-start-doc?)))
|
||||||
|
|
||||||
(define (doc-pdf-dest-step)
|
(define (doc-pdf-dest-step)
|
||||||
(setup-printf #f "--- building PDF documentation (via pdflatex) ---")
|
(setup-printf #f "--- building PDF documentation (via pdflatex) ---")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user