Skip to content

Automated Resyntax fixes #502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
31 changes: 12 additions & 19 deletions scribble-lib/scribble/private/doc-begin.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,15 @@
#'(check-pre-part s (quote-syntax loc))))]))

(define (check-pre-part v loc-stx)
(if (pre-part? v)
v
(error
(format
"~a: not valid in document body (need a pre-part for decode) in: ~e"
(cond
[(and (syntax-source loc-stx)
(syntax-line loc-stx))
(format "~a:~a:~a"
(syntax-source loc-stx)
(syntax-line loc-stx)
(syntax-column loc-stx))]
[(and (syntax-source loc-stx)
(syntax-position loc-stx))
(format "~a:::~a"
(syntax-source loc-stx)
(syntax-position loc-stx))]
[else 'document])
v))))
(unless (pre-part? v)
(error
(format
"~a: not valid in document body (need a pre-part for decode) in: ~e"
(cond
[(and (syntax-source loc-stx) (syntax-line loc-stx))
(format "~a:~a:~a" (syntax-source loc-stx) (syntax-line loc-stx) (syntax-column loc-stx))]
[(and (syntax-source loc-stx) (syntax-position loc-stx))
(format "~a:::~a" (syntax-source loc-stx) (syntax-position loc-stx))]
[else 'document])
v)))
v)
13 changes: 4 additions & 9 deletions scribble-lib/scribble/private/indirect-renderer.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@
(define/override (get-suffix) target-suffix)
(define/override (render srcs dests ri)
(define tmp-dir
(make-temporary-file
(format "scribble-~a-to-~a-~~a"
(dotless base-suffix) (dotless target-suffix))
'directory))
(make-temporary-directory
(format "scribble-~a-to-~a-~~a" (dotless base-suffix) (dotless target-suffix))))
(define (cleanup)
(when (directory-exists? tmp-dir) (delete-directory/files tmp-dir)))
(with-handlers ([void (lambda (e) (cleanup) (raise e))])
(define tmp-dests
(map (lambda (dest)
(build-path tmp-dir
(path-replace-suffix (file-name-from-path dest)
base-suffix)))
dests))
(for/list ([dest (in-list dests)])
(build-path tmp-dir (path-replace-suffix (file-name-from-path dest) base-suffix))))
(set! tmp-dest-dir tmp-dir)
;; it would be better if it's ok to change current-directory for this
(super render srcs tmp-dests ri)
Expand Down
43 changes: 23 additions & 20 deletions scribble-lib/scribble/private/manual-bib.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@

(define-struct a-bib-entry (key val))

(provide/contract
[cite ((string?) () #:rest (listof string?) . ->* . element?)]
[bib-entry ((#:key string? #:title (or/c #f pre-content?))
(#:is-book? boolean? #:author (or/c #f pre-content?)
#:location (or/c #f pre-content?)
#:date (or/c #f pre-content?)
#:url (or/c #f pre-content?)
#:note (or/c #f pre-content?))
. ->* .
a-bib-entry?)]
[rename a-bib-entry? bib-entry? predicate/c]
[bibliography (() (#:tag string?) #:rest (listof a-bib-entry?) . ->* . part?)])
(provide (contract-out
[cite ((string?) () #:rest (listof string?) . ->* . element?)]
[bib-entry
((#:key string? #:title (or/c #f pre-content?)) (#:is-book? boolean?
#:author (or/c #f pre-content?)
#:location (or/c #f pre-content?)
#:date (or/c #f pre-content?)
#:url (or/c #f pre-content?)
#:note (or/c #f pre-content?))
. ->* .
a-bib-entry?)]
(rename a-bib-entry?
bib-entry?
predicate/c)
[bibliography (() (#:tag string?) #:rest (listof a-bib-entry?) . ->* . part?)]))

(define (cite key . keys)
(make-element
Expand Down Expand Up @@ -65,7 +68,9 @@
`(" " ,@(decode-content (list location)) ,(if date "," "."))
null)
(if date `(" " ,@(decode-content (list date)) ".") null)
(if url `(" " ,(link url (tt url))) null)
(if url (list " "
(link url
(tt url))) null)
(if note (decode-content (list note)) null)))))

(define-on-demand bib-style (make-style "RBibliography" scheme-properties))
Expand All @@ -81,12 +86,10 @@
(list
(make-table
bib-style
(map (lambda (c)
(define key (a-bib-entry-key c))
(define val (a-bib-entry-val c))
(list
(to-flow (make-target-element #f `("[" ,key "]") `(cite ,key)))
(for/list ([c (in-list citations)])
(define key (a-bib-entry-key c))
(define val (a-bib-entry-val c))
(list (to-flow (make-target-element #f `("[" ,key "]") `(cite ,key)))
flow-spacer
(to-flow val)))
citations))))
(to-flow val))))))
null))
21 changes: 9 additions & 12 deletions scribble-lib/scribble/private/manual-mod.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,9 @@
pkg-spec))))
libs-specs))
(append (if link-target?
(map (lambda (modpath)
(make-part-tag-decl
(intern-taglet
`(mod-path ,(datum-intern-literal
(element->string modpath))))))
modpaths)
(for/list ([modpath (in-list modpaths)])
(make-part-tag-decl (intern-taglet `(mod-path ,(datum-intern-literal
(element->string modpath))))))
null)
(flow-paragraphs (decode-flow content)))))))

Expand Down Expand Up @@ -334,12 +331,12 @@
#'(list pkg ...)
#'#f)])
(let ([libs (syntax->list #'(lib ... plib ...))])
(for ([l libs])
(unless (or (syntax-case l (unquote)
[(unquote _) #t]
[_ #f])
(module-path? (syntax->datum l)))
(raise-syntax-error #f "not a module path" stx l)))
(for ([l libs]
#:unless (or (syntax-case l (unquote)
[(unquote _) #t]
[_ #f])
(module-path? (syntax->datum l))))
(raise-syntax-error #f "not a module path" stx l))
(when (null? libs)
(raise-syntax-error #f "need at least one module path" stx))
#'(*declare-exporting `(lib ...) `(plib ...) packages)))]))
Expand Down
94 changes: 44 additions & 50 deletions scribble-lib/scribble/private/manual-proc.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -857,42 +857,38 @@
(make-just-context (car name)
(car (syntax-e stx-id)))
stx-id)])
(if link?
(let ()
(define (gen defn?)
((if defn? annote-exporting-library values)
(to-element #:defn? defn? name-id)))
(define content (gen #t))
(define ref-content (gen #f))
(make-target-element*
(lambda (s c t)
(make-toc-target2-element s c t ref-content))
(if (pair? name)
(car (syntax-e stx-id))
stx-id)
content
(let ([name (if (pair? name) (car name) name)])
(list* (list 'info name)
(list 'type 'struct: name)
(list 'predicate name '?)
(append
(if cname-id
(list (list 'constructor (syntax-e cname-id)))
null)
(map (lambda (f)
(list 'accessor name '-
(field-name f)))
fields)
(filter-map
(lambda (f)
(and (or (not immutable?)
(and (pair? (car f))
(memq '#:mutable
(car f))))
(list 'mutator 'set- name '-
(field-name f) '!)))
fields))))))
(to-element #:defn? #t name-id)))])
(cond
[link?
(define (gen defn?)
((if defn? annote-exporting-library values) (to-element #:defn? defn?
name-id)))
(define content (gen #t))
(define ref-content (gen #f))
(make-target-element*
(lambda (s c t) (make-toc-target2-element s c t ref-content))
(if (pair? name)
(car (syntax-e stx-id))
stx-id)
content
(let ([name (if (pair? name)
(car name)
name)])
(list* (list 'info name)
(list 'type 'struct: name)
(list 'predicate name '?)
(append
(if cname-id
(list (list 'constructor (syntax-e cname-id)))
null)
(map (lambda (f) (list 'accessor name '- (field-name f)))
fields)
(filter-map
(lambda (f)
(and (or (not immutable?)
(and (pair? (car f)) (memq '#:mutable (car f))))
(list 'mutator 'set- name '- (field-name f) '!)))
fields)))))]
[else (to-element #:defn? #t name-id)]))])
(if (pair? name)
(make-element
#f
Expand All @@ -913,27 +909,25 @@
(map sym-length
(append (if (pair? name) name (list name))
(map field-name fields)))
(map (lambda (f)
(match (car f)
[(? symbol?) 0]
[(list name) 2] ;; the extra [ ]
[(list* name field-opts)
;; '[' ']'
(apply + 2
(for/list ([field-opt (in-list field-opts)])
;; and " #:"
(+ 3 (string-length (keyword->string field-opt)))))]))
fields)))])
(for/list ([f (in-list fields)])
(match (car f)
[(? symbol?) 0]
[(list name) 2] ;; the extra [ ]
[(list* name field-opts)
;; '[' ']'
(apply +
2
(for/list ([field-opt (in-list field-opts)])
;; and " #:"
(+ 3 (string-length (keyword->string field-opt)))))]))))])
(cond
[(and (short-width . < . max-proto-width)
(not keyword-modifiers?))
;; All on one line:
(make-omitable-paragraph
(list
(to-element
`(,(racket struct)
,the-name
,(map field-view fields)))))]
(list (racket struct) the-name (map field-view fields)))))]
[else
;; Multi-line view (leaving out last paren if keywords follow):
(define one-right-column?
Expand Down
57 changes: 27 additions & 30 deletions scribble-lib/scribble/private/manual-style.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
itemize
aux-elem
code-inset)
(provide/contract [filebox (((or/c core:element? string?)) () #:rest (listof pre-flow?) . ->* . block?)])
(provide (contract-out
[filebox (((or/c core:element? string?)) () #:rest (listof pre-flow?) . ->* . block?)]))

(define styling-f/c
(() () #:rest (listof pre-content?) . ->* . element?))
(-> pre-content? ... element?))
(define-syntax-rule (provide-styling id ...)
(provide/contract [id styling-f/c] ...))
(provide-styling racketmodfont racketoutput
Expand Down Expand Up @@ -53,35 +54,32 @@

(provide void-const
undefined-const)
(provide/contract
[PLaneT element?]
[hash-lang (-> element?)]
[etc element?]
[inset-flow (() () #:rest (listof pre-content?) . ->* . nested-flow?)]
[litchar (() () #:rest (listof string?) . ->* . element?)]
[t (() () #:rest (listof pre-content?) . ->* . paragraph?)]
[exec (() () #:rest (listof content?) . ->* . element?)]
[commandline (() () #:rest (listof content?) . ->* . paragraph?)]
[menuitem (string? string? . -> . element?)])
(provide (contract-out [PLaneT element?]
[hash-lang (-> element?)]
[etc element?]
[inset-flow (() () #:rest (listof pre-content?) . ->* . nested-flow?)]
[litchar (() () #:rest (listof string?) . ->* . element?)]
[t (() () #:rest (listof pre-content?) . ->* . paragraph?)]
[exec (() () #:rest (listof content?) . ->* . element?)]
[commandline (() () #:rest (listof content?) . ->* . paragraph?)]
[menuitem (string? string? . -> . element?)]))

(define PLaneT (make-element "planetName" '("PLaneT")))

(define etc (make-element #f (list "etc" ._)))

(define (litchar . strs)
(let ([s (string-append* (map (lambda (s) (regexp-replace* "\n" s " "))
strs))])
(cond
[(regexp-match? #rx"^ *$" s) (make-element input-background-color (list (hspace (string-length s))))]
[else
(define ^spaces (car (regexp-match-positions #rx"^ *" s)))
(define $spaces (car (regexp-match-positions #rx" *$" s)))
(make-element
input-background-color
(list (hspace (cdr ^spaces))
(make-element input-color
(list (substring s (cdr ^spaces) (car $spaces))))
(hspace (- (cdr $spaces) (car $spaces)))))])))
(define s (string-append* (map (lambda (s) (regexp-replace* "\n" s " ")) strs)))
(cond
[(regexp-match? #rx"^ *$" s)
(make-element input-background-color (list (hspace (string-length s))))]
[else
(define ^spaces (car (regexp-match-positions #rx"^ *" s)))
(define $spaces (car (regexp-match-positions #rx" *$" s)))
(make-element input-background-color
(list (hspace (cdr ^spaces))
(make-element input-color (list (substring s (cdr ^spaces) (car $spaces))))
(hspace (- (cdr $spaces) (car $spaces)))))]))

(define (onscreen . str)
(make-element 'sf (decode-content str)))
Expand Down Expand Up @@ -173,11 +171,10 @@
(make-blockquote code-inset-style (list b)))

(define (commandline . s)
(make-paragraph (cons (hspace 2) (map (lambda (s)
(if (string? s)
(make-element 'tt (list s))
s))
s))))
(make-paragraph (cons (hspace 2) (for/list ([s (in-list s)])
(if (string? s)
(make-element 'tt (list s))
s)))))

(define (pidefterm . s)
(define c (apply defterm s))
Expand Down
Loading