Skip to content

Commit 0c17d3c

Browse files
committed
better docs
review readme files
1 parent 2d14b2e commit 0c17d3c

18 files changed

+255
-54
lines changed

README.md

+139-24
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
<!-- markdownlint-disable MD041 -->
2+
3+
[file-annotations]: https://cpp-linter.github.io/cpp_linter_rs/cli#-a---file-annotations
4+
[thread-comments]: https://cpp-linter.github.io/cpp_linter_rs/cli#-g---thread-comments
5+
[step-summary]: https://cpp-linter.github.io/cpp_linter_rs/cli#-w---step-summary
6+
[tidy-review]: https://cpp-linter.github.io/cpp_linter_rs/cli#-d---tidy-review
7+
[format-review]: https://cpp-linter.github.io/cpp_linter_rs/cli#-m---format-review
8+
9+
[format-annotations-preview]: docs/src/images/annotations-clang-format.png
10+
[tidy-annotations-preview]: docs/src/images/annotations-clang-tidy.png
11+
[step-summary-preview]: docs/src/images/step-summary.png
12+
[thread-comment-preview]: docs/src/images/comment.png
13+
[tidy-review-preview]: docs/src/images/tidy-review.png
14+
[format-review-preview]: docs/src/images/format-review.png
15+
[format-suggestion-preview]: docs/src/images/format-suggestion.png
16+
217
[![Python packaging][py-build-badge]][py-build-ci]
318
[![Binary executable builds][bin-build-badge]][bin-build-ci]
419
[![node-js builds][node-ci-badge]][node-ci]
520
[![Test CI][test-ci-badge]][test-ci]
621
[![Docs][docs-ci-badge]][docs-site]
722
[![Pre-commit-ci][pre-commit-badge]][pre-commit-ci]
8-
923
[![codecov-status][codecov-badge]][codecov-project]
10-
[![docs.rs][docs-rs-badge]][docs-rs]
11-
[![PyPI - Version][pypi-badge]][pypi-pkg]
12-
[![Crates.io Version][crates-io-badge]][crates-io-pkg]
13-
[![NPM Version][npm-badge]][npm-pkg]
1424

1525
[py-build-ci]: https://github.com/cpp-linter/cpp_linter_rs/actions/workflows/python-packaging.yml
1626
[py-build-badge]: https://github.com/cpp-linter/cpp_linter_rs/actions/workflows/python-packaging.yml/badge.svg
@@ -30,20 +40,78 @@
3040
[docs-rs]: https://docs.rs/cpp-linter
3141
[pypi-badge]: https://img.shields.io/pypi/v/cpp-linter
3242
[pypi-pkg]: https://pypi.org/project/cpp-linter/
43+
[test-pypi-badge]: https://img.shields.io/pypi/v/cpp-linter?pypiBaseUrl=https%3A%2F%2Ftest.pypi.org&label=test-pypi
44+
[test-pypi-pkg]: https://test.pypi.org/project/cpp-linter/
3345
[crates-io-badge]: https://img.shields.io/crates/v/cpp-linter
3446
[crates-io-pkg]: https://crates.io/crates/cpp-linter
3547
[npm-badge]: https://img.shields.io/npm/v/%40cpp-linter%2Fcpp-linter
3648
[npm-pkg]: https://www.npmjs.com/package/@cpp-linter/cpp-linter
3749

3850
# C/C++ Linting Package
3951

40-
A Python and Rust package for linting C/C++ code with clang-tidy and/or clang-format to collect feedback provided in the form of thread comments, step summary, or file annotations.
52+
A package for linting C/C++ code with clang-tidy and/or clang-format to collect feedback provided in the form of
53+
54+
- [x] [thread-comments](#thread-comment)
55+
- [x] [step-summary](#step-summary)
56+
- [x] [file-annotations](#annotations)
57+
- [x] [Pull Request Review](#pull-request-review) suggestions
4158

4259
> [!CAUTION]
4360
> This project is still experimental and subject to drastic changes.
44-
> Please use the pure python [cpp-linter](https://github.com/cpp-linter/cpp-linter)
61+
> Please use the [pure python cpp-linter](https://github.com/cpp-linter/cpp-linter)
4562
> package until this project is ready for deployment.
4663
64+
## Install
65+
66+
This package is available in several programming languages (through their respective package managers).
67+
68+
### Rust
69+
70+
[![Crates.io Version][crates-io-badge]][crates-io-pkg]
71+
[![docs.rs][docs-rs-badge]][docs-rs]
72+
73+
Install from source code hosted at crates.io:
74+
75+
```text
76+
cargo install cpp-linter
77+
```
78+
79+
Install a pre-compiled binary from GitHub releases:
80+
81+
First [install `cargo-binstall`](https://github.com/cargo-bins/cargo-binstall?tab=readme-ov-file#installation).
82+
83+
```text
84+
cargo binstall cpp-linter
85+
```
86+
87+
### Python
88+
89+
[![PyPI - Version][pypi-badge]][pypi-pkg]
90+
91+
Install the python package:
92+
93+
```text
94+
pip install cpp-linter
95+
```
96+
97+
[![testPyPI - Version][test-pypi-badge]][test-pypi-pkg]
98+
99+
Pre-releases are uploaded to test-pypi:
100+
101+
```text
102+
pip install -i https://test.pypi.org/simple/ cpp-linter
103+
```
104+
105+
### Node.js
106+
107+
[![NPM Version][npm-badge]][npm-pkg]
108+
109+
Install the Node.js binding:
110+
111+
```text
112+
npm -g install @cpp-linter/cpp-linter
113+
```
114+
47115
## Usage
48116

49117
For usage in a CI workflow, see
@@ -52,56 +120,103 @@ For usage in a CI workflow, see
52120
For the description of supported Command Line Interface options, see
53121
[the CLI documentation](https://cpp-linter.github.io/cpp_linter_rs/cli.html).
54122

123+
## Example
124+
125+
### Annotations
126+
127+
Using [`--file-annotations`][file-annotations]:
128+
129+
#### clang-format annotations
130+
131+
![clang-format annotations][format-annotations-preview]
132+
133+
#### clang-tidy annotations
134+
135+
![clang-tidy annotations][tidy-annotations-preview]
136+
137+
### Thread Comment
138+
139+
Using [`--thread-comments`][thread-comments]:
140+
141+
![sample thread-comment][thread-comment-preview]
142+
143+
### Step Summary
144+
145+
Using [`--step-summary`][step-summary]:
146+
147+
![step summary][step-summary-preview]
148+
149+
### Pull Request Review
150+
151+
#### Only clang-tidy
152+
153+
Using [`--tidy-review`][tidy-review]:
154+
155+
![sample tidy-review][tidy-review-preview]
156+
157+
#### Only clang-format
158+
159+
Using [`--format-review`][format-review]:
160+
161+
![sample format-review][format-review-preview]
162+
163+
![sample format-suggestion][format-suggestion-preview]
164+
55165
## Have question or feedback?
56166

57167
To provide feedback (requesting a feature or reporting a bug) please post to
58168
[issues](https://github.com/cpp-linter/cpp_linter_rs/issues).
59169

60170
## License
61171

62-
The scripts and documentation in this project are released under the [MIT][MIT].
172+
The scripts and documentation in this project are released under the [MIT].
63173

64174
Dependencies (that are redistributed by us in binary form) have the following
65175
license agreements:
66176

67177
- [clap](https://crates.io/crates/clap):
68-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
178+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
69179
- [git2](https://crates.io/crates/git2):
70-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
180+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
71181

72182
The following are conditionally included in binaries (using the `openssl-vendored` feature on a
73183
case-by-case basis) because it is a dependency of git2:
74184

75185
- [openssl](https://crates.io/crates/openssl): Licensed under [Apache 2.0][Apache2]
76186
- [openssl-probe](https://crates.io/crates/openssl-probe):
77-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
187+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
78188

79189
- [lenient_semver](https://crates.io/crates/lenient_semver):
80-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
190+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
81191
- [log](https://crates.io/crates/log):
82-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
192+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
83193
- [regex](https://crates.io/crates/regex):
84-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
194+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
85195
- [reqwest](https://crates.io/crates/reqwest):
86-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
196+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
87197
- [semver](https://crates.io/crates/semver):
88-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
198+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
89199
- [serde](https://crates.io/crates/serde):
90-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
91-
- [serde-xml-rs](https://crates.io/crates/serde-xml-rs): Licensed under [MIT][MIT].
200+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
201+
- [serde-xml-rs](https://crates.io/crates/serde-xml-rs): Licensed under [MIT].
92202
- [serde_json](https://crates.io/crates/serde_json):
93-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
94-
- [which](https://crates.io/crates/which): Licensed under [MIT][MIT].
95-
- [tokio](https://crates.io/crates/tokio): Licensed under [MIT][MIT].
203+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
204+
- [which](https://crates.io/crates/which): Licensed under [MIT].
205+
- [tokio](https://crates.io/crates/tokio): Licensed under [MIT].
96206
- [futures](https://crates.io/crates/futures):
97-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
207+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
98208
- [chrono](https://crates.io/crates/chrono):
99-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
209+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
100210

101211
The python binding uses
102212

103213
- [pyo3](https://crates.io/crates/pyo3):
104-
Dual-licensed under [Apache 2.0][Apache2] or [MIT][MIT].
214+
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
215+
216+
The node binding uses
217+
218+
- [napi](https://crates.io/crates/napi): Licensed under [MIT]
219+
- [napi-derive](https://crates.io/crates/napi-derive): Licensed under [MIT]
105220

106221
[MIT]: https://choosealicense.com/licenses/mit
107222
[Apache2]: https://choosealicense.com/licenses/apache-2.0/

cspell.config.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: "0.2"
22
language: en
33
words:
4+
- binstall
45
- Boolish
56
- bugprone
67
- chrono
@@ -15,6 +16,7 @@ words:
1516
- iomanip
1617
- libgit
1718
- markdownlint
19+
- maturin
1820
- mdbook
1921
- msvc
2022
- napi
@@ -25,6 +27,8 @@ words:
2527
- pybind
2628
- pyfunction
2729
- pymodule
30+
- pypi
31+
- pyproject
2832
- ratelimit
2933
- reqwest
3034
- revparse

docs/src/SUMMARY.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
- [Command Line Interface](./cli.md)
77
- [Token Permissions](./permissions.md)
88
- [Pull Request Review Caveats](./pr-review-caveats.md)
9+
- [Python Binding](./python.md)
10+
- [Node.js Binding](./node.md)
19.9 KB
Loading
23.9 KB
Loading

docs/src/images/comment.png

22.3 KB
Loading

docs/src/images/format-review.png

26.5 KB
Loading

docs/src/images/format-suggestion.png

32.7 KB
Loading

docs/src/images/step-summary.png

51.1 KB
Loading

docs/src/images/tidy-review.png

59.4 KB
Loading

docs/src/index.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1+
<!-- markdownlint-disable MD041 MD053 -->
12

2-
<!-- markdownlint-disable MD041 -->
3+
[file-annotations]: cli.md#-a---file-annotations
4+
[thread-comments]: cli.md#-g---thread-comments
5+
[step-summary]: cli.md#-w---step-summary
6+
[tidy-review]: cli.md#-d---tidy-review
7+
[format-review]: cli.md#-m---format-review
38

4-
{{#include ../../README.md}}
9+
[format-annotations-preview]: images/annotations-clang-format.png
10+
[tidy-annotations-preview]: images/annotations-clang-tidy.png
11+
[step-summary-preview]: images/step-summary.png
12+
[thread-comment-preview]: images/comment.png
13+
[tidy-review-preview]: images/tidy-review.png
14+
[format-review-preview]: images/format-review.png
15+
[format-suggestion-preview]: images/format-suggestion.png
16+
17+
{{#include ../../README.md:16:}}

docs/src/node.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Node.js Binding
2+
3+
{{#include ../../node-binding/README.md:2:}}

docs/src/python.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Python Binding
2+
3+
{{#include ../../py-binding/README.md:2:}}

node-binding/README.md

+33-26
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,63 @@
1-
# cpp-linter node binding
1+
# cpp-linter
22

3-
The node.js binding generated from rust source code.
3+
The node.js binding binding for the [cpp_linter_rs][this] rust project
4+
(built using [napi-rs](https://napi.rs) and [yarn](https://yarnpkg.com)).
45

5-
This project must use yarn because [napi-rs] uses [yarn] to get platform-specific information.
6+
[this]: https://github.com/cpp-linter/cpp_linter_rs
67

7-
[yarn]: https://yarnpkg.com/
8-
[napi-rs]: https://napi.rs/
8+
## Install
99

10-
This repo also doubles as a yarn workspace. So, the lock file exists in repo root folder.
11-
Furthermore, most scripts that can be executed in this project are available to run from repo root folder (using the same script name).
10+
Install with `npm`:
11+
12+
```text
13+
npm -g install @cpp-linter/cpp-linter
14+
```
1215

1316
## Usage
1417

15-
After the native module is built using [`yarn-build`](#yarn-build), you can import the binding via the generated `index.js` file (using the `node` console):
18+
For usage in a CI workflow, see
19+
[the cpp-linter/cpp-linter-action repository](https://github.com/cpp-linter/cpp-linter-action).
1620

17-
```sh
18-
cppLinter = require('./index.js')
19-
await cppLinter.main(['cpp-linter', '--help'])
20-
```
21+
For the description of supported Command Line Interface options, see
22+
[the CLI documentation](https://cpp-linter.github.io/cpp_linter_rs/cli.html).
2123

22-
All CLI arguments are passed as a array of strings to the binding's `main()` function.
23-
Notice the name of the CLI app (`'cpp-linter'`) is required because the rust argument parsing
24-
mechanism (`clap` crate) needs to know the name of the program invoked.
24+
## Development
25+
26+
After the native module is built using [`yarn build:debug`](#yarn-builddebug), you can
27+
invoke the executable script as a normal CLI app:
28+
29+
```text
30+
npx cpp-linter --help
31+
```
2532

26-
## Scripts
33+
### Scripts
2734

28-
> [!note]
29-
> If an available script is not described below, it should be considered a convenience tool for the CI workflow.
35+
If an available script is not described below, it should be considered a convenience
36+
tool for the CI/CD workflow.
3037

31-
### `yarn build`
38+
#### `yarn build`
3239

33-
This script builds the native module for distribution.
40+
This script builds the native module for distribution (with release profile optimizations).
3441

35-
#### `yarn build:debug`
42+
##### `yarn build:debug`
3643

37-
Same as `yarn build` but does not use the release optimizations.
44+
Same as `yarn build` but does not use the release profile optimizations.
3845
You should use this script when testing locally.
3946

40-
### `yarn test`
47+
#### `yarn test`
4148

4249
This script runs a simple test to ensure the native module was built correctly.
4350

44-
## Folder structure
51+
### Folder structure
4552

4653
| Name | Description |
4754
|-----:|:------------|
4855
| `__test__` | The location of the unit test(s). |
4956
| `npm` | The required metadata for publishing platform-specific packages to npm. |
5057
| `src` | The location for all rust sources related to binding the cpp-linter library. |
5158
| `build.rs` | The cargo-specific build script used when compiling the binding. |
52-
| `Cargo.toml` | Metadata about the rust package (which _is not_ intended to be published to crates.io). |
53-
| `package.json` | Metadata about the node.js binding (which _is_ meant to be published to npm). |
59+
| `Cargo.toml` | Metadata about the binding's rust package (which _is not_ intended to be published to crates.io). |
60+
| `package.json` | Metadata about the npm package (platform agnostic). |
5461
| `index.d.ts` | The generated TypeScript typing info the describes the exposing functionality in the built native module. |
5562
| `index.js` | The generated script that delegates which platform-specific package to import. |
5663
| `cpp-linter.x-y-z.node` | Then native module built for a specific platform (where `x-y-z` denotes the platform's name using compilation target). |

0 commit comments

Comments
 (0)