Skip to content

Commit

Permalink
Automated Resyntax fixes
Browse files Browse the repository at this point in the history
This is an automated change generated by Resyntax.

#### Pass 1

Applied 1 fix to [`scribble-lib/scribble/doclang2.rkt`](../blob/HEAD/scribble-lib/scribble/doclang2.rkt)

  * Line 6, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.

Applied 1 fix to [`scribble-lib/scribble/valid-blueboxes-info.rkt`](../blob/HEAD/scribble-lib/scribble/valid-blueboxes-info.rkt)

  * Line 5, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.

Applied 3 fixes to [`scribble-lib/scribble/render.rkt`](../blob/HEAD/scribble-lib/scribble/render.rkt)

  * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.
  * Line 11, `provide/contract-to-contract-out`: The `provide/contract` form is a legacy form made obsolete by `contract-out`.
  * Line 54, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.

Applied 1 fix to [`scribble-lib/scribble/pdf-render.rkt`](../blob/HEAD/scribble-lib/scribble/pdf-render.rkt)

  * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.

Applied 1 fix to [`scribble-lib/scribble/latex-properties.rkt`](../blob/HEAD/scribble-lib/scribble/latex-properties.rkt)

  * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.

Applied 1 fix to [`scribble-lib/scribble/comment-reader.rkt`](../blob/HEAD/scribble-lib/scribble/comment-reader.rkt)

  * Line 36, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.

Applied 4 fixes to [`scribble-lib/scribble/racket.rkt`](../blob/HEAD/scribble-lib/scribble/racket.rkt)

  * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.
  * Line 477, `if-else-false-to-and`: This `if` expression can be refactored to an equivalent expression using `and`.
  * Line 507, `map-to-for`: This `map` operation can be replaced with a `for/list` loop.
  * Line 740, `if-x-else-x-to-and`: This conditional expression can be replaced with a simpler, equivalent expression.

Applied 7 fixes to [`scribble-lib/scribble/struct.rkt`](../blob/HEAD/scribble-lib/scribble/struct.rkt)

  * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.
  * Line 50, `map-to-for`: This `map` operation can be replaced with a `for/list` loop.
  * Line 217, `map-to-for`: This `map` operation can be replaced with a `for/list` loop.
  * Line 230, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 372, `andmap-to-for/and`: This `andmap` operation can be replaced with a `for/and` loop.
  * Line 387, `if-let-to-cond`: `cond` with internal definitions is preferred over `if` with `let`, to reduce nesting
  * Line 417, `cond-let-to-cond-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.

Applied 1 fix to [`scribble-lib/scribble/doclang.rkt`](../blob/HEAD/scribble-lib/scribble/doclang.rkt)

  * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.

## Summary

Fixed 20 issues in 9 files.

  * Fixed 8 occurrences of `tidy-require`
  * Fixed 3 occurrences of `let-to-define`
  * Fixed 3 occurrences of `map-to-for`
  * Fixed 1 occurrence of `provide/contract-to-contract-out`
  * Fixed 1 occurrence of `if-else-false-to-and`
  * Fixed 1 occurrence of `if-x-else-x-to-and`
  * Fixed 1 occurrence of `andmap-to-for/and`
  * Fixed 1 occurrence of `if-let-to-cond`
  * Fixed 1 occurrence of `cond-let-to-cond-define`
  • Loading branch information
resyntax-ci[bot] authored and mflatt committed Oct 30, 2024
1 parent c02b8f8 commit bdaa06a
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 160 deletions.
6 changes: 3 additions & 3 deletions scribble-lib/scribble/comment-reader.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
[(char port)
(do-comment port (lambda () (read/recursive port #\@)))]
[(char port src line col pos)
(let ([v (do-comment port (lambda () (read-syntax/recursive src port #\@)))])
(define-values (eline ecol epos) (port-next-location port))
(datum->syntax #f v (list src line col pos (and pos epos (- epos pos)))))])))
(define v (do-comment port (lambda () (read-syntax/recursive src port #\@))))
(define-values (eline ecol epos) (port-next-location port))
(datum->syntax #f v (list src line col pos (and pos epos (- epos pos))))])))

(define (do-comment port recur)
(let loop ()
Expand Down
4 changes: 2 additions & 2 deletions scribble-lib/scribble/doclang.rkt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#lang racket/base
(require "private/doc-begin.rkt"
(for-syntax racket/base))
(require (for-syntax racket/base)
"private/doc-begin.rkt")

(provide (except-out (all-from-out racket/base) #%module-begin)
(rename-out [*module-begin #%module-begin]))
Expand Down
6 changes: 3 additions & 3 deletions scribble-lib/scribble/doclang2.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
;; A slightly nicer version of doclang where the parameters are keyword-based
;; rather than positional.

(require "private/doc-begin.rkt"
(for-syntax racket/base
syntax/parse))
(require (for-syntax racket/base
syntax/parse)
"private/doc-begin.rkt")

(provide (except-out (all-from-out racket/base) #%module-begin)
(rename-out [*module-begin #%module-begin]))
Expand Down
4 changes: 2 additions & 2 deletions scribble-lib/scribble/latex-properties.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#lang racket/base
(require "private/provide-structs.rkt"
(require racket/contract/base
racket/serialize
racket/contract/base)
"private/provide-structs.rkt")

(provide-structs
[tex-addition ([path (or/c path-string? (cons/c 'collects (listof bytes?)) bytes?)])]
Expand Down
5 changes: 3 additions & 2 deletions scribble-lib/scribble/pdf-render.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#lang racket/base

(require "private/indirect-renderer.rkt" "private/run-pdflatex.rkt"
(prefix-in latex: "latex-render.rkt"))
(require (prefix-in latex: "latex-render.rkt")
"private/indirect-renderer.rkt"
"private/run-pdflatex.rkt")

(provide render-mixin
dvi-render-mixin
Expand Down
42 changes: 21 additions & 21 deletions scribble-lib/scribble/racket.rkt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#lang racket/base

(require "core.rkt"
(require (for-syntax racket/base)
file/convertible
racket/extflonum
"basic.rkt"
"search.rkt"
"core.rkt"
"html-properties.rkt"
"private/manual-sprop.rkt"
"private/on-demand.rkt"
"html-properties.rkt"
file/convertible
racket/extflonum
(for-syntax racket/base))
"search.rkt")

(provide define-code
to-element
Expand Down Expand Up @@ -474,7 +474,7 @@
a
(let ([val? (positive? quote-depth)])
(make-sized-element
(if val? value-color #f)
(and val? value-color)
(list
(make-element/cache (if val? value-color paren-color) '". ")
(typeset a #f "" "" "" (not val?) expr? escapes? defn? elem-wrap)
Expand Down Expand Up @@ -504,12 +504,11 @@
(out 'nbsp comment-color)
(define v (syntax->datum (cadr (syntax->list c))))
(if (paragraph? v)
(map (lambda (v)
(let ([v (no-fancy-chars v)])
(if (or (string? v) (symbol? v))
(out v comment-color)
(out v #f))))
(paragraph-content v))
(for/list ([v (in-list (paragraph-content v))])
(let ([v (no-fancy-chars v)])
(if (or (string? v) (symbol? v))
(out v comment-color)
(out v #f))))
(out (no-fancy-chars v) comment-color))]

#; {Syntax Init-line! Srcless-step String String -> Contract}
Expand Down Expand Up @@ -737,14 +736,15 @@
(syntax-column (cadr l)))
(and (syntax-column c)
(+ (syntax-column c) (syntax-span c))))])
(if end
(datum->syntax #f
(syntax-e key)
(vector #f (syntax-line key)
(syntax-column key)
(syntax-position key)
(max 1 (- end 1 (syntax-column key)))))
end))
(and end
(datum->syntax
#f
(syntax-e key)
(vector #f
(syntax-line key)
(syntax-column key)
(syntax-position key)
(max 1 (- end 1 (syntax-column key)))))))
(cdr l)))]
[(struct-proxy? (syntax-e c))
(struct-proxy-content (syntax-e c))]
Expand Down
144 changes: 71 additions & 73 deletions scribble-lib/scribble/render.rkt
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
#lang racket/base

(require "core.rkt"
"base-render.rkt"
"xref.rkt"
racket/file
racket/class
(require racket/class
racket/contract/base
(prefix-in html: "html-render.rkt"))
racket/file
(prefix-in html: "html-render.rkt")
"base-render.rkt"
"core.rkt"
"xref.rkt")

(provide/contract
[render (((listof part?)
(listof path-string?))
(#:render-mixin
(class? . -> . class?)
#:dest-dir (or/c #f path-string?)
#:helper-file-prefix (or/c #f string?)
#:keep-existing-helper-files? any/c
#:prefix-file (or/c #f path-string?)
#:style-file (or/c #f path-string?)
#:style-extra-files (listof path-string?)
#:extra-files (listof path-string?)
#:image-preferences (listof (or/c 'ps 'pdf 'png 'svg 'gif))
#:redirect (or/c #f string?)
#:redirect-main (or/c #f string?)
#:directory-depth exact-nonnegative-integer?
#:xrefs (listof xref?)
#:info-in-files (listof path-string?)
#:info-out-file (or/c #f path-string?)
#:quiet? any/c
#:warn-undefined? any/c)
. ->* . void?)])
(provide (contract-out [render
(((listof part?) (listof path-string?))
(#:render-mixin (class? . -> . class?)
#:dest-dir (or/c #f path-string?)
#:helper-file-prefix (or/c #f string?)
#:keep-existing-helper-files? any/c
#:prefix-file (or/c #f path-string?)
#:style-file (or/c #f path-string?)
#:style-extra-files (listof path-string?)
#:extra-files (listof path-string?)
#:image-preferences (listof (or/c 'ps 'pdf 'png 'svg 'gif))
#:redirect (or/c #f string?)
#:redirect-main (or/c #f string?)
#:directory-depth exact-nonnegative-integer?
#:xrefs (listof xref?)
#:info-in-files (listof path-string?)
#:info-out-file (or/c #f path-string?)
#:quiet? any/c
#:warn-undefined? any/c)
. ->* .
void?)]))

(define (render docs
names
Expand All @@ -51,48 +50,47 @@
#:quiet? [quiet? #t]
#:warn-undefined? [warn-undefined? (not quiet?)])
(when dest-dir (make-directory* dest-dir))
(let ([renderer (new (render-mixin render%)
[dest-dir dest-dir]
[prefix-file prefix-file]
[style-file style-file]
[style-extra-files style-extra-files]
[extra-files extra-files]
[image-preferences image-preferences]
[helper-file-prefix helper-file-prefix]
[keep-existing-helper-files? keep-existing-helper-files?])])
(when redirect
(send renderer set-external-tag-path redirect))
(when redirect-main
(send renderer set-external-root-url redirect-main))
(unless (zero? directory-depth)
(send renderer set-directory-depth directory-depth))
(unless quiet?
(send renderer report-output!))
(let* ([fns (map (lambda (fn)
(let-values ([(base name dir?) (split-path fn)])
(let ([fn (path-replace-suffix
name
(send renderer get-suffix))])
(if dest-dir (build-path dest-dir fn) fn))))
names)]
[fp (send renderer traverse docs fns)]
[info (send renderer collect docs fns fp)])
(for ([file (in-list info-input-files)])
(let ([s (with-input-from-file file read)])
(send renderer deserialize-info s info)))
(for ([xr (in-list xrefs)])
(xref-transfer-info renderer info xr))
(let ([r-info (send renderer resolve docs fns info)])
(send renderer render docs fns r-info)
(when info-output-file
(let ([s (send renderer serialize-info r-info)])
(with-output-to-file info-output-file
#:exists 'truncate/replace
(lambda () (write s)))))
(when warn-undefined?
(let ([undef (send renderer get-undefined r-info)])
(unless (null? undef)
(eprintf "Warning: some cross references may be broken due to undefined tags:\n")
(for ([t (in-list undef)])
(eprintf " ~s\n" t))))))
(void))))
(define renderer
(new (render-mixin render%)
[dest-dir dest-dir]
[prefix-file prefix-file]
[style-file style-file]
[style-extra-files style-extra-files]
[extra-files extra-files]
[image-preferences image-preferences]
[helper-file-prefix helper-file-prefix]
[keep-existing-helper-files? keep-existing-helper-files?]))
(when redirect
(send renderer set-external-tag-path redirect))
(when redirect-main
(send renderer set-external-root-url redirect-main))
(unless (zero? directory-depth)
(send renderer set-directory-depth directory-depth))
(unless quiet?
(send renderer report-output!))
(define fns
(map (lambda (fn)
(let-values ([(base name dir?) (split-path fn)])
(let ([fn (path-replace-suffix name (send renderer get-suffix))])
(if dest-dir
(build-path dest-dir fn)
fn))))
names))
(define fp (send renderer traverse docs fns))
(define info (send renderer collect docs fns fp))
(for ([file (in-list info-input-files)])
(let ([s (with-input-from-file file read)]) (send renderer deserialize-info s info)))
(for ([xr (in-list xrefs)])
(xref-transfer-info renderer info xr))
(let ([r-info (send renderer resolve docs fns info)])
(send renderer render docs fns r-info)
(when info-output-file
(let ([s (send renderer serialize-info r-info)])
(with-output-to-file info-output-file #:exists 'truncate/replace (lambda () (write s)))))
(when warn-undefined?
(let ([undef (send renderer get-undefined r-info)])
(unless (null? undef)
(eprintf "Warning: some cross references may be broken due to undefined tags:\n")
(for ([t (in-list undef)])
(eprintf " ~s\n" t))))))
(void))
Loading

0 comments on commit bdaa06a

Please sign in to comment.