readability-cli 0.10.5__tar.gz → 0.10.7__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.10.5 → readability_cli-0.10.7}/PKG-INFO +9 -4
- {readability_cli-0.10.5 → readability_cli-0.10.7}/README.md +8 -2
- {readability_cli-0.10.5 → readability_cli-0.10.7}/pyproject.toml +1 -2
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guide.py +13 -72
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guides/Rguide.md +36 -13
- readability_cli-0.10.7/readability/guides/cppguide.md +5403 -0
- readability_cli-0.10.5/readability/guides/csharp-style.md → readability_cli-0.10.7/readability/guides/csharpguide.md +127 -31
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guides/docguide-style.md +46 -77
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guides/htmlcssguide.md +473 -100
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guides/javaguide.md +32 -16
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guides/jsguide.md +1261 -489
- readability_cli-0.10.7/readability/guides/jsoncguide.md +1602 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guides/objcguide.md +357 -300
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guides/pyguide.md +771 -381
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guides/shellguide.md +241 -149
- readability_cli-0.10.7/readability/guides/vimscriptguide.md +304 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/tools.py +2 -1
- {readability_cli-0.10.5 → readability_cli-0.10.7}/test_checking.py +4 -1
- {readability_cli-0.10.5 → readability_cli-0.10.7}/test_guide.py +0 -7
- {readability_cli-0.10.5 → readability_cli-0.10.7}/uv.lock +1 -3
- readability_cli-0.10.5/readability/guides/cppguide.md +0 -5713
- readability_cli-0.10.5/readability/guides/jsoncstyleguide.md +0 -1376
- readability_cli-0.10.5/readability/guides/vimscriptguide.md +0 -356
- {readability_cli-0.10.5 → readability_cli-0.10.7}/.github/workflows/ci.yml +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/.github/workflows/publish.yml +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/.github/workflows/update-guides.yml +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/.gitignore +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/.python-version +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/LICENSE +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/biome.json +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/__init__.py +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/checking.py +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/cli.py +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/configs/biome-default.json +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/configs/pyrefly.toml +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/configs/ruff.toml +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guides/go-guide.md +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/guides/tsguide.md +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/readability/outline.py +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/test_outline.py +0 -0
- {readability_cli-0.10.5 → readability_cli-0.10.7}/test_package.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: readability-cli
|
|
3
|
-
Version: 0.10.
|
|
3
|
+
Version: 0.10.7
|
|
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
|
|
@@ -8,7 +8,6 @@ License-File: LICENSE
|
|
|
8
8
|
Requires-Python: >=3.12
|
|
9
9
|
Requires-Dist: click>=8.3.1
|
|
10
10
|
Provides-Extra: sync
|
|
11
|
-
Requires-Dist: beautifulsoup4>=4.14.3; extra == 'sync'
|
|
12
11
|
Requires-Dist: markdownify>=1.2.2; extra == 'sync'
|
|
13
12
|
Requires-Dist: requests>=2.33.0; extra == 'sync'
|
|
14
13
|
Description-Content-Type: text/markdown
|
|
@@ -133,6 +132,12 @@ to Ruff's — which has published seventeen minor series, roughly one every six
|
|
|
133
132
|
weeks. If you need a fixed version, install it: an installed tool always wins
|
|
134
133
|
over a fetched one.
|
|
135
134
|
|
|
135
|
+
Biome is the temporary exception, pinned to 2.5.14: from 2.5.15 it panics
|
|
136
|
+
(`path is expected to be under the root`) when the bundled config sits outside
|
|
137
|
+
the repository being checked, which is every project without its own
|
|
138
|
+
`biome.json` ([biomejs/biome#12158](https://github.com/biomejs/biome/issues/12158)).
|
|
139
|
+
The pin goes once upstream fixes it.
|
|
140
|
+
|
|
136
141
|
Set `UV_OFFLINE=1` to forbid fetching. A tool that then cannot be reached fails
|
|
137
142
|
the run rather than passing it.
|
|
138
143
|
|
|
@@ -205,8 +210,8 @@ For Python, add `[tool.ruff]` or `[tool.pyrefly]` to `pyproject.toml`, or use
|
|
|
205
210
|
their native project configurations in place of bundled defaults. Readability
|
|
206
211
|
does not interpret EditorConfig itself; a canonical tool such as Biome may opt
|
|
207
212
|
into it through that tool's native configuration. Neither gofmt nor goimports
|
|
208
|
-
has project settings. The bundled Biome file requires Biome 2.5 or later
|
|
209
|
-
|
|
213
|
+
has project settings. The bundled Biome file requires Biome 2.5 or later; the
|
|
214
|
+
fallback runner is pinned to 2.5.14 for now.
|
|
210
215
|
|
|
211
216
|
Configuration is found per file, in the file's own directory and then its
|
|
212
217
|
ancestors, which is where each canonical tool looks. A package keeping its
|
|
@@ -118,6 +118,12 @@ to Ruff's — which has published seventeen minor series, roughly one every six
|
|
|
118
118
|
weeks. If you need a fixed version, install it: an installed tool always wins
|
|
119
119
|
over a fetched one.
|
|
120
120
|
|
|
121
|
+
Biome is the temporary exception, pinned to 2.5.14: from 2.5.15 it panics
|
|
122
|
+
(`path is expected to be under the root`) when the bundled config sits outside
|
|
123
|
+
the repository being checked, which is every project without its own
|
|
124
|
+
`biome.json` ([biomejs/biome#12158](https://github.com/biomejs/biome/issues/12158)).
|
|
125
|
+
The pin goes once upstream fixes it.
|
|
126
|
+
|
|
121
127
|
Set `UV_OFFLINE=1` to forbid fetching. A tool that then cannot be reached fails
|
|
122
128
|
the run rather than passing it.
|
|
123
129
|
|
|
@@ -190,8 +196,8 @@ For Python, add `[tool.ruff]` or `[tool.pyrefly]` to `pyproject.toml`, or use
|
|
|
190
196
|
their native project configurations in place of bundled defaults. Readability
|
|
191
197
|
does not interpret EditorConfig itself; a canonical tool such as Biome may opt
|
|
192
198
|
into it through that tool's native configuration. Neither gofmt nor goimports
|
|
193
|
-
has project settings. The bundled Biome file requires Biome 2.5 or later
|
|
194
|
-
|
|
199
|
+
has project settings. The bundled Biome file requires Biome 2.5 or later; the
|
|
200
|
+
fallback runner is pinned to 2.5.14 for now.
|
|
195
201
|
|
|
196
202
|
Configuration is found per file, in the file's own directory and then its
|
|
197
203
|
ancestors, which is where each canonical tool looks. A package keeping its
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "readability-cli"
|
|
3
|
-
version = "0.10.
|
|
3
|
+
version = "0.10.7"
|
|
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"
|
|
@@ -11,7 +11,6 @@ dependencies = [
|
|
|
11
11
|
# Only `sync` fetches and converts guides; the rest reads bundled copies.
|
|
12
12
|
[project.optional-dependencies]
|
|
13
13
|
sync = [
|
|
14
|
-
"beautifulsoup4>=4.14.3",
|
|
15
14
|
"markdownify>=1.2.2",
|
|
16
15
|
"requests>=2.33.0",
|
|
17
16
|
]
|
|
@@ -5,7 +5,6 @@ from importlib.resources import files
|
|
|
5
5
|
import logging
|
|
6
6
|
import os
|
|
7
7
|
import types
|
|
8
|
-
import warnings
|
|
9
8
|
|
|
10
9
|
import click
|
|
11
10
|
|
|
@@ -13,22 +12,19 @@ logger = logging.getLogger("readability")
|
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
@functools.cache
|
|
16
|
-
def load_sync_deps() -> tuple[
|
|
17
|
-
types.ModuleType, types.ModuleType, types.ModuleType
|
|
18
|
-
]:
|
|
15
|
+
def load_sync_deps() -> tuple[types.ModuleType, types.ModuleType]:
|
|
19
16
|
"""Imports the libraries only the guide refresh needs.
|
|
20
17
|
|
|
21
18
|
Guides ship pre-converted, so this stack stays out of the default
|
|
22
19
|
install rather than charging every user for `sync`.
|
|
23
20
|
|
|
24
21
|
Returns:
|
|
25
|
-
The requests
|
|
22
|
+
The requests and markdownify modules.
|
|
26
23
|
|
|
27
24
|
Raises:
|
|
28
25
|
click.ClickException: If the sync extra is not installed.
|
|
29
26
|
"""
|
|
30
27
|
try:
|
|
31
|
-
import bs4 # noqa: PLC0415
|
|
32
28
|
import markdownify # noqa: PLC0415
|
|
33
29
|
import requests # noqa: PLC0415
|
|
34
30
|
except ImportError as e:
|
|
@@ -37,8 +33,7 @@ def load_sync_deps() -> tuple[
|
|
|
37
33
|
"with: pip install 'readability-cli[sync]'"
|
|
38
34
|
) from e
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
return requests, bs4, markdownify
|
|
36
|
+
return requests, markdownify
|
|
42
37
|
|
|
43
38
|
|
|
44
39
|
def get_guides_dir() -> str:
|
|
@@ -60,22 +55,22 @@ LANGUAGE_MAP = {
|
|
|
60
55
|
"objc": "objcguide.md",
|
|
61
56
|
"objective-c": "objcguide.md",
|
|
62
57
|
"r": "Rguide.md",
|
|
63
|
-
"csharp": "
|
|
64
|
-
"c#": "
|
|
58
|
+
"csharp": "csharpguide.md",
|
|
59
|
+
"c#": "csharpguide.md",
|
|
65
60
|
"docguide": "docguide/style.md",
|
|
66
61
|
"markdown": "docguide/style.md",
|
|
67
62
|
"go": "go/guide.md",
|
|
68
63
|
"cpp": "cppguide.html",
|
|
69
64
|
"c++": "cppguide.html",
|
|
70
65
|
"java": "javaguide.html",
|
|
71
|
-
"js": "jsguide.
|
|
72
|
-
"javascript": "jsguide.
|
|
66
|
+
"js": "jsguide.md",
|
|
67
|
+
"javascript": "jsguide.md",
|
|
73
68
|
"ts": "tsguide.html",
|
|
74
69
|
"typescript": "tsguide.html",
|
|
75
|
-
"html": "htmlcssguide.
|
|
76
|
-
"css": "htmlcssguide.
|
|
77
|
-
"json": "
|
|
78
|
-
"vim": "vimscriptguide.
|
|
70
|
+
"html": "htmlcssguide.md",
|
|
71
|
+
"css": "htmlcssguide.md",
|
|
72
|
+
"json": "jsoncguide.md",
|
|
73
|
+
"vim": "vimscriptguide.md",
|
|
79
74
|
}
|
|
80
75
|
|
|
81
76
|
BASE_URL = "https://google.github.io/styleguide/"
|
|
@@ -96,7 +91,7 @@ def get_guide_content(url: str) -> str:
|
|
|
96
91
|
Raises:
|
|
97
92
|
click.ClickException: If the HTTP request fails.
|
|
98
93
|
"""
|
|
99
|
-
requests, _
|
|
94
|
+
requests, _ = load_sync_deps()
|
|
100
95
|
logger.info("Fetching style guide from %s", url)
|
|
101
96
|
|
|
102
97
|
try:
|
|
@@ -121,66 +116,12 @@ def convert_to_markdown(content: str, filename: str) -> str:
|
|
|
121
116
|
Returns:
|
|
122
117
|
The converted markdown content.
|
|
123
118
|
"""
|
|
124
|
-
_,
|
|
119
|
+
_, markdownify = load_sync_deps()
|
|
125
120
|
logger.debug("Converting content for %s", filename)
|
|
126
121
|
|
|
127
122
|
if filename.endswith(".md"):
|
|
128
123
|
return content
|
|
129
124
|
|
|
130
|
-
# Strip XML prologue if present to avoid it leaking into the output
|
|
131
|
-
if content.lstrip().startswith("<?xml"):
|
|
132
|
-
content = content.split("?>", 1)[-1].lstrip()
|
|
133
|
-
|
|
134
|
-
# The Vim script and JSON guides are only published as XML
|
|
135
|
-
if filename.endswith(".xml"):
|
|
136
|
-
soup = bs4.BeautifulSoup(content, "html.parser")
|
|
137
|
-
|
|
138
|
-
guide = soup.find("guide")
|
|
139
|
-
if guide:
|
|
140
|
-
title = guide.get("title")
|
|
141
|
-
if isinstance(title, str) and title:
|
|
142
|
-
h1 = soup.new_tag("h1")
|
|
143
|
-
h1.string = title
|
|
144
|
-
guide.insert(0, h1)
|
|
145
|
-
|
|
146
|
-
for category in soup.find_all("category"):
|
|
147
|
-
title = category.get("title")
|
|
148
|
-
if isinstance(title, str) and title:
|
|
149
|
-
h2 = soup.new_tag("h2")
|
|
150
|
-
h2.string = title
|
|
151
|
-
category.insert(0, h2)
|
|
152
|
-
|
|
153
|
-
for sp in soup.find_all("stylepoint"):
|
|
154
|
-
title = sp.get("title")
|
|
155
|
-
if isinstance(title, str) and title:
|
|
156
|
-
h3 = soup.new_tag("h3")
|
|
157
|
-
h3.string = title
|
|
158
|
-
sp.insert(0, h3)
|
|
159
|
-
|
|
160
|
-
for summary in soup.find_all("summary"):
|
|
161
|
-
summary.name = "p"
|
|
162
|
-
content_str = summary.decode_contents()
|
|
163
|
-
summary.clear()
|
|
164
|
-
strong = soup.new_tag("strong")
|
|
165
|
-
strong.append(bs4.BeautifulSoup(content_str, "html.parser"))
|
|
166
|
-
summary.append(strong)
|
|
167
|
-
|
|
168
|
-
for snippet in soup.find_all(["code_snippet", "bad_code_snippet"]):
|
|
169
|
-
is_bad = snippet.name == "bad_code_snippet"
|
|
170
|
-
snippet.name = "pre"
|
|
171
|
-
code = soup.new_tag("code")
|
|
172
|
-
code.string = snippet.get_text()
|
|
173
|
-
snippet.clear()
|
|
174
|
-
if is_bad:
|
|
175
|
-
p = soup.new_tag("p")
|
|
176
|
-
strong = soup.new_tag("strong")
|
|
177
|
-
strong.string = "BAD:"
|
|
178
|
-
p.append(strong)
|
|
179
|
-
snippet.append(p)
|
|
180
|
-
snippet.append(code)
|
|
181
|
-
|
|
182
|
-
return markdownify.markdownify(str(soup), **MARKDOWNIFY_OPTIONS)
|
|
183
|
-
|
|
184
125
|
if filename.endswith(".html"):
|
|
185
126
|
return markdownify.markdownify(content, **MARKDOWNIFY_OPTIONS)
|
|
186
127
|
|
|
@@ -11,6 +11,15 @@ were developed in collaboration with the internal R user community. The rest of
|
|
|
11
11
|
this document explains Google's primary differences with the Tidyverse guide,
|
|
12
12
|
and why these differences exist.
|
|
13
13
|
|
|
14
|
+
Google uses the [styler](https://github.com/r-lib/styler) package on every
|
|
15
|
+
checked in file to ensure code consistency and help reviewers focus on more
|
|
16
|
+
important issues.
|
|
17
|
+
|
|
18
|
+
<!-- mdformat off -->
|
|
19
|
+
* TOC
|
|
20
|
+
{:toc}
|
|
21
|
+
<!-- mdformat on -->
|
|
22
|
+
|
|
14
23
|
## Syntax
|
|
15
24
|
|
|
16
25
|
### Naming conventions
|
|
@@ -18,8 +27,9 @@ and why these differences exist.
|
|
|
18
27
|
Google prefers identifying functions with `BigCamelCase` to clearly distinguish
|
|
19
28
|
them from other objects.
|
|
20
29
|
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
<div class='goodcode'></div>
|
|
31
|
+
|
|
32
|
+
```r
|
|
23
33
|
DoNothing <- function() {
|
|
24
34
|
return(invisible(NULL))
|
|
25
35
|
}
|
|
@@ -28,8 +38,9 @@ DoNothing <- function() {
|
|
|
28
38
|
The names of private functions should begin with a dot. This helps communicate
|
|
29
39
|
both the origin of the function and its intended use.
|
|
30
40
|
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
<div class='goodcode'></div>
|
|
42
|
+
|
|
43
|
+
```r
|
|
33
44
|
.DoNothingPrivately <- function() {
|
|
34
45
|
return(invisible(NULL))
|
|
35
46
|
}
|
|
@@ -48,8 +59,9 @@ The possibilities for creating errors when using `attach()` are numerous.
|
|
|
48
59
|
|
|
49
60
|
We do not support using right-hand assignment.
|
|
50
61
|
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
<div class='badcode'></div>
|
|
63
|
+
|
|
64
|
+
```r
|
|
53
65
|
iris %>%
|
|
54
66
|
dplyr::summarize(max_petal = max(Petal.Width)) -> results
|
|
55
67
|
```
|
|
@@ -64,13 +76,17 @@ lines).
|
|
|
64
76
|
Do not rely on R's implicit return feature. It is better to be clear about your
|
|
65
77
|
intent to `return()` an object.
|
|
66
78
|
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
<div class='goodcode'></div>
|
|
80
|
+
|
|
81
|
+
```r
|
|
69
82
|
AddValues <- function(x, y) {
|
|
70
83
|
return(x + y)
|
|
71
84
|
}
|
|
85
|
+
```
|
|
72
86
|
|
|
73
|
-
|
|
87
|
+
<div class='badcode'></div>
|
|
88
|
+
|
|
89
|
+
```r
|
|
74
90
|
AddValues <- function(x, y) {
|
|
75
91
|
x + y
|
|
76
92
|
}
|
|
@@ -80,8 +96,9 @@ AddValues <- function(x, y) {
|
|
|
80
96
|
|
|
81
97
|
Users should explicitly qualify namespaces for all external functions.
|
|
82
98
|
|
|
83
|
-
|
|
84
|
-
|
|
99
|
+
<div class='goodcode'></div>
|
|
100
|
+
|
|
101
|
+
```r
|
|
85
102
|
purrr::map()
|
|
86
103
|
```
|
|
87
104
|
|
|
@@ -95,8 +112,8 @@ understand dependencies in your code. There are some exceptions to this rule.
|
|
|
95
112
|
* Infix functions (`%name%`) always need to be imported.
|
|
96
113
|
* Certain `rlang` pronouns, notably `.data`, need to be imported.
|
|
97
114
|
* Functions from default R packages, including `datasets`, `utils`,
|
|
98
|
-
|
|
99
|
-
|
|
115
|
+
`grDevices`, `graphics`, `stats` and `methods`. If needed, you can `@import`
|
|
116
|
+
the full package.
|
|
100
117
|
|
|
101
118
|
When importing functions, place the `@importFrom` tag in the Roxygen header
|
|
102
119
|
above the function where the external dependency is used.
|
|
@@ -107,3 +124,9 @@ above the function where the external dependency is used.
|
|
|
107
124
|
|
|
108
125
|
All packages should have a package documentation file, in a
|
|
109
126
|
`packagename-package.R` file.
|
|
127
|
+
|
|
128
|
+
## Errors
|
|
129
|
+
|
|
130
|
+
### Use of bullets
|
|
131
|
+
|
|
132
|
+
We prefer ASCII style bullets (`*`) to unicode when producing error messages.
|