readability-cli 0.7.0__tar.gz → 0.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {readability_cli-0.7.0 → readability_cli-0.8.0}/PKG-INFO +137 -57
  2. {readability_cli-0.7.0 → readability_cli-0.8.0}/README.md +136 -56
  3. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/cppguide.md +3 -3
  4. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/tsguide.md +2 -2
  5. {readability_cli-0.7.0 → readability_cli-0.8.0}/pyproject.toml +1 -1
  6. {readability_cli-0.7.0 → readability_cli-0.8.0}/readability.py +617 -233
  7. {readability_cli-0.7.0 → readability_cli-0.8.0}/test_readability.py +721 -154
  8. {readability_cli-0.7.0 → readability_cli-0.8.0}/uv.lock +1 -1
  9. {readability_cli-0.7.0 → readability_cli-0.8.0}/.github/workflows/ci.yml +0 -0
  10. {readability_cli-0.7.0 → readability_cli-0.8.0}/.github/workflows/publish.yml +0 -0
  11. {readability_cli-0.7.0 → readability_cli-0.8.0}/.github/workflows/update-guides.yml +0 -0
  12. {readability_cli-0.7.0 → readability_cli-0.8.0}/.gitignore +0 -0
  13. {readability_cli-0.7.0 → readability_cli-0.8.0}/.python-version +0 -0
  14. {readability_cli-0.7.0 → readability_cli-0.8.0}/LICENSE +0 -0
  15. {readability_cli-0.7.0 → readability_cli-0.8.0}/configs/pyrefly.toml +0 -0
  16. {readability_cli-0.7.0 → readability_cli-0.8.0}/configs/ruff.toml +0 -0
  17. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/Rguide.md +0 -0
  18. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/csharp-style.md +0 -0
  19. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/docguide-style.md +0 -0
  20. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/go-guide.md +0 -0
  21. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/htmlcssguide.md +0 -0
  22. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/javaguide.md +0 -0
  23. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/jsguide.md +0 -0
  24. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/jsoncstyleguide.md +0 -0
  25. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/objcguide.md +0 -0
  26. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/pyguide.md +0 -0
  27. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/shellguide.md +0 -0
  28. {readability_cli-0.7.0 → readability_cli-0.8.0}/guides/vimscriptguide.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: readability-cli
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: A CLI to lint, format, and type-check code with Google-style defaults, and pull Google style guides in markdown format.
5
5
  Project-URL: Homepage, https://github.com/owahltinez/readability
6
6
  Project-URL: Repository, https://github.com/owahltinez/readability
@@ -28,7 +28,8 @@ and quick access to style conventions without browsing HTML pages.
28
28
  Pyrefly are used automatically when a project does not define its own.
29
29
  - **Style Guides**: A `guide` command that fetches the latest Google style
30
30
  guides (Python, Shell, C++, Java, JS/TS, Go, etc.) converted to Markdown,
31
- navigable by outline and by section rather than read whole.
31
+ and outlines, addresses, and searches them by section rather than serving
32
+ 200 KB to be read whole.
32
33
  - **Offline Mode**: Local caching of style guides for fast, offline access,
33
34
  kept fresh with a single `sync` command.
34
35
 
@@ -40,8 +41,9 @@ You can run the tool directly without installing it using `uvx`:
40
41
  # Check and fix formatting for the current directory
41
42
  uvx --from readability-cli readability check . --fix
42
43
 
43
- # Get the Python style guide
44
+ # Outline the Python style guide, then read one of its sections
44
45
  uvx --from readability-cli readability guide python
46
+ uvx --from readability-cli readability guide python 2.2
45
47
  ```
46
48
 
47
49
  ## Installation
@@ -92,17 +94,58 @@ readability check . --fix
92
94
 
93
95
  ### Supported Tools
94
96
 
95
- | Tool | Supported Extensions | Trigger Files |
96
- |------|----------------------|---------------|
97
- | **Ruff** | `.py` | `pyproject.toml`, `ruff.toml`, `.ruff.toml` |
98
- | **Pyrefly** | `.py` | `pyproject.toml`, `pyrefly.toml` |
99
- | **Biome** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.jsonc`, `.css`, `.html` | `biome.json`, `biome.jsonc` |
100
- | **Prettier** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.css`, `.scss`, `.html`, `.md`, `.yml`, `.yaml` | `.prettierrc*`, `prettier.config.*` |
101
- | **gofmt** | `.go` | `go.mod` |
97
+ | Tool | Supported Extensions | Config Needed | Fetched By |
98
+ |------|----------------------|---------------|------------|
99
+ | **Ruff** | `.py` | none, bundled | `uvx` |
100
+ | **Pyrefly** | `.py` | none, bundled | `uvx` |
101
+ | **Biome** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.jsonc`, `.css`, `.html` | `biome.json` or `biome.jsonc` | `npx` |
102
+ | **Prettier** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.css`, `.scss`, `.html`, `.md`, `.yml`, `.yaml` | `.prettierrc*` or `prettier.config.*` | `npx` |
103
+ | **gofmt** | `.go` | `go.mod` | — |
104
+
105
+ **You do not need to install any of these.** Each is resolved in order: a
106
+ project-local install (`node_modules/.bin`, `.venv/bin`) first, then whatever
107
+ is on your `PATH`, and only then fetched by `uvx` or `npx`. The runners cache
108
+ what they download, so the fetch happens once per machine and later runs are
109
+ served from disk and work offline.
110
+
111
+ That keeps this package at ~4 MB rather than the ~54 MB it would take to
112
+ carry Ruff and Pyrefly itself — a cost that would fall on everyone using only
113
+ `guide`. An installed copy always wins over a fetched one, so a project that
114
+ pinned a version is linted against the rules it chose.
115
+
116
+ Fetched tools carry a minimum version, enough to understand the bundled
117
+ configurations, and no maximum. A ceiling would freeze anyone who installed
118
+ nothing at whatever was current when this package shipped, and tie its
119
+ releases to Ruff's — which has published seventeen minor series, roughly one
120
+ every six weeks. If you need a fixed version, install it: an installed tool
121
+ always wins over a fetched one.
122
+
123
+ Set `UV_OFFLINE=1` to forbid fetching. A tool that then cannot be reached
124
+ fails the run rather than passing it.
125
+
126
+ Ruff and Pyrefly ship with bundled configurations, so they run on any file
127
+ they handle without the project arranging anything. Biome, Prettier and gofmt
128
+ bring no defaults here, so they wait until the project asks with a config
129
+ file.
130
+
131
+ A tool that could not be reached at all is never skipped quietly:
102
132
 
103
- The command will only run a tool if its trigger file exists in the current
104
- working directory and the tool is available in your `PATH`. For `biome` and
105
- `prettier`, it attempts to run them via `npx`.
133
+ ```bash
134
+ # Some tools ran, so the result stands, but coverage was partial
135
+ $ readability check src/
136
+ Warning: not installed, so not run: prettier.
137
+ No findings in 1 path(s) (ruff, pyrefly).
138
+
139
+ # Nothing ran, so there is no result to report
140
+ $ readability check src/
141
+ Error: Every tool for 1 path(s) is missing, so nothing was verified.
142
+ ```
143
+
144
+ That second case needs neither the tool nor a runner to be present, which is
145
+ the state a container image is usually in.
146
+
147
+ `check` exits non-zero on findings and on having verified nothing, so it can
148
+ gate CI without a clean exit ever meaning "the tools were absent".
106
149
 
107
150
  ### Default Configurations
108
151
 
@@ -116,59 +159,64 @@ project-level configuration takes full precedence over the bundled defaults.
116
159
 
117
160
  ## Style Guides
118
161
 
119
- The `guide` command prints a Google style guide as Markdown, using the local
120
- cache when available:
162
+ The `guide` command reads a Google style guide, using the local cache when
163
+ available. It has four forms:
121
164
 
122
165
  ```bash
123
- # Get the Python style guide (uses local cache if available)
124
- readability guide python
125
-
126
- # Force fetching the latest version from the web
127
- readability guide python --remote
166
+ # Which languages have a guide, and which are cached
167
+ readability guide
128
168
 
129
- # Save a style guide to a file
130
- readability guide cpp --output cpp-style.md
169
+ # The outline of one: every heading, a few KB where the guide is 200
170
+ readability guide python
131
171
 
132
- # Search a guide without printing it: the pipe carries it, you see matches
133
- readability guide python | grep -n "f-string"
172
+ # One section, by index, heading text, or a parent-scoped path
173
+ readability guide cpp 10.4
174
+ readability guide shell "Function Comments"
175
+ readability guide python "Imports > Decision"
134
176
 
135
- # Synchronize all supported style guides to the local cache
136
- readability sync
177
+ # The whole guide, for grepping or when you really do want all of it
178
+ readability guide cpp --full
179
+ readability guide python --full | grep -i f-string
137
180
  ```
138
181
 
139
- A guide can exceed 100 KB, so printing one whole is rarely what you want.
140
- `--outline` and `--section` below cover navigating to a rule; piping to
141
- `grep` covers finding wording that no heading names. Neither leaves a copy
142
- behind, which is what a coding agent should do rather than redirecting a
143
- guide into the repository it is working on.
182
+ A guide can exceed 200 KB, so the outline is what a bare invocation prints:
183
+ listing the sections and fetching the one you need beats reading the lot.
184
+ Nothing is written to disk, which is what a coding agent should do rather
185
+ than redirecting a guide into the repository it is working on use a shell
186
+ redirect if you do want a copy.
187
+
188
+ `REF` and `--full` cannot be combined; that is refused rather than resolved
189
+ by a precedence rule you would have to know.
144
190
 
145
191
  ### Navigating a Guide
146
192
 
147
- `--outline` lists a guide's headings and `--section` prints just one of them,
148
- which turns "read 200 KB" into "list the sections, fetch the one you need":
193
+ The outline gives each section an index to fetch it by, and flags the ones
194
+ large enough to be worth knowing about first:
149
195
 
150
196
  ```bash
151
- # List every heading, with the index to pass to --section
152
- readability guide cpp --outline
153
-
154
- # Only the top two levels, for a bird's eye view of a large guide
155
- readability guide cpp --outline --depth 2
156
-
157
- # Print one section: its heading and everything nested under it
158
- readability guide shell --section "Function Comments"
159
- readability guide cpp --section 10.4
160
-
161
- # Sections can be saved like whole guides can
162
- readability guide python --section "Imports" --output imports.md
197
+ $ readability guide cpp
198
+ Google C++ Style Guide
199
+ 1 Background
200
+ 1.1 Goals of the Style Guide
201
+ 2 C++ Version
202
+ 3 Header Files (1.7k words)
203
+ 3.1 Self-contained Headers
204
+ ...
205
+ # 140 sections · print one: readability guide cpp 4.5.1
163
206
  ```
164
207
 
208
+ Sizes appear only at 1200 words and above — the 4% of sections expensive
209
+ enough that you would want warning. They include subsections, since that is
210
+ what the reference returns. The trailing line goes to stderr, so it never
211
+ contaminates a piped outline.
212
+
165
213
  A section reference can be any of the following:
166
214
 
167
215
  | Reference | Example |
168
216
  |-----------|---------|
169
- | Section index, as shown by `--outline` | `--section 2.2.4` |
170
- | Heading text, case-insensitive, or its slug | `--section "function comments"` |
171
- | A parent-scoped path, spaces around the `>` | `--section "Imports > Decision"` |
217
+ | Section index, as shown by the outline | `2.2.4` |
218
+ | Heading text, case-insensitive, or its slug | `"function comments"` |
219
+ | A parent-scoped path, spaces around the `>` | `"Imports > Decision"` |
172
220
 
173
221
  Whole matches are preferred; a reference that matches nothing in full is
174
222
  retried as a substring of the heading text.
@@ -187,28 +235,50 @@ printed section number or the heading text over a positional index, since
187
235
  positional indices shift when an unnumbered guide is re-synced.
188
236
 
189
237
  A reference that matches several headings is reported rather than guessed at,
190
- listing the index and path of every candidate on stderr:
238
+ listing every candidate on stderr:
191
239
 
192
240
  ```bash
193
- $ readability guide python --section Decision
241
+ $ readability guide python Decision
194
242
  Error: 'Decision' matches 19 headings in the 'python' guide. Repeat with one of:
195
- --section 2.1.4 (Python Language Rules > Lint > Decision)
196
- --section 2.2.4 (Python Language Rules > Imports > Decision)
243
+ 2.1.4 (Python Language Rules > Lint > Decision)
244
+ 2.2.4 (Python Language Rules > Imports > Decision)
197
245
  ...
198
246
  ```
199
247
 
200
- Content goes to stdout and diagnostics to stderr, so both flags are safe to
248
+ ### When a Reference Misses
249
+
250
+ A guide discusses plenty that no heading is named after, so a reference that
251
+ matches nothing is usually a vocabulary mismatch rather than a mistake. The
252
+ sections that mention the words are reported, which turns the miss into the
253
+ next command:
254
+
255
+ ```bash
256
+ $ readability guide python f-string
257
+ Error: Found no heading matching 'f-string' in the 'python' guide.
258
+ It appears in these sections:
259
+ 3.10 Python Style Rules > Strings
260
+ 3.10.1 Python Style Rules > Strings > Logging
261
+ ```
262
+
263
+ This locates a rule; it does not search text. For that, pipe `--full` to
264
+ `grep`, which you already know and which brings its own `-i`, `-A`, `-c` and
265
+ the rest:
266
+
267
+ ```bash
268
+ readability guide python --full | grep -in -A2 "f-string"
269
+ ```
270
+
271
+ Content goes to stdout and diagnostics to stderr, so every form is safe to
201
272
  pipe. Headings inside fenced code blocks are ignored, which matters for the
202
273
  Shell and Python guides where `#` starts a comment.
203
274
 
204
275
  ### Supported Languages
205
276
 
206
- Use `readability languages` to see a full list of supported languages and
207
- their aliases. This command also indicates which guides are currently
208
- available in the local cache with a `[cached]` label:
277
+ Run `readability guide` with no language for the full list and which guides
278
+ are cached:
209
279
 
210
280
  ```bash
211
- $ readability languages
281
+ $ readability guide
212
282
  Supported languages and their aliases:
213
283
  - r [cached]
214
284
  - c++, cpp [cached]
@@ -226,6 +296,16 @@ Supported languages and their aliases:
226
296
  - vim [cached]
227
297
  ```
228
298
 
299
+ Refresh the cache with `sync`, which takes languages or refetches everything:
300
+
301
+ ```bash
302
+ # Refetch one guide, or a few
303
+ readability sync python shell
304
+
305
+ # Refetch all of them
306
+ readability sync
307
+ ```
308
+
229
309
  ### Offline Mode
230
310
 
231
311
  The tool stores local copies of the style guides in the `guides/` directory
@@ -14,7 +14,8 @@ and quick access to style conventions without browsing HTML pages.
14
14
  Pyrefly are used automatically when a project does not define its own.
15
15
  - **Style Guides**: A `guide` command that fetches the latest Google style
16
16
  guides (Python, Shell, C++, Java, JS/TS, Go, etc.) converted to Markdown,
17
- navigable by outline and by section rather than read whole.
17
+ and outlines, addresses, and searches them by section rather than serving
18
+ 200 KB to be read whole.
18
19
  - **Offline Mode**: Local caching of style guides for fast, offline access,
19
20
  kept fresh with a single `sync` command.
20
21
 
@@ -26,8 +27,9 @@ You can run the tool directly without installing it using `uvx`:
26
27
  # Check and fix formatting for the current directory
27
28
  uvx --from readability-cli readability check . --fix
28
29
 
29
- # Get the Python style guide
30
+ # Outline the Python style guide, then read one of its sections
30
31
  uvx --from readability-cli readability guide python
32
+ uvx --from readability-cli readability guide python 2.2
31
33
  ```
32
34
 
33
35
  ## Installation
@@ -78,17 +80,58 @@ readability check . --fix
78
80
 
79
81
  ### Supported Tools
80
82
 
81
- | Tool | Supported Extensions | Trigger Files |
82
- |------|----------------------|---------------|
83
- | **Ruff** | `.py` | `pyproject.toml`, `ruff.toml`, `.ruff.toml` |
84
- | **Pyrefly** | `.py` | `pyproject.toml`, `pyrefly.toml` |
85
- | **Biome** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.jsonc`, `.css`, `.html` | `biome.json`, `biome.jsonc` |
86
- | **Prettier** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.css`, `.scss`, `.html`, `.md`, `.yml`, `.yaml` | `.prettierrc*`, `prettier.config.*` |
87
- | **gofmt** | `.go` | `go.mod` |
83
+ | Tool | Supported Extensions | Config Needed | Fetched By |
84
+ |------|----------------------|---------------|------------|
85
+ | **Ruff** | `.py` | none, bundled | `uvx` |
86
+ | **Pyrefly** | `.py` | none, bundled | `uvx` |
87
+ | **Biome** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.jsonc`, `.css`, `.html` | `biome.json` or `biome.jsonc` | `npx` |
88
+ | **Prettier** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.css`, `.scss`, `.html`, `.md`, `.yml`, `.yaml` | `.prettierrc*` or `prettier.config.*` | `npx` |
89
+ | **gofmt** | `.go` | `go.mod` | — |
90
+
91
+ **You do not need to install any of these.** Each is resolved in order: a
92
+ project-local install (`node_modules/.bin`, `.venv/bin`) first, then whatever
93
+ is on your `PATH`, and only then fetched by `uvx` or `npx`. The runners cache
94
+ what they download, so the fetch happens once per machine and later runs are
95
+ served from disk and work offline.
96
+
97
+ That keeps this package at ~4 MB rather than the ~54 MB it would take to
98
+ carry Ruff and Pyrefly itself — a cost that would fall on everyone using only
99
+ `guide`. An installed copy always wins over a fetched one, so a project that
100
+ pinned a version is linted against the rules it chose.
101
+
102
+ Fetched tools carry a minimum version, enough to understand the bundled
103
+ configurations, and no maximum. A ceiling would freeze anyone who installed
104
+ nothing at whatever was current when this package shipped, and tie its
105
+ releases to Ruff's — which has published seventeen minor series, roughly one
106
+ every six weeks. If you need a fixed version, install it: an installed tool
107
+ always wins over a fetched one.
108
+
109
+ Set `UV_OFFLINE=1` to forbid fetching. A tool that then cannot be reached
110
+ fails the run rather than passing it.
111
+
112
+ Ruff and Pyrefly ship with bundled configurations, so they run on any file
113
+ they handle without the project arranging anything. Biome, Prettier and gofmt
114
+ bring no defaults here, so they wait until the project asks with a config
115
+ file.
116
+
117
+ A tool that could not be reached at all is never skipped quietly:
88
118
 
89
- The command will only run a tool if its trigger file exists in the current
90
- working directory and the tool is available in your `PATH`. For `biome` and
91
- `prettier`, it attempts to run them via `npx`.
119
+ ```bash
120
+ # Some tools ran, so the result stands, but coverage was partial
121
+ $ readability check src/
122
+ Warning: not installed, so not run: prettier.
123
+ No findings in 1 path(s) (ruff, pyrefly).
124
+
125
+ # Nothing ran, so there is no result to report
126
+ $ readability check src/
127
+ Error: Every tool for 1 path(s) is missing, so nothing was verified.
128
+ ```
129
+
130
+ That second case needs neither the tool nor a runner to be present, which is
131
+ the state a container image is usually in.
132
+
133
+ `check` exits non-zero on findings and on having verified nothing, so it can
134
+ gate CI without a clean exit ever meaning "the tools were absent".
92
135
 
93
136
  ### Default Configurations
94
137
 
@@ -102,59 +145,64 @@ project-level configuration takes full precedence over the bundled defaults.
102
145
 
103
146
  ## Style Guides
104
147
 
105
- The `guide` command prints a Google style guide as Markdown, using the local
106
- cache when available:
148
+ The `guide` command reads a Google style guide, using the local cache when
149
+ available. It has four forms:
107
150
 
108
151
  ```bash
109
- # Get the Python style guide (uses local cache if available)
110
- readability guide python
111
-
112
- # Force fetching the latest version from the web
113
- readability guide python --remote
152
+ # Which languages have a guide, and which are cached
153
+ readability guide
114
154
 
115
- # Save a style guide to a file
116
- readability guide cpp --output cpp-style.md
155
+ # The outline of one: every heading, a few KB where the guide is 200
156
+ readability guide python
117
157
 
118
- # Search a guide without printing it: the pipe carries it, you see matches
119
- readability guide python | grep -n "f-string"
158
+ # One section, by index, heading text, or a parent-scoped path
159
+ readability guide cpp 10.4
160
+ readability guide shell "Function Comments"
161
+ readability guide python "Imports > Decision"
120
162
 
121
- # Synchronize all supported style guides to the local cache
122
- readability sync
163
+ # The whole guide, for grepping or when you really do want all of it
164
+ readability guide cpp --full
165
+ readability guide python --full | grep -i f-string
123
166
  ```
124
167
 
125
- A guide can exceed 100 KB, so printing one whole is rarely what you want.
126
- `--outline` and `--section` below cover navigating to a rule; piping to
127
- `grep` covers finding wording that no heading names. Neither leaves a copy
128
- behind, which is what a coding agent should do rather than redirecting a
129
- guide into the repository it is working on.
168
+ A guide can exceed 200 KB, so the outline is what a bare invocation prints:
169
+ listing the sections and fetching the one you need beats reading the lot.
170
+ Nothing is written to disk, which is what a coding agent should do rather
171
+ than redirecting a guide into the repository it is working on use a shell
172
+ redirect if you do want a copy.
173
+
174
+ `REF` and `--full` cannot be combined; that is refused rather than resolved
175
+ by a precedence rule you would have to know.
130
176
 
131
177
  ### Navigating a Guide
132
178
 
133
- `--outline` lists a guide's headings and `--section` prints just one of them,
134
- which turns "read 200 KB" into "list the sections, fetch the one you need":
179
+ The outline gives each section an index to fetch it by, and flags the ones
180
+ large enough to be worth knowing about first:
135
181
 
136
182
  ```bash
137
- # List every heading, with the index to pass to --section
138
- readability guide cpp --outline
139
-
140
- # Only the top two levels, for a bird's eye view of a large guide
141
- readability guide cpp --outline --depth 2
142
-
143
- # Print one section: its heading and everything nested under it
144
- readability guide shell --section "Function Comments"
145
- readability guide cpp --section 10.4
146
-
147
- # Sections can be saved like whole guides can
148
- readability guide python --section "Imports" --output imports.md
183
+ $ readability guide cpp
184
+ Google C++ Style Guide
185
+ 1 Background
186
+ 1.1 Goals of the Style Guide
187
+ 2 C++ Version
188
+ 3 Header Files (1.7k words)
189
+ 3.1 Self-contained Headers
190
+ ...
191
+ # 140 sections · print one: readability guide cpp 4.5.1
149
192
  ```
150
193
 
194
+ Sizes appear only at 1200 words and above — the 4% of sections expensive
195
+ enough that you would want warning. They include subsections, since that is
196
+ what the reference returns. The trailing line goes to stderr, so it never
197
+ contaminates a piped outline.
198
+
151
199
  A section reference can be any of the following:
152
200
 
153
201
  | Reference | Example |
154
202
  |-----------|---------|
155
- | Section index, as shown by `--outline` | `--section 2.2.4` |
156
- | Heading text, case-insensitive, or its slug | `--section "function comments"` |
157
- | A parent-scoped path, spaces around the `>` | `--section "Imports > Decision"` |
203
+ | Section index, as shown by the outline | `2.2.4` |
204
+ | Heading text, case-insensitive, or its slug | `"function comments"` |
205
+ | A parent-scoped path, spaces around the `>` | `"Imports > Decision"` |
158
206
 
159
207
  Whole matches are preferred; a reference that matches nothing in full is
160
208
  retried as a substring of the heading text.
@@ -173,28 +221,50 @@ printed section number or the heading text over a positional index, since
173
221
  positional indices shift when an unnumbered guide is re-synced.
174
222
 
175
223
  A reference that matches several headings is reported rather than guessed at,
176
- listing the index and path of every candidate on stderr:
224
+ listing every candidate on stderr:
177
225
 
178
226
  ```bash
179
- $ readability guide python --section Decision
227
+ $ readability guide python Decision
180
228
  Error: 'Decision' matches 19 headings in the 'python' guide. Repeat with one of:
181
- --section 2.1.4 (Python Language Rules > Lint > Decision)
182
- --section 2.2.4 (Python Language Rules > Imports > Decision)
229
+ 2.1.4 (Python Language Rules > Lint > Decision)
230
+ 2.2.4 (Python Language Rules > Imports > Decision)
183
231
  ...
184
232
  ```
185
233
 
186
- Content goes to stdout and diagnostics to stderr, so both flags are safe to
234
+ ### When a Reference Misses
235
+
236
+ A guide discusses plenty that no heading is named after, so a reference that
237
+ matches nothing is usually a vocabulary mismatch rather than a mistake. The
238
+ sections that mention the words are reported, which turns the miss into the
239
+ next command:
240
+
241
+ ```bash
242
+ $ readability guide python f-string
243
+ Error: Found no heading matching 'f-string' in the 'python' guide.
244
+ It appears in these sections:
245
+ 3.10 Python Style Rules > Strings
246
+ 3.10.1 Python Style Rules > Strings > Logging
247
+ ```
248
+
249
+ This locates a rule; it does not search text. For that, pipe `--full` to
250
+ `grep`, which you already know and which brings its own `-i`, `-A`, `-c` and
251
+ the rest:
252
+
253
+ ```bash
254
+ readability guide python --full | grep -in -A2 "f-string"
255
+ ```
256
+
257
+ Content goes to stdout and diagnostics to stderr, so every form is safe to
187
258
  pipe. Headings inside fenced code blocks are ignored, which matters for the
188
259
  Shell and Python guides where `#` starts a comment.
189
260
 
190
261
  ### Supported Languages
191
262
 
192
- Use `readability languages` to see a full list of supported languages and
193
- their aliases. This command also indicates which guides are currently
194
- available in the local cache with a `[cached]` label:
263
+ Run `readability guide` with no language for the full list and which guides
264
+ are cached:
195
265
 
196
266
  ```bash
197
- $ readability languages
267
+ $ readability guide
198
268
  Supported languages and their aliases:
199
269
  - r [cached]
200
270
  - c++, cpp [cached]
@@ -212,6 +282,16 @@ Supported languages and their aliases:
212
282
  - vim [cached]
213
283
  ```
214
284
 
285
+ Refresh the cache with `sync`, which takes languages or refetches everything:
286
+
287
+ ```bash
288
+ # Refetch one guide, or a few
289
+ readability sync python shell
290
+
291
+ # Refetch all of them
292
+ readability sync
293
+ ```
294
+
215
295
  ### Offline Mode
216
296
 
217
297
  The tool stores local copies of the style guides in the `guides/` directory
@@ -415,7 +415,7 @@ brackets:
415
415
  and `<string>`).
416
416
  * POSIX, Linux, and Windows system headers (e.g., `<unistd.h>`
417
417
  and `<windows.h>`).
418
- * In rare cases, third\_party libraries (e.g., `<Python.h>`).
418
+ * In rare cases, third_party libraries (e.g., `<Python.h>`).
419
419
 
420
420
  In `dir/foo.cc` or
421
421
  `dir/foo_test.cc`, whose main
@@ -1005,7 +1005,7 @@ Dynamic initialization of static local variables is allowed (and common).
1005
1005
  it by using a function-local static pointer or reference (e.g.,
1006
1006
  `static const auto& impl = *new T(args...);`).
1007
1007
 
1008
- ### thread\_local Variables
1008
+ ### thread_local Variables
1009
1009
 
1010
1010
  `thread_local` variables that aren't declared inside a function
1011
1011
  must be initialized with a true compile-time constant,
@@ -3989,7 +3989,7 @@ the rules are the rules.
3989
3989
  For the purposes of the naming rules below, a "word" is anything that you
3990
3990
  would write in English without internal spaces. Either words are all lowercase,
3991
3991
  with underscores between words
3992
- ("[snake\_case](https://en.wikipedia.org/wiki/Snake_case)"), or words
3992
+ ("[snake_case](https://en.wikipedia.org/wiki/Snake_case)"), or words
3993
3993
  are mixed case with the first letter of each word capitalized
3994
3994
  ("[camelCase](https://en.wikipedia.org/wiki/Camel_case)" or
3995
3995
  "[PascalCase](https://en.wiktionary.org/wiki/Pascal_case)").
@@ -110,8 +110,8 @@ There are four variants of import statements in ES6 and TypeScript:
110
110
 
111
111
  | Import type | Example | Use for |
112
112
  | --- | --- | --- |
113
- | module[module\_import] | `import * as foo from '...';` | TypeScript imports |
114
- | named[destructuring\_import] | `import {SomeThing} from '...';` | TypeScript imports |
113
+ | module[module_import] | `import * as foo from '...';` | TypeScript imports |
114
+ | named[destructuring_import] | `import {SomeThing} from '...';` | TypeScript imports |
115
115
  | default | `import SomeThing from '...';` | Only for other external code that requires them |
116
116
  | side-effect | `import '...';` | Only to import libraries for their side-effects on load (such as custom elements) |
117
117
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "readability-cli"
3
- version = "0.7.0"
3
+ version = "0.8.0"
4
4
  description = "A CLI to lint, format, and type-check code with Google-style defaults, and pull Google style guides in markdown format."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"