readability-cli 0.4.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.4.0/.github/workflows/ci.yml +31 -0
- readability_cli-0.4.0/.github/workflows/publish.yml +26 -0
- readability_cli-0.4.0/.github/workflows/update-guides.yml +33 -0
- readability_cli-0.4.0/.gitignore +152 -0
- readability_cli-0.4.0/.python-version +1 -0
- readability_cli-0.4.0/LICENSE +21 -0
- readability_cli-0.4.0/PKG-INFO +192 -0
- readability_cli-0.4.0/README.md +178 -0
- readability_cli-0.4.0/configs/pyrefly.toml +11 -0
- readability_cli-0.4.0/configs/ruff.toml +20 -0
- readability_cli-0.4.0/guides/Rguide.md +109 -0
- readability_cli-0.4.0/guides/cppguide.md +5713 -0
- readability_cli-0.4.0/guides/csharp-style.md +478 -0
- readability_cli-0.4.0/guides/docguide-style.md +845 -0
- readability_cli-0.4.0/guides/go-guide.md +483 -0
- readability_cli-0.4.0/guides/htmlcssguide.md +1022 -0
- readability_cli-0.4.0/guides/javaguide.md +1189 -0
- readability_cli-0.4.0/guides/jsguide.md +3775 -0
- readability_cli-0.4.0/guides/jsoncstyleguide.md +1376 -0
- readability_cli-0.4.0/guides/objcguide.md +2386 -0
- readability_cli-0.4.0/guides/pyguide.md +3709 -0
- readability_cli-0.4.0/guides/shellguide.md +1343 -0
- readability_cli-0.4.0/guides/tsguide.md +3662 -0
- readability_cli-0.4.0/guides/vimscriptguide.md +356 -0
- readability_cli-0.4.0/pyproject.toml +56 -0
- readability_cli-0.4.0/readability.py +755 -0
- readability_cli-0.4.0/test_readability.py +561 -0
- readability_cli-0.4.0/uv.lock +300 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint-and-test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v6
|
|
15
|
+
|
|
16
|
+
- name: Set up Python
|
|
17
|
+
uses: astral-sh/setup-uv@v7
|
|
18
|
+
with:
|
|
19
|
+
python-version: '3.14'
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: uv sync
|
|
23
|
+
|
|
24
|
+
- name: Run linting
|
|
25
|
+
run: uv run ruff check .
|
|
26
|
+
|
|
27
|
+
- name: Run formatting check
|
|
28
|
+
run: uv run ruff format --check .
|
|
29
|
+
|
|
30
|
+
- name: Run tests
|
|
31
|
+
run: uv run pytest
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ['v*']
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment: pypi
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v6
|
|
16
|
+
|
|
17
|
+
- name: Set up Python
|
|
18
|
+
uses: astral-sh/setup-uv@v7
|
|
19
|
+
with:
|
|
20
|
+
python-version: '3.14'
|
|
21
|
+
|
|
22
|
+
- name: Build distribution
|
|
23
|
+
run: uv build
|
|
24
|
+
|
|
25
|
+
- name: Publish to PyPI
|
|
26
|
+
run: uv publish --trusted-publishing always
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Update Style Guides
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
schedule:
|
|
5
|
+
- cron: '0 0 * * 0' # Weekly on Sunday at midnight
|
|
6
|
+
workflow_dispatch: # Ad-hoc trigger
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
update-guides:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Install uv
|
|
17
|
+
uses: astral-sh/setup-uv@v5
|
|
18
|
+
with:
|
|
19
|
+
version: "latest"
|
|
20
|
+
|
|
21
|
+
- name: Set up Python
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version-file: ".python-version"
|
|
25
|
+
|
|
26
|
+
- name: Sync guides
|
|
27
|
+
run: uv run readability sync --verbose
|
|
28
|
+
|
|
29
|
+
- name: Commit and push changes
|
|
30
|
+
uses: stefanzweifel/git-auto-commit-action@v5
|
|
31
|
+
with:
|
|
32
|
+
commit_message: "chore: update style guides [skip ci]"
|
|
33
|
+
file_pattern: 'guides/*.md'
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so may be deleted later.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
pytestdebug.log
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore it in the repository,
|
|
87
|
+
# but for a top-level application, you might want to keep it.
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, Pipfile.lock might cause issues.
|
|
94
|
+
#Pipfile.lock
|
|
95
|
+
|
|
96
|
+
# poetry
|
|
97
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
98
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
99
|
+
#poetry.lock
|
|
100
|
+
|
|
101
|
+
# pdm
|
|
102
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
103
|
+
#pdm.lock
|
|
104
|
+
|
|
105
|
+
# PEP 582; used by e.g. github.com/pdm-project/pdm
|
|
106
|
+
__pypackages__/
|
|
107
|
+
|
|
108
|
+
# Celery stuff
|
|
109
|
+
celerybeat-schedule
|
|
110
|
+
celerybeat.pid
|
|
111
|
+
|
|
112
|
+
# SageMath parsed files
|
|
113
|
+
*.sage.py
|
|
114
|
+
|
|
115
|
+
# Environments
|
|
116
|
+
.env
|
|
117
|
+
.venv
|
|
118
|
+
env/
|
|
119
|
+
venv/
|
|
120
|
+
ENV/
|
|
121
|
+
env.bak/
|
|
122
|
+
venv.bak/
|
|
123
|
+
|
|
124
|
+
# Spyder project settings
|
|
125
|
+
.spyderproject
|
|
126
|
+
.spyproject
|
|
127
|
+
|
|
128
|
+
# Rope project settings
|
|
129
|
+
.ropeproject
|
|
130
|
+
|
|
131
|
+
# mkdocs documentation
|
|
132
|
+
/site
|
|
133
|
+
|
|
134
|
+
# mypy
|
|
135
|
+
.mypy_cache/
|
|
136
|
+
.dmypy.json
|
|
137
|
+
dmypy.json
|
|
138
|
+
|
|
139
|
+
# Pyre type checker
|
|
140
|
+
.pyre/
|
|
141
|
+
|
|
142
|
+
# pytype static type analyzer
|
|
143
|
+
.pytype/
|
|
144
|
+
|
|
145
|
+
# Cython debug symbols
|
|
146
|
+
cython_debug/
|
|
147
|
+
|
|
148
|
+
# PyCharm
|
|
149
|
+
.idea/
|
|
150
|
+
|
|
151
|
+
# Ruff
|
|
152
|
+
.ruff_cache/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 owahltinez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: readability-cli
|
|
3
|
+
Version: 0.4.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
|
+
- **Offline Mode**: Local caching of style guides for fast, offline access,
|
|
32
|
+
kept fresh with a single `sync` command.
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
You can run the tool directly without installing it using `uvx`:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Check and fix formatting for the current directory
|
|
40
|
+
uvx --from git+https://github.com/owahltinez/readability.git readability check . --fix
|
|
41
|
+
|
|
42
|
+
# Get the Python style guide
|
|
43
|
+
uvx --from git+https://github.com/owahltinez/readability.git readability guide python
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
Install it as a global tool with `uv`:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Install the readability tool
|
|
52
|
+
uv tool install git+https://github.com/owahltinez/readability.git
|
|
53
|
+
|
|
54
|
+
# Use it anywhere
|
|
55
|
+
readability check .
|
|
56
|
+
readability guide python
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### For Development
|
|
60
|
+
|
|
61
|
+
This project uses `uv` for dependency management:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Clone the repository
|
|
65
|
+
git clone https://github.com/owahltinez/readability.git
|
|
66
|
+
cd readability
|
|
67
|
+
|
|
68
|
+
# Install dependencies and create a virtual environment
|
|
69
|
+
uv sync
|
|
70
|
+
|
|
71
|
+
# (Optional) Populate the local cache for offline use
|
|
72
|
+
uv run readability sync
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Checking and Formatting
|
|
76
|
+
|
|
77
|
+
The `check` command identifies and runs relevant linting and formatting tools
|
|
78
|
+
based on file extensions and the presence of configuration files (triggers) in
|
|
79
|
+
your project root:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Run checks on the current directory
|
|
83
|
+
readability check .
|
|
84
|
+
|
|
85
|
+
# Check specific files or directories
|
|
86
|
+
readability check src/ tests/ main.py
|
|
87
|
+
|
|
88
|
+
# Automatically fix and format files
|
|
89
|
+
readability check . --fix
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Supported Tools
|
|
93
|
+
|
|
94
|
+
| Tool | Supported Extensions | Trigger Files |
|
|
95
|
+
|------|----------------------|---------------|
|
|
96
|
+
| **Ruff** | `.py` | `pyproject.toml`, `ruff.toml`, `.ruff.toml` |
|
|
97
|
+
| **Pyrefly** | `.py` | `pyproject.toml`, `pyrefly.toml` |
|
|
98
|
+
| **Biome** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.jsonc`, `.css`, `.html` | `biome.json`, `biome.jsonc` |
|
|
99
|
+
| **Prettier** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.css`, `.scss`, `.html`, `.md`, `.yml`, `.yaml` | `.prettierrc*`, `prettier.config.*` |
|
|
100
|
+
| **gofmt** | `.go` | `go.mod` |
|
|
101
|
+
|
|
102
|
+
The command will only run a tool if its trigger file exists in the current
|
|
103
|
+
working directory and the tool is available in your `PATH`. For `biome` and
|
|
104
|
+
`prettier`, it attempts to run them via `npx`.
|
|
105
|
+
|
|
106
|
+
### Default Configurations
|
|
107
|
+
|
|
108
|
+
For Ruff and Pyrefly, bundled defaults based on the
|
|
109
|
+
[Google Python style guide](https://google.github.io/styleguide/pyguide.html)
|
|
110
|
+
(80-column lines, Google docstring convention, import ordering, full type
|
|
111
|
+
checking) are applied when the project does not define its own configuration.
|
|
112
|
+
To override them, add a `[tool.ruff]` or `[tool.pyrefly]` section to your
|
|
113
|
+
`pyproject.toml` (or a dedicated `ruff.toml` / `pyrefly.toml`) — any
|
|
114
|
+
project-level configuration takes full precedence over the bundled defaults.
|
|
115
|
+
|
|
116
|
+
## Style Guides
|
|
117
|
+
|
|
118
|
+
The `guide` command prints a Google style guide as Markdown, using the local
|
|
119
|
+
cache when available:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Get the Python style guide (uses local cache if available)
|
|
123
|
+
readability guide python
|
|
124
|
+
|
|
125
|
+
# Force fetching the latest version from the web
|
|
126
|
+
readability guide python --remote
|
|
127
|
+
|
|
128
|
+
# Save a style guide to a file
|
|
129
|
+
readability guide cpp --output cpp-style.md
|
|
130
|
+
|
|
131
|
+
# Synchronize all supported style guides to the local cache
|
|
132
|
+
readability sync
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Supported Languages
|
|
136
|
+
|
|
137
|
+
Use `readability languages` to see a full list of supported languages and
|
|
138
|
+
their aliases. This command also indicates which guides are currently
|
|
139
|
+
available in the local cache with a `[cached]` label:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
$ readability languages
|
|
143
|
+
Supported languages and their aliases:
|
|
144
|
+
- r [cached]
|
|
145
|
+
- c++, cpp [cached]
|
|
146
|
+
- c#, csharp [cached]
|
|
147
|
+
- docguide, markdown [cached]
|
|
148
|
+
- go [cached]
|
|
149
|
+
- css, html [cached]
|
|
150
|
+
- java [cached]
|
|
151
|
+
- javascript, js [cached]
|
|
152
|
+
- json [cached]
|
|
153
|
+
- objc, objective-c [cached]
|
|
154
|
+
- python [cached]
|
|
155
|
+
- shell [cached]
|
|
156
|
+
- ts, typescript [cached]
|
|
157
|
+
- vim [cached]
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Offline Mode
|
|
161
|
+
|
|
162
|
+
The tool stores local copies of the style guides in the `guides/` directory
|
|
163
|
+
and the `guide` command uses these local files when they exist. The bundled
|
|
164
|
+
copies are automatically synchronized weekly from the official
|
|
165
|
+
[Google Style Guides](https://google.github.io/styleguide/) repository via
|
|
166
|
+
GitHub Actions, and you can refresh your local cache at any time with the
|
|
167
|
+
`sync` command.
|
|
168
|
+
|
|
169
|
+
You can override the default `guides/` directory by setting the
|
|
170
|
+
`READABILITY_CACHE` environment variable. This is useful if you want to store
|
|
171
|
+
the guides in a specific location or share them across different
|
|
172
|
+
installations:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
export READABILITY_CACHE=/path/to/my/guides
|
|
176
|
+
readability guide python
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Development
|
|
180
|
+
|
|
181
|
+
Run tests with `pytest`:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
uv run pytest
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Check code style with `ruff`:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
uv run ruff check .
|
|
191
|
+
uv run ruff format .
|
|
192
|
+
```
|
|
@@ -0,0 +1,178 @@
|
|
|
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
|
+
- **Offline Mode**: Local caching of style guides for fast, offline access,
|
|
18
|
+
kept fresh with a single `sync` command.
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
You can run the tool directly without installing it using `uvx`:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Check and fix formatting for the current directory
|
|
26
|
+
uvx --from git+https://github.com/owahltinez/readability.git readability check . --fix
|
|
27
|
+
|
|
28
|
+
# Get the Python style guide
|
|
29
|
+
uvx --from git+https://github.com/owahltinez/readability.git readability guide python
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Install it as a global tool with `uv`:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Install the readability tool
|
|
38
|
+
uv tool install git+https://github.com/owahltinez/readability.git
|
|
39
|
+
|
|
40
|
+
# Use it anywhere
|
|
41
|
+
readability check .
|
|
42
|
+
readability guide python
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### For Development
|
|
46
|
+
|
|
47
|
+
This project uses `uv` for dependency management:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Clone the repository
|
|
51
|
+
git clone https://github.com/owahltinez/readability.git
|
|
52
|
+
cd readability
|
|
53
|
+
|
|
54
|
+
# Install dependencies and create a virtual environment
|
|
55
|
+
uv sync
|
|
56
|
+
|
|
57
|
+
# (Optional) Populate the local cache for offline use
|
|
58
|
+
uv run readability sync
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Checking and Formatting
|
|
62
|
+
|
|
63
|
+
The `check` command identifies and runs relevant linting and formatting tools
|
|
64
|
+
based on file extensions and the presence of configuration files (triggers) in
|
|
65
|
+
your project root:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Run checks on the current directory
|
|
69
|
+
readability check .
|
|
70
|
+
|
|
71
|
+
# Check specific files or directories
|
|
72
|
+
readability check src/ tests/ main.py
|
|
73
|
+
|
|
74
|
+
# Automatically fix and format files
|
|
75
|
+
readability check . --fix
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Supported Tools
|
|
79
|
+
|
|
80
|
+
| Tool | Supported Extensions | Trigger Files |
|
|
81
|
+
|------|----------------------|---------------|
|
|
82
|
+
| **Ruff** | `.py` | `pyproject.toml`, `ruff.toml`, `.ruff.toml` |
|
|
83
|
+
| **Pyrefly** | `.py` | `pyproject.toml`, `pyrefly.toml` |
|
|
84
|
+
| **Biome** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.jsonc`, `.css`, `.html` | `biome.json`, `biome.jsonc` |
|
|
85
|
+
| **Prettier** | `.js`, `.ts`, `.jsx`, `.tsx`, `.json`, `.css`, `.scss`, `.html`, `.md`, `.yml`, `.yaml` | `.prettierrc*`, `prettier.config.*` |
|
|
86
|
+
| **gofmt** | `.go` | `go.mod` |
|
|
87
|
+
|
|
88
|
+
The command will only run a tool if its trigger file exists in the current
|
|
89
|
+
working directory and the tool is available in your `PATH`. For `biome` and
|
|
90
|
+
`prettier`, it attempts to run them via `npx`.
|
|
91
|
+
|
|
92
|
+
### Default Configurations
|
|
93
|
+
|
|
94
|
+
For Ruff and Pyrefly, bundled defaults based on the
|
|
95
|
+
[Google Python style guide](https://google.github.io/styleguide/pyguide.html)
|
|
96
|
+
(80-column lines, Google docstring convention, import ordering, full type
|
|
97
|
+
checking) are applied when the project does not define its own configuration.
|
|
98
|
+
To override them, add a `[tool.ruff]` or `[tool.pyrefly]` section to your
|
|
99
|
+
`pyproject.toml` (or a dedicated `ruff.toml` / `pyrefly.toml`) — any
|
|
100
|
+
project-level configuration takes full precedence over the bundled defaults.
|
|
101
|
+
|
|
102
|
+
## Style Guides
|
|
103
|
+
|
|
104
|
+
The `guide` command prints a Google style guide as Markdown, using the local
|
|
105
|
+
cache when available:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Get the Python style guide (uses local cache if available)
|
|
109
|
+
readability guide python
|
|
110
|
+
|
|
111
|
+
# Force fetching the latest version from the web
|
|
112
|
+
readability guide python --remote
|
|
113
|
+
|
|
114
|
+
# Save a style guide to a file
|
|
115
|
+
readability guide cpp --output cpp-style.md
|
|
116
|
+
|
|
117
|
+
# Synchronize all supported style guides to the local cache
|
|
118
|
+
readability sync
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Supported Languages
|
|
122
|
+
|
|
123
|
+
Use `readability languages` to see a full list of supported languages and
|
|
124
|
+
their aliases. This command also indicates which guides are currently
|
|
125
|
+
available in the local cache with a `[cached]` label:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
$ readability languages
|
|
129
|
+
Supported languages and their aliases:
|
|
130
|
+
- r [cached]
|
|
131
|
+
- c++, cpp [cached]
|
|
132
|
+
- c#, csharp [cached]
|
|
133
|
+
- docguide, markdown [cached]
|
|
134
|
+
- go [cached]
|
|
135
|
+
- css, html [cached]
|
|
136
|
+
- java [cached]
|
|
137
|
+
- javascript, js [cached]
|
|
138
|
+
- json [cached]
|
|
139
|
+
- objc, objective-c [cached]
|
|
140
|
+
- python [cached]
|
|
141
|
+
- shell [cached]
|
|
142
|
+
- ts, typescript [cached]
|
|
143
|
+
- vim [cached]
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Offline Mode
|
|
147
|
+
|
|
148
|
+
The tool stores local copies of the style guides in the `guides/` directory
|
|
149
|
+
and the `guide` command uses these local files when they exist. The bundled
|
|
150
|
+
copies are automatically synchronized weekly from the official
|
|
151
|
+
[Google Style Guides](https://google.github.io/styleguide/) repository via
|
|
152
|
+
GitHub Actions, and you can refresh your local cache at any time with the
|
|
153
|
+
`sync` command.
|
|
154
|
+
|
|
155
|
+
You can override the default `guides/` directory by setting the
|
|
156
|
+
`READABILITY_CACHE` environment variable. This is useful if you want to store
|
|
157
|
+
the guides in a specific location or share them across different
|
|
158
|
+
installations:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
export READABILITY_CACHE=/path/to/my/guides
|
|
162
|
+
readability guide python
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Development
|
|
166
|
+
|
|
167
|
+
Run tests with `pytest`:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
uv run pytest
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Check code style with `ruff`:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
uv run ruff check .
|
|
177
|
+
uv run ruff format .
|
|
178
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Default configuration used by `readability check` when the target project
|
|
2
|
+
# does not define its own pyrefly settings (pyrefly.toml or [tool.pyrefly] in
|
|
3
|
+
# pyproject.toml). The presence of a config file switches pyrefly from its
|
|
4
|
+
# lenient "basic" preset to full type checking.
|
|
5
|
+
|
|
6
|
+
[errors]
|
|
7
|
+
# When this bundled config is used, pyrefly treats its directory as the
|
|
8
|
+
# project root, so imports local to the checked project cannot be resolved
|
|
9
|
+
# reliably; suppress those errors to avoid false positives
|
|
10
|
+
missing-import = false
|
|
11
|
+
missing-module-attribute = false
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Default configuration used by `readability check` when the target project
|
|
2
|
+
# does not define its own ruff settings (ruff.toml or [tool.ruff] in
|
|
3
|
+
# pyproject.toml). Based on the Google Python style guide:
|
|
4
|
+
# https://google.github.io/styleguide/pyguide.html
|
|
5
|
+
line-length = 80
|
|
6
|
+
|
|
7
|
+
[lint]
|
|
8
|
+
# Pycodestyle (E, W), Pyflakes (F), import order (I), naming (N),
|
|
9
|
+
# docstrings (D), and pylint (PL) rules
|
|
10
|
+
select = ["E", "W", "F", "I", "N", "D", "PL"]
|
|
11
|
+
# Complexity counters and magic-value warnings are guidance, not errors
|
|
12
|
+
ignore = ["PLR0911", "PLR0912", "PLR0913", "PLR0915", "PLR2004"]
|
|
13
|
+
|
|
14
|
+
[lint.pydocstyle]
|
|
15
|
+
convention = "google"
|
|
16
|
+
|
|
17
|
+
[lint.per-file-ignores]
|
|
18
|
+
# Docstring requirements are noise in test files
|
|
19
|
+
"test_*.py" = ["D"]
|
|
20
|
+
"*_test.py" = ["D"]
|