readability-cli 0.6.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 (32) hide show
  1. readability_cli-0.8.0/PKG-INFO +355 -0
  2. readability_cli-0.8.0/README.md +341 -0
  3. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/cppguide.md +3 -3
  4. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/tsguide.md +2 -2
  5. {readability_cli-0.6.0 → readability_cli-0.8.0}/pyproject.toml +1 -1
  6. readability_cli-0.8.0/readability.py +1685 -0
  7. readability_cli-0.8.0/test_readability.py +1908 -0
  8. {readability_cli-0.6.0 → readability_cli-0.8.0}/uv.lock +1 -1
  9. readability_cli-0.6.0/PKG-INFO +0 -215
  10. readability_cli-0.6.0/README.md +0 -201
  11. readability_cli-0.6.0/readability.py +0 -828
  12. readability_cli-0.6.0/test_readability.py +0 -711
  13. {readability_cli-0.6.0 → readability_cli-0.8.0}/.github/workflows/ci.yml +0 -0
  14. {readability_cli-0.6.0 → readability_cli-0.8.0}/.github/workflows/publish.yml +0 -0
  15. {readability_cli-0.6.0 → readability_cli-0.8.0}/.github/workflows/update-guides.yml +0 -0
  16. {readability_cli-0.6.0 → readability_cli-0.8.0}/.gitignore +0 -0
  17. {readability_cli-0.6.0 → readability_cli-0.8.0}/.python-version +0 -0
  18. {readability_cli-0.6.0 → readability_cli-0.8.0}/LICENSE +0 -0
  19. {readability_cli-0.6.0 → readability_cli-0.8.0}/configs/pyrefly.toml +0 -0
  20. {readability_cli-0.6.0 → readability_cli-0.8.0}/configs/ruff.toml +0 -0
  21. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/Rguide.md +0 -0
  22. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/csharp-style.md +0 -0
  23. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/docguide-style.md +0 -0
  24. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/go-guide.md +0 -0
  25. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/htmlcssguide.md +0 -0
  26. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/javaguide.md +0 -0
  27. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/jsguide.md +0 -0
  28. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/jsoncstyleguide.md +0 -0
  29. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/objcguide.md +0 -0
  30. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/pyguide.md +0 -0
  31. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/shellguide.md +0 -0
  32. {readability_cli-0.6.0 → readability_cli-0.8.0}/guides/vimscriptguide.md +0 -0
@@ -0,0 +1,355 @@
1
+ Metadata-Version: 2.5
2
+ Name: readability-cli
3
+ Version: 0.8.0
4
+ Summary: A CLI to lint, format, and type-check code with Google-style defaults, and pull Google style guides in markdown format.
5
+ Project-URL: Homepage, https://github.com/owahltinez/readability
6
+ Project-URL: Repository, https://github.com/owahltinez/readability
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.12
9
+ Requires-Dist: beautifulsoup4>=4.14.3
10
+ Requires-Dist: click>=8.3.1
11
+ Requires-Dist: markdownify>=1.2.2
12
+ Requires-Dist: requests>=2.33.0
13
+ Description-Content-Type: text/markdown
14
+
15
+ # Readability
16
+
17
+ A CLI tool that keeps code aligned with Google style conventions. It runs the
18
+ right linters, formatters, and type checkers for your project with sensible
19
+ defaults, and serves the official Google style guides in Markdown format. This
20
+ is ideal for AI agents or developers who want consistent code quality checks
21
+ and quick access to style conventions without browsing HTML pages.
22
+
23
+ ## Features
24
+
25
+ - **Linting & Formatting**: A `check` command that automatically detects and
26
+ runs relevant tools (Ruff, Pyrefly, Biome, Prettier, gofmt) for your project.
27
+ - **Sensible Defaults**: Bundled Google-style configurations for Ruff and
28
+ Pyrefly are used automatically when a project does not define its own.
29
+ - **Style Guides**: A `guide` command that fetches the latest Google style
30
+ guides (Python, Shell, C++, Java, JS/TS, Go, etc.) converted to Markdown,
31
+ and outlines, addresses, and searches them by section rather than serving
32
+ 200 KB to be read whole.
33
+ - **Offline Mode**: Local caching of style guides for fast, offline access,
34
+ kept fresh with a single `sync` command.
35
+
36
+ ## Quick Start
37
+
38
+ You can run the tool directly without installing it using `uvx`:
39
+
40
+ ```bash
41
+ # Check and fix formatting for the current directory
42
+ uvx --from readability-cli readability check . --fix
43
+
44
+ # Outline the Python style guide, then read one of its sections
45
+ uvx --from readability-cli readability guide python
46
+ uvx --from readability-cli readability guide python 2.2
47
+ ```
48
+
49
+ ## Installation
50
+
51
+ Install it as a global tool with `uv`:
52
+
53
+ ```bash
54
+ # Install the readability tool
55
+ uv tool install readability-cli
56
+
57
+ # Use it anywhere
58
+ readability check .
59
+ readability guide python
60
+ ```
61
+
62
+ ### For Development
63
+
64
+ This project uses `uv` for dependency management:
65
+
66
+ ```bash
67
+ # Clone the repository
68
+ git clone https://github.com/owahltinez/readability.git
69
+ cd readability
70
+
71
+ # Install dependencies and create a virtual environment
72
+ uv sync
73
+
74
+ # (Optional) Populate the local cache for offline use
75
+ uv run readability sync
76
+ ```
77
+
78
+ ## Checking and Formatting
79
+
80
+ The `check` command identifies and runs relevant linting and formatting tools
81
+ based on file extensions and the presence of configuration files (triggers) in
82
+ your project root:
83
+
84
+ ```bash
85
+ # Run checks on the current directory
86
+ readability check .
87
+
88
+ # Check specific files or directories
89
+ readability check src/ tests/ main.py
90
+
91
+ # Automatically fix and format files
92
+ readability check . --fix
93
+ ```
94
+
95
+ ### Supported Tools
96
+
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:
132
+
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".
149
+
150
+ ### Default Configurations
151
+
152
+ For Ruff and Pyrefly, bundled defaults based on the
153
+ [Google Python style guide](https://google.github.io/styleguide/pyguide.html)
154
+ (80-column lines, Google docstring convention, import ordering, full type
155
+ checking) are applied when the project does not define its own configuration.
156
+ To override them, add a `[tool.ruff]` or `[tool.pyrefly]` section to your
157
+ `pyproject.toml` (or a dedicated `ruff.toml` / `pyrefly.toml`) — any
158
+ project-level configuration takes full precedence over the bundled defaults.
159
+
160
+ ## Style Guides
161
+
162
+ The `guide` command reads a Google style guide, using the local cache when
163
+ available. It has four forms:
164
+
165
+ ```bash
166
+ # Which languages have a guide, and which are cached
167
+ readability guide
168
+
169
+ # The outline of one: every heading, a few KB where the guide is 200
170
+ readability guide python
171
+
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"
176
+
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
180
+ ```
181
+
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.
190
+
191
+ ### Navigating a Guide
192
+
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:
195
+
196
+ ```bash
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
206
+ ```
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
+
213
+ A section reference can be any of the following:
214
+
215
+ | Reference | Example |
216
+ |-----------|---------|
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"` |
220
+
221
+ Whole matches are preferred; a reference that matches nothing in full is
222
+ retried as a substring of the heading text.
223
+
224
+ Three of the shipped guides — Python, JavaScript, and Java — number their own
225
+ sections, and those numbers are the index. A rule cited from the outline then
226
+ matches the published guide exactly, including where the guide skips a
227
+ number: the Python guide has no 2.15 at all, so its 2.16 is listed as 2.16
228
+ rather than renumbered. The other eleven guides number nothing, so their
229
+ index comes from each heading's position in the tree.
230
+
231
+ Either way the index is unique, which is what makes a repeated heading
232
+ addressable — `Definition`, `Pros`, `Cons`, and `Decision` appear under every
233
+ rule in the Python guide. For a reference stored and used later, prefer a
234
+ printed section number or the heading text over a positional index, since
235
+ positional indices shift when an unnumbered guide is re-synced.
236
+
237
+ A reference that matches several headings is reported rather than guessed at,
238
+ listing every candidate on stderr:
239
+
240
+ ```bash
241
+ $ readability guide python Decision
242
+ Error: 'Decision' matches 19 headings in the 'python' guide. Repeat with one of:
243
+ 2.1.4 (Python Language Rules > Lint > Decision)
244
+ 2.2.4 (Python Language Rules > Imports > Decision)
245
+ ...
246
+ ```
247
+
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
272
+ pipe. Headings inside fenced code blocks are ignored, which matters for the
273
+ Shell and Python guides where `#` starts a comment.
274
+
275
+ ### Supported Languages
276
+
277
+ Run `readability guide` with no language for the full list and which guides
278
+ are cached:
279
+
280
+ ```bash
281
+ $ readability guide
282
+ Supported languages and their aliases:
283
+ - r [cached]
284
+ - c++, cpp [cached]
285
+ - c#, csharp [cached]
286
+ - docguide, markdown [cached]
287
+ - go [cached]
288
+ - css, html [cached]
289
+ - java [cached]
290
+ - javascript, js [cached]
291
+ - json [cached]
292
+ - objc, objective-c [cached]
293
+ - python [cached]
294
+ - shell [cached]
295
+ - ts, typescript [cached]
296
+ - vim [cached]
297
+ ```
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
+
309
+ ### Offline Mode
310
+
311
+ The tool stores local copies of the style guides in the `guides/` directory
312
+ and the `guide` command uses these local files when they exist. The bundled
313
+ copies are automatically synchronized weekly from the official
314
+ [Google Style Guides](https://google.github.io/styleguide/) repository via
315
+ GitHub Actions, and you can refresh your local cache at any time with the
316
+ `sync` command.
317
+
318
+ You can override the default `guides/` directory by setting the
319
+ `READABILITY_CACHE` environment variable. This is useful if you want to store
320
+ the guides in a specific location or share them across different
321
+ installations:
322
+
323
+ ```bash
324
+ export READABILITY_CACHE=/path/to/my/guides
325
+ readability guide python
326
+ ```
327
+
328
+ ## Development
329
+
330
+ Run tests with `pytest`:
331
+
332
+ ```bash
333
+ uv run pytest
334
+ ```
335
+
336
+ Check code style with `ruff`:
337
+
338
+ ```bash
339
+ uv run ruff check .
340
+ uv run ruff format .
341
+ ```
342
+
343
+ ### Releasing
344
+
345
+ Releases are published to PyPI as
346
+ [`readability-cli`](https://pypi.org/project/readability-cli/) via trusted
347
+ publishing: pushing a `v*` tag triggers the `publish.yml` GitHub Actions
348
+ workflow, which builds the package with `uv build` and uploads it.
349
+
350
+ ```bash
351
+ # 1. Bump the version in pyproject.toml, commit, and push
352
+ # 2. Tag the release and push the tag
353
+ git tag v0.4.1
354
+ git push origin v0.4.1
355
+ ```
@@ -0,0 +1,341 @@
1
+ # Readability
2
+
3
+ A CLI tool that keeps code aligned with Google style conventions. It runs the
4
+ right linters, formatters, and type checkers for your project with sensible
5
+ defaults, and serves the official Google style guides in Markdown format. This
6
+ is ideal for AI agents or developers who want consistent code quality checks
7
+ and quick access to style conventions without browsing HTML pages.
8
+
9
+ ## Features
10
+
11
+ - **Linting & Formatting**: A `check` command that automatically detects and
12
+ runs relevant tools (Ruff, Pyrefly, Biome, Prettier, gofmt) for your project.
13
+ - **Sensible Defaults**: Bundled Google-style configurations for Ruff and
14
+ Pyrefly are used automatically when a project does not define its own.
15
+ - **Style Guides**: A `guide` command that fetches the latest Google style
16
+ guides (Python, Shell, C++, Java, JS/TS, Go, etc.) converted to Markdown,
17
+ and outlines, addresses, and searches them by section rather than serving
18
+ 200 KB to be read whole.
19
+ - **Offline Mode**: Local caching of style guides for fast, offline access,
20
+ kept fresh with a single `sync` command.
21
+
22
+ ## Quick Start
23
+
24
+ You can run the tool directly without installing it using `uvx`:
25
+
26
+ ```bash
27
+ # Check and fix formatting for the current directory
28
+ uvx --from readability-cli readability check . --fix
29
+
30
+ # Outline the Python style guide, then read one of its sections
31
+ uvx --from readability-cli readability guide python
32
+ uvx --from readability-cli readability guide python 2.2
33
+ ```
34
+
35
+ ## Installation
36
+
37
+ Install it as a global tool with `uv`:
38
+
39
+ ```bash
40
+ # Install the readability tool
41
+ uv tool install readability-cli
42
+
43
+ # Use it anywhere
44
+ readability check .
45
+ readability guide python
46
+ ```
47
+
48
+ ### For Development
49
+
50
+ This project uses `uv` for dependency management:
51
+
52
+ ```bash
53
+ # Clone the repository
54
+ git clone https://github.com/owahltinez/readability.git
55
+ cd readability
56
+
57
+ # Install dependencies and create a virtual environment
58
+ uv sync
59
+
60
+ # (Optional) Populate the local cache for offline use
61
+ uv run readability sync
62
+ ```
63
+
64
+ ## Checking and Formatting
65
+
66
+ The `check` command identifies and runs relevant linting and formatting tools
67
+ based on file extensions and the presence of configuration files (triggers) in
68
+ your project root:
69
+
70
+ ```bash
71
+ # Run checks on the current directory
72
+ readability check .
73
+
74
+ # Check specific files or directories
75
+ readability check src/ tests/ main.py
76
+
77
+ # Automatically fix and format files
78
+ readability check . --fix
79
+ ```
80
+
81
+ ### Supported Tools
82
+
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:
118
+
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".
135
+
136
+ ### Default Configurations
137
+
138
+ For Ruff and Pyrefly, bundled defaults based on the
139
+ [Google Python style guide](https://google.github.io/styleguide/pyguide.html)
140
+ (80-column lines, Google docstring convention, import ordering, full type
141
+ checking) are applied when the project does not define its own configuration.
142
+ To override them, add a `[tool.ruff]` or `[tool.pyrefly]` section to your
143
+ `pyproject.toml` (or a dedicated `ruff.toml` / `pyrefly.toml`) — any
144
+ project-level configuration takes full precedence over the bundled defaults.
145
+
146
+ ## Style Guides
147
+
148
+ The `guide` command reads a Google style guide, using the local cache when
149
+ available. It has four forms:
150
+
151
+ ```bash
152
+ # Which languages have a guide, and which are cached
153
+ readability guide
154
+
155
+ # The outline of one: every heading, a few KB where the guide is 200
156
+ readability guide python
157
+
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"
162
+
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
166
+ ```
167
+
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.
176
+
177
+ ### Navigating a Guide
178
+
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:
181
+
182
+ ```bash
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
192
+ ```
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
+
199
+ A section reference can be any of the following:
200
+
201
+ | Reference | Example |
202
+ |-----------|---------|
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"` |
206
+
207
+ Whole matches are preferred; a reference that matches nothing in full is
208
+ retried as a substring of the heading text.
209
+
210
+ Three of the shipped guides — Python, JavaScript, and Java — number their own
211
+ sections, and those numbers are the index. A rule cited from the outline then
212
+ matches the published guide exactly, including where the guide skips a
213
+ number: the Python guide has no 2.15 at all, so its 2.16 is listed as 2.16
214
+ rather than renumbered. The other eleven guides number nothing, so their
215
+ index comes from each heading's position in the tree.
216
+
217
+ Either way the index is unique, which is what makes a repeated heading
218
+ addressable — `Definition`, `Pros`, `Cons`, and `Decision` appear under every
219
+ rule in the Python guide. For a reference stored and used later, prefer a
220
+ printed section number or the heading text over a positional index, since
221
+ positional indices shift when an unnumbered guide is re-synced.
222
+
223
+ A reference that matches several headings is reported rather than guessed at,
224
+ listing every candidate on stderr:
225
+
226
+ ```bash
227
+ $ readability guide python Decision
228
+ Error: 'Decision' matches 19 headings in the 'python' guide. Repeat with one of:
229
+ 2.1.4 (Python Language Rules > Lint > Decision)
230
+ 2.2.4 (Python Language Rules > Imports > Decision)
231
+ ...
232
+ ```
233
+
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
258
+ pipe. Headings inside fenced code blocks are ignored, which matters for the
259
+ Shell and Python guides where `#` starts a comment.
260
+
261
+ ### Supported Languages
262
+
263
+ Run `readability guide` with no language for the full list and which guides
264
+ are cached:
265
+
266
+ ```bash
267
+ $ readability guide
268
+ Supported languages and their aliases:
269
+ - r [cached]
270
+ - c++, cpp [cached]
271
+ - c#, csharp [cached]
272
+ - docguide, markdown [cached]
273
+ - go [cached]
274
+ - css, html [cached]
275
+ - java [cached]
276
+ - javascript, js [cached]
277
+ - json [cached]
278
+ - objc, objective-c [cached]
279
+ - python [cached]
280
+ - shell [cached]
281
+ - ts, typescript [cached]
282
+ - vim [cached]
283
+ ```
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
+
295
+ ### Offline Mode
296
+
297
+ The tool stores local copies of the style guides in the `guides/` directory
298
+ and the `guide` command uses these local files when they exist. The bundled
299
+ copies are automatically synchronized weekly from the official
300
+ [Google Style Guides](https://google.github.io/styleguide/) repository via
301
+ GitHub Actions, and you can refresh your local cache at any time with the
302
+ `sync` command.
303
+
304
+ You can override the default `guides/` directory by setting the
305
+ `READABILITY_CACHE` environment variable. This is useful if you want to store
306
+ the guides in a specific location or share them across different
307
+ installations:
308
+
309
+ ```bash
310
+ export READABILITY_CACHE=/path/to/my/guides
311
+ readability guide python
312
+ ```
313
+
314
+ ## Development
315
+
316
+ Run tests with `pytest`:
317
+
318
+ ```bash
319
+ uv run pytest
320
+ ```
321
+
322
+ Check code style with `ruff`:
323
+
324
+ ```bash
325
+ uv run ruff check .
326
+ uv run ruff format .
327
+ ```
328
+
329
+ ### Releasing
330
+
331
+ Releases are published to PyPI as
332
+ [`readability-cli`](https://pypi.org/project/readability-cli/) via trusted
333
+ publishing: pushing a `v*` tag triggers the `publish.yml` GitHub Actions
334
+ workflow, which builds the package with `uv build` and uploads it.
335
+
336
+ ```bash
337
+ # 1. Bump the version in pyproject.toml, commit, and push
338
+ # 2. Tag the release and push the tag
339
+ git tag v0.4.1
340
+ git push origin v0.4.1
341
+ ```