Skip to content

Commit d1ee4f5

Browse files
committed
docs: update docs
1 parent fbb7eb9 commit d1ee4f5

File tree

2 files changed

+79
-81
lines changed

2 files changed

+79
-81
lines changed

MIGRATION.md

Lines changed: 72 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,109 @@
1-
# Migration Guide: From clang-tools to Python Wheels
1+
# Migration: From Clang Tools Binaries to Python Wheels
22

33
## Overview
44

5-
Starting from version 0.9.0, `cpp-linter-hooks` has migrated from using the `clang-tools` package to using Python wheel packages for `clang-format` and `clang-tidy`. This change provides better cross-platform compatibility, easier installation, and more reliable dependency management.
5+
Starting from version **v1.0.0**, `cpp-linter-hooks` has migrated from using the `clang-tools` package to using Python wheel packages for `clang-format` and `clang-tidy`. This change provides:
6+
7+
- **Better cross-platform compatibility**
8+
- **Easier installation and dependency management**
9+
- **Improved performance and reliability**
10+
- **More predictable version management**
611

712
## What Changed
813

9-
### Dependencies
10-
- **Before**: Used `clang-tools==0.15.1` package
11-
- **After**: Uses `clang-format` and `clang-tidy` wheel packages from PyPI
14+
### Core Changes
1215

13-
### Installation Method
14-
- **Before**: clang-format and clang-tidy were installed via `clang-tools` package which managed binaries
15-
- **After**: clang-format and clang-tidy are installed as Python packages and available as executables
16+
| Aspect | Before (< v1.0.0) | After (≥ v1.0.0) |
17+
|--------|-------------------|-------------------|
18+
| **Installation** | `clang-tools` package (binary management) | Python wheel packages (`clang-format`, `clang-tidy`) |
19+
| **Distribution** | Single package for both tools | Separate packages for each tool |
20+
| **Version Control** | Limited version flexibility | Enhanced version management with pip |
21+
| **Performance** | Standard performance | Optimized wheel packages |
1622

17-
### Benefits of Migration
23+
### Implementation Details
1824

19-
1. **Better Cross-Platform Support**: Python wheels work consistently across different operating systems
20-
2. **Simplified Installation**: No need to manage binary installations separately
21-
3. **More Reliable**: No more issues with binary compatibility or single threaded execution
22-
4. **Better Version Management**: Each tool version is a separate package release
25+
- **Dependencies**: Updated to use separate `clang-format==20.1.7` and `clang-tidy==20.1.0` Python wheels
26+
- **Installation Logic**: Enhanced with pip-based installation and runtime version checks
27+
- **Performance**: Pre-commit hooks can now run in parallel for better speed
2328

2429
## Breaking Changes
2530

2631
### For End Users
2732

28-
- **No breaking changes**: The pre-commit hook configuration remains exactly the same
29-
- All existing `.pre-commit-config.yaml` files will continue to work without modification
33+
> **No breaking changes for end users**
3034
31-
### For Developers
32-
- The internal `ensure_installed()` function now returns the tool name instead of a Path object
33-
- The `util.py` module has been rewritten to use `shutil.which()` instead of `clang_tools.install`
34-
- Tests have been updated to mock the new wheel-based installation
35+
- Your existing `.pre-commit-config.yaml` files will continue to work without modification
36+
- All hook configurations remain backward compatible
37+
- No changes required to your workflow
3538

3639
## Migration Steps
3740

3841
### For End Users
39-
No action required! Your existing configuration will continue to work.
40-
41-
### For Developers/Contributors
42-
1. Update your development environment:
43-
```bash
44-
pip install clang-format clang-tidy
45-
```
4642

47-
2. If you were importing from the utility module:
48-
```python
49-
# Before
50-
from cpp_linter_hooks.util import ensure_installed
51-
path = ensure_installed("clang-format", "18")
52-
command = [str(path), "--version"]
43+
**No action required!** Your existing configuration will continue to work seamlessly.
5344

54-
# After
55-
from cpp_linter_hooks.util import ensure_installed
56-
tool_name = ensure_installed("clang-format", "18")
57-
command = [tool_name, "--version"]
58-
```
45+
However, we recommend updating to the latest version for:
46+
- Better performance
47+
- Enhanced reliability
48+
- Latest features and bug fixes
5949

60-
## Version Support
50+
#### Example Configuration (No Changes Needed)
6151

62-
The wheel packages support the same LLVM versions as before:
63-
- LLVM 16, 17, 18, 19, 20+
64-
- The `--version` argument continues to work as expected
52+
```yaml
53+
repos:
54+
- repo: https://github.com/cpp-linter/cpp-linter-hooks
55+
rev: v1.0.0 # Use the latest version
56+
hooks:
57+
- id: clang-format
58+
args: [--style=Google]
59+
- id: clang-tidy
60+
args: [--checks=-*,readability-*]
61+
```
6562
6663
## Troubleshooting
6764
68-
### Tool Not Found Error
69-
If you encounter "command not found" errors:
70-
71-
1. Ensure the wheel packages are installed:
72-
```bash
73-
pip install clang-format clang-tidy
74-
```
65+
### Common Issues
7566
76-
2. Verify the tools are available:
77-
```bash
78-
clang-format --version
79-
clang-tidy --version
80-
```
81-
82-
3. Check that the tools are in your PATH:
83-
```bash
84-
which clang-format
85-
which clang-tidy
86-
```
87-
88-
### Version Mismatch
89-
If you need a specific version, you can install it explicitly:
67+
#### Issue: Tool not found after migration
68+
**Solution**: Clear your pre-commit cache:
9069
```bash
91-
pip install clang-format==18.1.8
92-
pip install clang-tidy==18.1.8
70+
pre-commit clean
71+
pre-commit install
72+
```
73+
74+
#### Issue: Version mismatch errors
75+
**Solution**: Ensure you're using the latest version of `cpp-linter-hooks`:
76+
```yaml
77+
rev: v1.0.0 # Update to latest version
9378
```
9479
9580
## Support
9681
97-
If you encounter any issues after the migration, please:
98-
1. Check this migration guide
99-
2. Search existing [issues](https://github.com/cpp-linter/cpp-linter-hooks/issues)
100-
3. Create a new issue with:
101-
- Your operating system
82+
If you encounter issues after migration:
83+
84+
1. **Check this guide**: Review the troubleshooting section above
85+
2. **Search existing issues**: [GitHub Issues](https://github.com/cpp-linter/cpp-linter-hooks/issues)
86+
3. **Report new issues**: Include the following information:
87+
- Operating system and version
10288
- Python version
103-
- The exact error message
89+
- `cpp-linter-hooks` version
90+
- Complete error message/stack trace
10491
- Your `.pre-commit-config.yaml` configuration
10592

10693
## References
10794

108-
- [clang-format wheel package](https://github.com/ssciwr/clang-format-wheel)
109-
- [clang-tidy wheel package](https://github.com/ssciwr/clang-tidy-wheel)
110-
- [PyPI clang-format](https://pypi.org/project/clang-format/)
111-
- [PyPI clang-tidy](https://pypi.org/project/clang-tidy/)
95+
### Official Packages
96+
- [clang-format Python wheel](https://pypi.org/project/clang-format/) - PyPI package
97+
- [clang-tidy Python wheel](https://pypi.org/project/clang-tidy/) - PyPI package
98+
99+
### Source Repositories
100+
- [clang-format wheel source](https://github.com/ssciwr/clang-format-wheel) - GitHub repository
101+
- [clang-tidy wheel source](https://github.com/ssciwr/clang-tidy-wheel) - GitHub repository
102+
103+
### Documentation
104+
- [cpp-linter-hooks Documentation](https://github.com/cpp-linter/cpp-linter-hooks) - Main repository
105+
- [Pre-commit Framework](https://pre-commit.com/) - Pre-commit documentation
106+
107+
---
108+
109+
**Happy linting!**

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Add this configuration to your `.pre-commit-config.yaml` file:
2929
```yaml
3030
repos:
3131
- repo: https://github.com/cpp-linter/cpp-linter-hooks
32-
rev: v0.8.3 # Use the tag or commit you want
32+
rev: v1.0.0 # Use the tag or commit you want
3333
hooks:
3434
- id: clang-format
3535
args: [--style=Google] # Other coding style: LLVM, GNU, Chromium, Microsoft, Mozilla, WebKit.
@@ -44,7 +44,7 @@ To use custom configurations like `.clang-format` and `.clang-tidy`:
4444
```yaml
4545
repos:
4646
- repo: https://github.com/cpp-linter/cpp-linter-hooks
47-
rev: v0.8.3
47+
rev: v1.0.0
4848
hooks:
4949
- id: clang-format
5050
args: [--style=file] # Loads style from .clang-format file
@@ -59,7 +59,7 @@ To use specific versions of clang-format and clang-tidy (using Python wheel pack
5959
```yaml
6060
repos:
6161
- repo: https://github.com/cpp-linter/cpp-linter-hooks
62-
rev: v0.8.3
62+
rev: v1.0.0
6363
hooks:
6464
- id: clang-format
6565
args: [--style=file, --version=18] # Specifies version
@@ -68,7 +68,7 @@ repos:
6868
```
6969

7070
> [!NOTE]
71-
> Starting from version 0.9.0, this package uses Python wheel packages ([clang-format](https://pypi.org/project/clang-format/) and [clang-tidy](https://pypi.org/project/clang-tidy/)) instead of the previous clang-tools binaries. The wheel packages provide better cross-platform compatibility and easier installation.
71+
> Starting from version v1.0.0, this package uses Python wheel packages ([clang-format](https://pypi.org/project/clang-format/) and [clang-tidy](https://pypi.org/project/clang-tidy/)) instead of the previous clang-tools binaries. The wheel packages provide better cross-platform compatibility and easier installation. For more details, see the [Migration Guide](MIGRATION.md).
7272

7373
## Output
7474

@@ -144,12 +144,12 @@ Use -header-filter=.* to display errors from all non-system headers. Use -system
144144

145145
### Performance Optimization
146146

147-
> [!WARNING]
147+
> [!TIP]
148148
> If your `pre-commit` runs longer than expected, it is highly recommended to add `files` in `.pre-commit-config.yaml` to limit the scope of the hook. This helps improve performance by reducing the number of files being checked and avoids unnecessary processing. Here's an example configuration:
149149

150150
```yaml
151151
- repo: https://github.com/cpp-linter/cpp-linter-hooks
152-
rev: v0.8.3
152+
rev: v1.0.0
153153
hooks:
154154
- id: clang-format
155155
args: [--style=file, --version=18]
@@ -175,7 +175,7 @@ This approach ensures that only modified files are checked, further speeding up
175175
```yaml
176176
repos:
177177
- repo: https://github.com/cpp-linter/cpp-linter-hooks
178-
rev: v0.8.3
178+
rev: v1.0.0
179179
hooks:
180180
- id: clang-format
181181
args: [--style=file, --version=18, --verbose] # Add -v or --verbose for detailed output

0 commit comments

Comments
 (0)