Skip to content

Commit 868214e

Browse files
jackfirthclaude
andauthored
Document file group API in the grimoire (#789)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent a3a844a commit 868214e

6 files changed

Lines changed: 527 additions & 317 deletions

File tree

cli.rkt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
resyntax
2525
resyntax/base
2626
resyntax/default-recommendations
27-
resyntax/private/file-group
27+
resyntax/grimoire/source-group
2828
resyntax/private/github
2929
resyntax/private/refactoring-result
3030
resyntax/grimoire/source
@@ -71,25 +71,25 @@
7171
("--file"
7272
filepath
7373
"A file to analyze."
74-
(vector-builder-add targets (single-file-group filepath all-lines)))
74+
(vector-builder-add targets (single-source-group filepath all-lines)))
7575

7676
("--directory"
7777
dirpath
7878
"A directory to analyze, including subdirectories."
79-
(vector-builder-add targets (directory-file-group dirpath)))
79+
(vector-builder-add targets (directory-source-group dirpath)))
8080

8181
("--package"
8282
pkgname
8383
"An installed package to analyze."
84-
(vector-builder-add targets (package-file-group pkgname)))
84+
(vector-builder-add targets (package-source-group pkgname)))
8585

8686
("--local-git-repository"
8787
repopath baseref
8888
"A Git repository to search for modified files to analyze. The repopath argument is a directory
8989
path to the root of a Git repository, and the baseref argument is a Git reference (in the form \
9090
\"remotename/branchname\") to use as the base state of the repository. Any files that have been \
9191
changed relative to baseref are analyzed."
92-
(vector-builder-add targets (git-repository-file-group repopath baseref)))
92+
(vector-builder-add targets (git-repository-source-group repopath baseref)))
9393

9494
#:once-each
9595

@@ -158,25 +158,25 @@ determined by the GITHUB_REPOSITORY and GITHUB_REF environment variables."
158158

159159
#:multi
160160

161-
("--file" filepath "A file to fix." (add-target! (single-file-group filepath all-lines)))
161+
("--file" filepath "A file to fix." (add-target! (single-source-group filepath all-lines)))
162162

163163
("--directory"
164164
dirpath
165165
"A directory to fix, including subdirectories."
166-
(add-target! (directory-file-group dirpath)))
166+
(add-target! (directory-source-group dirpath)))
167167

168168
("--package"
169169
pkgname
170170
"An installed package to fix."
171-
(add-target! (package-file-group pkgname)))
171+
(add-target! (package-source-group pkgname)))
172172

173173
("--local-git-repository"
174174
repopath baseref
175175
"A Git repository to search for modified files to fix. The repopath argument is a directory
176176
path to the root of a Git repository, and the baseref argument is a Git reference (in the form \
177177
\"remotename/branchname\") to use as the base state of the repository. Any files that have been \
178178
changed relative to baseref are analyzed and fixed."
179-
(add-target! (git-repository-file-group repopath baseref)))
179+
(add-target! (git-repository-source-group repopath baseref)))
180180

181181
#:once-each
182182

@@ -284,7 +284,8 @@ For help on these, use 'analyze --help' or 'fix --help'."
284284

285285
(define (resyntax-analyze-run)
286286
(define options (resyntax-analyze-parse-command-line))
287-
(define sources (file-groups-resolve (resyntax-analyze-options-targets options)))
287+
(define target-group (source-group-union-all (resyntax-analyze-options-targets options)))
288+
(define sources (source-group-resolve target-group))
288289
(define analysis
289290
(resyntax-analyze-all sources
290291
#:suite (resyntax-analyze-options-suite options)
@@ -329,7 +330,8 @@ For help on these, use 'analyze --help' or 'fix --help'."
329330
(define options (resyntax-fix-parse-command-line))
330331
(define fix-method (resyntax-fix-options-fix-method options))
331332
(define output-format (resyntax-fix-options-output-format options))
332-
(define sources (file-groups-resolve (resyntax-fix-options-targets options)))
333+
(define target-group (source-group-union-all (resyntax-fix-options-targets options)))
334+
(define sources (source-group-resolve target-group))
333335
(define max-modified-files (resyntax-fix-options-max-modified-files options))
334336
(define max-modified-lines (resyntax-fix-options-max-modified-lines options))
335337
(define analysis

cli.scrbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ for fixing code by applying Resyntax's suggestions.
1616
Note that at present, Resyntax is limited in what files it can fix. Resyntax only analyzes files with
1717
the @exec{.rkt} extension where @tt{#lang racket/base} is the first line in the file.
1818

19+
Each of the target flags accepted by these commands constructs a @tech{source group} describing which
20+
files to operate on. See @secref["source-group"] in The Resyntax Grimoire for the API underlying these
21+
flags.
22+
1923

2024
@section[#:tag "install"]{Installation}
2125

grimoire.scrbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ programmatically on anything found here.
1313

1414

1515
@include-section[(lib "resyntax/grimoire/source.scrbl")]
16+
@include-section[(lib "resyntax/grimoire/source-group.scrbl")]
1617
@include-section[(lib "resyntax/grimoire/syntax-path.scrbl")]

0 commit comments

Comments
 (0)