readability-cli 0.10.5__tar.gz → 0.10.6__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 (41) hide show
  1. {readability_cli-0.10.5 → readability_cli-0.10.6}/PKG-INFO +1 -2
  2. {readability_cli-0.10.5 → readability_cli-0.10.6}/pyproject.toml +1 -2
  3. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guide.py +13 -72
  4. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guides/Rguide.md +36 -13
  5. readability_cli-0.10.6/readability/guides/cppguide.md +5403 -0
  6. readability_cli-0.10.5/readability/guides/csharp-style.md → readability_cli-0.10.6/readability/guides/csharpguide.md +127 -31
  7. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guides/docguide-style.md +46 -77
  8. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guides/htmlcssguide.md +473 -100
  9. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guides/javaguide.md +32 -16
  10. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guides/jsguide.md +1261 -489
  11. readability_cli-0.10.6/readability/guides/jsoncguide.md +1602 -0
  12. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guides/objcguide.md +357 -300
  13. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guides/pyguide.md +771 -381
  14. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guides/shellguide.md +241 -149
  15. readability_cli-0.10.6/readability/guides/vimscriptguide.md +304 -0
  16. {readability_cli-0.10.5 → readability_cli-0.10.6}/test_guide.py +0 -7
  17. {readability_cli-0.10.5 → readability_cli-0.10.6}/uv.lock +1 -3
  18. readability_cli-0.10.5/readability/guides/cppguide.md +0 -5713
  19. readability_cli-0.10.5/readability/guides/jsoncstyleguide.md +0 -1376
  20. readability_cli-0.10.5/readability/guides/vimscriptguide.md +0 -356
  21. {readability_cli-0.10.5 → readability_cli-0.10.6}/.github/workflows/ci.yml +0 -0
  22. {readability_cli-0.10.5 → readability_cli-0.10.6}/.github/workflows/publish.yml +0 -0
  23. {readability_cli-0.10.5 → readability_cli-0.10.6}/.github/workflows/update-guides.yml +0 -0
  24. {readability_cli-0.10.5 → readability_cli-0.10.6}/.gitignore +0 -0
  25. {readability_cli-0.10.5 → readability_cli-0.10.6}/.python-version +0 -0
  26. {readability_cli-0.10.5 → readability_cli-0.10.6}/LICENSE +0 -0
  27. {readability_cli-0.10.5 → readability_cli-0.10.6}/README.md +0 -0
  28. {readability_cli-0.10.5 → readability_cli-0.10.6}/biome.json +0 -0
  29. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/__init__.py +0 -0
  30. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/checking.py +0 -0
  31. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/cli.py +0 -0
  32. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/configs/biome-default.json +0 -0
  33. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/configs/pyrefly.toml +0 -0
  34. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/configs/ruff.toml +0 -0
  35. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guides/go-guide.md +0 -0
  36. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/guides/tsguide.md +0 -0
  37. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/outline.py +0 -0
  38. {readability_cli-0.10.5 → readability_cli-0.10.6}/readability/tools.py +0 -0
  39. {readability_cli-0.10.5 → readability_cli-0.10.6}/test_checking.py +0 -0
  40. {readability_cli-0.10.5 → readability_cli-0.10.6}/test_outline.py +0 -0
  41. {readability_cli-0.10.5 → readability_cli-0.10.6}/test_package.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: readability-cli
3
- Version: 0.10.5
3
+ Version: 0.10.6
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "readability-cli"
3
- version = "0.10.5"
3
+ version = "0.10.6"
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, bs4, and markdownify modules.
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
- warnings.filterwarnings("ignore", category=bs4.XMLParsedAsHTMLWarning)
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": "csharp-style.md",
64
- "c#": "csharp-style.md",
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.html",
72
- "javascript": "jsguide.html",
66
+ "js": "jsguide.md",
67
+ "javascript": "jsguide.md",
73
68
  "ts": "tsguide.html",
74
69
  "typescript": "tsguide.html",
75
- "html": "htmlcssguide.html",
76
- "css": "htmlcssguide.html",
77
- "json": "jsoncstyleguide.xml",
78
- "vim": "vimscriptguide.xml",
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, _, _ = load_sync_deps()
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
- _, bs4, markdownify = load_sync_deps()
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
- # Good
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
- # Good
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
- # Bad
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
- # Good
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
- # Bad
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
- # Good
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
- `grDevices`, `graphics`, `stats` and `methods`. If needed, you can `@import`
99
- the full package.
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.