Skip to content

Automated Resyntax fixes #507

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 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions scribble-lib/scribble/private/define-popup.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,12 @@
[found-open?
(cond
[(char=? char #\})
(regexp-replace
#rx"^[\n ]*"
(regexp-replace
#rx"[\n ]*$"
(apply string (reverse chars))
"")
"")]
[else
(loop (+ pos 1) #t (cons char chars))])]
[else
(cond
[(char=? char #\{)
(loop (+ pos 1) #t '())]
[else
(loop (+ pos 1) #f '())])])]
(regexp-replace #rx"^[\n ]*"
(regexp-replace #rx"[\n ]*$" (apply string (reverse chars)) "")
"")]
[else (loop (+ pos 1) #t (cons char chars))])]
[(char=? char #\{) (loop (+ pos 1) #t '())]
[else (loop (+ pos 1) #f '())])]
[else #f])))

(define define-popup
Expand Down
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
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
48 changes: 23 additions & 25 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
68 changes: 31 additions & 37 deletions scribble-lib/scribble/private/manual-vars.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

(define-struct (box-splice splice) ())

(provide/contract
[struct (box-splice splice) ([run list?])]) ; XXX ugly copying
(provide (contract-out (struct (box-splice splice) ([run list?])))) ; XXX ugly copying
(provide deftogether *deftogether
with-racket-variables
with-togetherable-racket-variables
Expand Down Expand Up @@ -172,47 +171,42 @@
(list
(make-table
boxed-style
(map
(lambda (box)
(unless (and (box-splice? box)
(= 1 (length (splice-run box)))
(nested-flow? (car (splice-run box)))
(eq? vertical-inset-style (nested-flow-style (car (splice-run box))))
(let ([l (nested-flow-blocks (car (splice-run box)))])
(= 1 (length l))
(table? (car l))
(eq? boxed-style (table-style (car l)))))
(error 'deftogether
"element is not a boxing splice containing a single nested-flow with a single table: ~e"
box))
(list (make-flow (list (make-table
"together"
(table-flowss (car (nested-flow-blocks (car (splice-run box))))))))))
boxes))))
(for/list ([box (in-list boxes)])
(unless (and (box-splice? box)
(= 1 (length (splice-run box)))
(nested-flow? (car (splice-run box)))
(eq? vertical-inset-style (nested-flow-style (car (splice-run box))))
(let ([l (nested-flow-blocks (car (splice-run box)))])
(= 1 (length l))
(table? (car l))
(eq? boxed-style (table-style (car l)))))
(error
'deftogether
"element is not a boxing splice containing a single nested-flow with a single table: ~e"
box))
(list (make-flow (list (make-table "together"
(table-flowss (car (nested-flow-blocks
(car (splice-run box)))))))))))))
(body-thunk))))

(define-syntax (deftogether stx)
(syntax-parse stx
[(_ (def ...+) . body)
(with-syntax ([((_ (lit ...) (var ...) decl) ...)
(map (lambda (def)
(define exp-def
(local-expand
def
(list (make-deftogether-tag))
(cons
#'with-togetherable-racket-variables*
(kernel-form-identifier-list))))
(syntax-case exp-def (with-togetherable-racket-variables*)
[(with-togetherable-racket-variables* lits vars decl)
exp-def]
[_
(raise-syntax-error
#f
"sub-form is not a documentation form that can be combined"
stx
def)]))
(syntax->list #'(def ...)))])
(for/list ([def (in-list (syntax->list #'(def ...)))])
(define exp-def
(local-expand def
(list (make-deftogether-tag))
(cons #'with-togetherable-racket-variables*
(kernel-form-identifier-list))))
(syntax-case exp-def (with-togetherable-racket-variables*)
[(with-togetherable-racket-variables* lits vars decl) exp-def]
[_
(raise-syntax-error
#f
"sub-form is not a documentation form that can be combined"
stx
def)]))])
#'(with-togetherable-racket-variables
(lit ... ...)
(var ... ...)
Expand Down
Loading