readability-cli 0.5.0__tar.gz → 0.6.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.
- {readability_cli-0.5.0 → readability_cli-0.6.0}/PKG-INFO +11 -2
- {readability_cli-0.5.0 → readability_cli-0.6.0}/README.md +9 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/pyproject.toml +1 -1
- {readability_cli-0.5.0 → readability_cli-0.6.0}/readability.py +51 -1
- {readability_cli-0.5.0 → readability_cli-0.6.0}/test_readability.py +46 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/uv.lock +1 -1
- {readability_cli-0.5.0 → readability_cli-0.6.0}/.github/workflows/ci.yml +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/.github/workflows/publish.yml +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/.github/workflows/update-guides.yml +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/.gitignore +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/.python-version +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/LICENSE +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/configs/pyrefly.toml +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/configs/ruff.toml +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/Rguide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/cppguide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/csharp-style.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/docguide-style.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/go-guide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/htmlcssguide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/javaguide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/jsguide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/jsoncstyleguide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/objcguide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/pyguide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/shellguide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/tsguide.md +0 -0
- {readability_cli-0.5.0 → readability_cli-0.6.0}/guides/vimscriptguide.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: readability-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.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
|
|
@@ -128,10 +128,19 @@ readability guide python --remote
|
|
|
128
128
|
# Save a style guide to a file
|
|
129
129
|
readability guide cpp --output cpp-style.md
|
|
130
130
|
|
|
131
|
+
# Print where the guide already lives, to search it without copying it
|
|
132
|
+
readability guide python --path
|
|
133
|
+
grep -n "Naming" "$(readability guide python --path)"
|
|
134
|
+
|
|
131
135
|
# Synchronize all supported style guides to the local cache
|
|
132
136
|
readability sync
|
|
133
137
|
```
|
|
134
138
|
|
|
139
|
+
A guide can exceed 100 KB, so `--path` is the cheap way to consult one: the
|
|
140
|
+
file is already on disk, and searching it beats reading it whole or writing
|
|
141
|
+
out a second copy. It is also what a coding agent should use, rather than
|
|
142
|
+
redirecting the guide into a repository.
|
|
143
|
+
|
|
135
144
|
### Supported Languages
|
|
136
145
|
|
|
137
146
|
Use `readability languages` to see a full list of supported languages and
|
|
@@ -114,10 +114,19 @@ readability guide python --remote
|
|
|
114
114
|
# Save a style guide to a file
|
|
115
115
|
readability guide cpp --output cpp-style.md
|
|
116
116
|
|
|
117
|
+
# Print where the guide already lives, to search it without copying it
|
|
118
|
+
readability guide python --path
|
|
119
|
+
grep -n "Naming" "$(readability guide python --path)"
|
|
120
|
+
|
|
117
121
|
# Synchronize all supported style guides to the local cache
|
|
118
122
|
readability sync
|
|
119
123
|
```
|
|
120
124
|
|
|
125
|
+
A guide can exceed 100 KB, so `--path` is the cheap way to consult one: the
|
|
126
|
+
file is already on disk, and searching it beats reading it whole or writing
|
|
127
|
+
out a second copy. It is also what a coding agent should use, rather than
|
|
128
|
+
redirecting the guide into a repository.
|
|
129
|
+
|
|
121
130
|
### Supported Languages
|
|
122
131
|
|
|
123
132
|
Use `readability languages` to see a full list of supported languages and
|
|
@@ -253,6 +253,38 @@ def cli(ctx: click.Context, verbose: bool) -> None:
|
|
|
253
253
|
logger.setLevel(logging.DEBUG)
|
|
254
254
|
|
|
255
255
|
|
|
256
|
+
def _echo_guide_path(language: str) -> None:
|
|
257
|
+
"""Print the local path of a language's style guide.
|
|
258
|
+
|
|
259
|
+
Args:
|
|
260
|
+
language: The language whose guide is being located.
|
|
261
|
+
|
|
262
|
+
Raises:
|
|
263
|
+
SystemExit: If the language is unsupported or its guide is absent.
|
|
264
|
+
"""
|
|
265
|
+
filename = LANGUAGE_MAP.get(language.lower())
|
|
266
|
+
if not filename:
|
|
267
|
+
click.echo(
|
|
268
|
+
f"Error: Language '{language}' is not supported. Supported "
|
|
269
|
+
f"languages: {', '.join(sorted(LANGUAGE_MAP.keys()))}",
|
|
270
|
+
err=True,
|
|
271
|
+
)
|
|
272
|
+
sys.exit(1)
|
|
273
|
+
|
|
274
|
+
local_path = get_local_path(filename)
|
|
275
|
+
if not os.path.exists(local_path):
|
|
276
|
+
# Naming a file that is not there would send the caller to read
|
|
277
|
+
# nothing; fetching it is what `sync` is for.
|
|
278
|
+
click.echo(
|
|
279
|
+
f"Error: No local guide for '{language}' at {local_path}. "
|
|
280
|
+
"Run 'readability sync' to fetch it.",
|
|
281
|
+
err=True,
|
|
282
|
+
)
|
|
283
|
+
sys.exit(1)
|
|
284
|
+
|
|
285
|
+
click.echo(local_path)
|
|
286
|
+
|
|
287
|
+
|
|
256
288
|
@cli.command()
|
|
257
289
|
@click.argument("language")
|
|
258
290
|
@click.option(
|
|
@@ -264,9 +296,20 @@ def cli(ctx: click.Context, verbose: bool) -> None:
|
|
|
264
296
|
@click.option(
|
|
265
297
|
"--remote", "-r", is_flag=True, help="Force fetching from the web."
|
|
266
298
|
)
|
|
299
|
+
@click.option(
|
|
300
|
+
"--path",
|
|
301
|
+
"-p",
|
|
302
|
+
"show_path",
|
|
303
|
+
is_flag=True,
|
|
304
|
+
help="Print where the guide is stored instead of its contents.",
|
|
305
|
+
)
|
|
267
306
|
@click.option("--verbose", "-v", is_flag=True, help="Enable verbose logging.")
|
|
268
307
|
def guide(
|
|
269
|
-
language: str,
|
|
308
|
+
language: str,
|
|
309
|
+
output: Optional[str],
|
|
310
|
+
remote: bool,
|
|
311
|
+
show_path: bool,
|
|
312
|
+
verbose: bool,
|
|
270
313
|
) -> None:
|
|
271
314
|
"""Fetch the style guide for a specific LANGUAGE."""
|
|
272
315
|
if verbose:
|
|
@@ -274,6 +317,13 @@ def guide(
|
|
|
274
317
|
|
|
275
318
|
logger.info("Processing style guide for: %s", language)
|
|
276
319
|
|
|
320
|
+
# A guide runs to hundreds of kilobytes, so a caller that wants a few
|
|
321
|
+
# rules is better served searching the copy already on disk than
|
|
322
|
+
# reading the whole thing or writing out a second one.
|
|
323
|
+
if show_path:
|
|
324
|
+
_echo_guide_path(language)
|
|
325
|
+
return
|
|
326
|
+
|
|
277
327
|
try:
|
|
278
328
|
# Fetch and process the style guide
|
|
279
329
|
markdown_content = get_guide(language, remote=remote)
|
|
@@ -151,6 +151,52 @@ def test_cli_output_file(mock_guide: MagicMock, tmp_path: Path) -> None:
|
|
|
151
151
|
assert output_file.read_text() == "# Style Guide"
|
|
152
152
|
|
|
153
153
|
|
|
154
|
+
def test_cli_path_prints_the_location(tmp_path: Path, monkeypatch) -> None:
|
|
155
|
+
"""Tests that --path reports where the guide already lives on disk.
|
|
156
|
+
|
|
157
|
+
Guides ship with the package, so a caller wanting to search one needs
|
|
158
|
+
its location, not another copy of its contents.
|
|
159
|
+
"""
|
|
160
|
+
monkeypatch.setenv("READABILITY_CACHE", str(tmp_path))
|
|
161
|
+
(tmp_path / "pyguide.md").write_text("# Style Guide")
|
|
162
|
+
|
|
163
|
+
runner = CliRunner()
|
|
164
|
+
result = runner.invoke(cli, ["guide", "python", "--path"])
|
|
165
|
+
|
|
166
|
+
assert result.exit_code == 0
|
|
167
|
+
assert result.output.strip() == str(tmp_path / "pyguide.md")
|
|
168
|
+
assert "# Style Guide" not in result.output
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def test_cli_path_reports_a_guide_not_yet_fetched(
|
|
172
|
+
tmp_path: Path, monkeypatch
|
|
173
|
+
) -> None:
|
|
174
|
+
"""Tests that a missing local guide fails instead of naming a phantom.
|
|
175
|
+
|
|
176
|
+
Printing a path to a file that is not there would send the caller to
|
|
177
|
+
read nothing at all.
|
|
178
|
+
"""
|
|
179
|
+
monkeypatch.setenv("READABILITY_CACHE", str(tmp_path))
|
|
180
|
+
|
|
181
|
+
runner = CliRunner()
|
|
182
|
+
result = runner.invoke(cli, ["guide", "python", "--path"])
|
|
183
|
+
|
|
184
|
+
assert result.exit_code == 1
|
|
185
|
+
assert "sync" in result.output
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def test_cli_path_rejects_an_unsupported_language(
|
|
189
|
+
tmp_path: Path, monkeypatch
|
|
190
|
+
) -> None:
|
|
191
|
+
"""Tests that --path validates the language like the default path does."""
|
|
192
|
+
monkeypatch.setenv("READABILITY_CACHE", str(tmp_path))
|
|
193
|
+
|
|
194
|
+
runner = CliRunner()
|
|
195
|
+
result = runner.invoke(cli, ["guide", "nonexistent", "--path"])
|
|
196
|
+
|
|
197
|
+
assert result.exit_code == 1
|
|
198
|
+
|
|
199
|
+
|
|
154
200
|
@patch("readability.get_guide")
|
|
155
201
|
def test_cli_verbose(mock_guide: MagicMock) -> None:
|
|
156
202
|
"""Tests CLI with verbose flag.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|