Skip to content

Commit f15f170

Browse files
committed
chore: save progress
1 parent 1679bac commit f15f170

File tree

8 files changed

+131
-44
lines changed

8 files changed

+131
-44
lines changed

README.rst

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ clang-tools CLI
3434
Features
3535
--------
3636

37+
- Support clang tools binaries and Python wheels.
3738
- Binaries are statically linked for improved portability.
3839
- Binaries can be specified installed for increased flexibility.
3940
- Binaries are checked with SHA512 checksum. This ensures:
@@ -50,6 +51,7 @@ Features
5051
category.
5152
- Customizable install path.
5253

54+
5355
Install clang-tools CLI
5456
-----------------------
5557

@@ -85,14 +87,15 @@ Install `clang-tools` from git repo
8587
8688
pip install git+https://github.com/cpp-linter/clang-tools-pip.git@main
8789
90+
8891
CLI Usage
8992
---------
9093

9194
For a list of supported Command Line Interface options, see
9295
`the CLI documentation <https://cpp-linter.github.io/clang-tools-pip/cli_args.html>`_
9396

94-
Examples
95-
********
97+
Install binaries examples
98+
~~~~~~~~~~~~~~~~~~~~~~~~~
9699

97100
Use ``clang-tools`` command to install version 13 binaries.
98101

@@ -128,17 +131,49 @@ If the installed directory is in your path, you can run the installed tools.
128131
Default target: x86_64-unknown-linux-gnu
129132
Host CPU: skylake
130133
131-
Supported versions
134+
135+
Install wheels examples
136+
~~~~~~~~~~~~~~~~~~~~~~~~~
137+
138+
After installing the ``clang-tools`` CLI, you can install the Python wheels by running: ``clang-tools-wheel`` command.
139+
140+
.. important::
141+
It is just used for cpp-linter projects to install clang tools Python wheels. For other use cases, please install the wheels with ``pip``, ``pipx``, ``uv``, or other tools.
142+
143+
144+
.. code-block:: shell
145+
146+
# Install latest clang-format wheel
147+
clang-tools-wheel --tool clang-format --version 21
148+
# Install latest clang-tidy wheel
149+
clang-tools-wheel --tool clang-tidy --version 21
150+
151+
152+
Supported Versions
132153
------------------
133154

134-
clang-format, clang-tidy, clang-query, clang-apply-replacements
135-
***************************************************************
155+
156+
clang tools binaries
157+
~~~~~~~~~~~~~~~~~~~~
158+
159+
The following table shows the supported versions of clang-format, clang-tidy, clang-query, and clang-apply-replacements binaries for each platform:
160+
136161
.. csv-table::
137-
:header: "Version", "21", "20", "19", "18", "17", "16", "15", "14", "13", "12", "11", "10", "9"
162+
:header: "Platform", "21", "20", "19", "18", "17", "16", "15", "14", "13", "12", "11", "10", "9"
138163
:stub-columns: 1
139164

140165
Linux,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
141166
Windows,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
142167
macOS,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
143168

144169
For more details, visit the `clang-tools-static-binaries <https://github.com/cpp-linter/clang-tools-static-binaries>`_ repository.
170+
171+
clang tools Python wheels
172+
~~~~~~~~~~~~~~~~~~~~~~~~~
173+
174+
The following Python wheels are supported:
175+
176+
- `clang-format <https://pypi.org/project/clang-format/#history>`_
177+
- `clang-tidy <https://pypi.org/project/clang-tidy/#history>`_
178+
179+
Check the respective PyPI pages for available versions and platform support.

clang_tools/wheel.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from cpp_linter_hooks.util import _resolve_install
33

44

5-
def main() -> int:
5+
def get_parser() -> ArgumentParser:
6+
"""Get and parser to interpret CLI args."""
67
parser = ArgumentParser(description="Install specified clang tool wheel")
78
parser.add_argument(
89
"--tool",
@@ -15,6 +16,22 @@ def main() -> int:
1516
default=None,
1617
help="Version to install (e.g., 21 or 21.1.2). Defaults to latest compatible version.",
1718
)
19+
return parser
20+
21+
22+
def main() -> int:
23+
parser = get_parser()
24+
args = parser.parse_args()
25+
args = parser.parse_args()
26+
path = _resolve_install(args.tool, args.version)
27+
if path:
28+
print(f"{args.tool} installed at: {path}")
29+
return 0
30+
parser.add_argument(
31+
"--version",
32+
default=None,
33+
help="Version to install (e.g., 21 or 21.1.2). Defaults to latest compatible version.",
34+
)
1835
args = parser.parse_args()
1936
path = _resolve_install(args.tool, args.version)
2037
if path:

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ API Reference
99

1010
.. automodule:: clang_tools.util
1111
:members:
12+
13+
.. automodule:: clang_tools.wheel
14+
:members:

docs/conf.py

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from sphinx.util.docutils import SphinxRole
1515
from sphinx_immaterial.inline_icons import load_svg_into_builder_env
1616
from clang_tools.main import get_parser
17+
from clang_tools.wheel import get_parser as get_wheel_parser
1718

1819
# -- Path setup --------------------------------------------------------------
1920

@@ -207,38 +208,49 @@ def setup(app: Sphinx):
207208
app.add_role("badge-default", CliBadgeDefault())
208209
app.add_role("badge-switch", CliBadgeSwitch())
209210

211+
def write_cli_doc(doc_path, parser, prog_name):
212+
with open(doc_path, mode="w") as doc:
213+
doc.write(f"{prog_name} --help\n{'=' * 30}\n\n")
214+
doc.write(
215+
".. code-block:: text\n :caption: Usage\n :class: no-copy\n\n"
216+
)
217+
parser.prog = prog_name
218+
str_buf = StringIO()
219+
parser.print_usage(str_buf)
220+
usage = str_buf.getvalue()
221+
start = usage.find(parser.prog)
222+
for line in usage.splitlines():
223+
doc.write(f" {line[start:]}\n")
224+
args = parser._optionals._actions
225+
for arg in args:
226+
aliases = arg.option_strings
227+
if not aliases or arg.default == "==SUPPRESS==":
228+
continue
229+
assert arg.help is not None
230+
doc.write("\n.. std:option:: " + ", ".join(aliases) + "\n")
231+
req_ver = next(
232+
(
233+
ver
234+
for ver, names in REQUIRED_VERSIONS.items()
235+
if arg.dest in names
236+
),
237+
"0.1.0",
238+
)
239+
doc.write(f"\n :badge-version:`{req_ver}` ")
240+
if arg.default:
241+
default = (
242+
" ".join(arg.default)
243+
if isinstance(arg.default, list)
244+
else arg.default
245+
)
246+
doc.write(f":badge-default:`{default}` ")
247+
if isinstance(arg, _StoreTrueAction):
248+
doc.write(":badge-switch:`Accepts no value` ")
249+
doc.write("\n\n ")
250+
doc.write("\n ".join(arg.help.splitlines()) + "\n")
251+
210252
cli_doc = Path(app.srcdir, "cli_args.rst")
211-
with open(cli_doc, mode="w") as doc:
212-
doc.write("Command Line Interface Options\n==============================\n\n")
213-
parser = get_parser()
214-
doc.write(".. code-block:: text\n :caption: Usage\n :class: no-copy\n\n")
215-
parser.prog = "clang-tools"
216-
str_buf = StringIO()
217-
parser.print_usage(str_buf)
218-
usage = str_buf.getvalue()
219-
start = usage.find(parser.prog)
220-
for line in usage.splitlines():
221-
doc.write(f" {line[start:]}\n")
222-
223-
args = parser._optionals._actions
224-
for arg in args:
225-
aliases = arg.option_strings
226-
if not aliases or arg.default == "==SUPPRESS==":
227-
continue
228-
assert arg.help is not None
229-
doc.write("\n.. std:option:: " + ", ".join(aliases) + "\n")
230-
req_ver = "0.1.0"
231-
for ver, names in REQUIRED_VERSIONS.items():
232-
if arg.dest in names:
233-
req_ver = ver
234-
break
235-
doc.write(f"\n :badge-version:`{req_ver}` ")
236-
if arg.default:
237-
default = arg.default
238-
if isinstance(arg.default, list):
239-
default = " ".join(arg.default)
240-
doc.write(f":badge-default:`{default}` ")
241-
if isinstance(arg, _StoreTrueAction):
242-
doc.write(":badge-switch:`Accepts no value` ")
243-
doc.write("\n\n ")
244-
doc.write("\n ".join(arg.help.splitlines()) + "\n")
253+
write_cli_doc(cli_doc, get_parser(), "clang-tools")
254+
255+
wheel_cli_doc = Path(app.srcdir, "wheel_cli_args.rst")
256+
write_cli_doc(wheel_cli_doc, get_wheel_parser(), "clang-tools-wheel")

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
:hidden:
1212

1313
cli_args
14+
wheel_cli_args
1415

1516
.. toctree::
1617
:hidden:

docs/usage.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Using a Custom Binary Repository
2-
--------------------------------
1+
Custom Binary Repository
2+
------------------------
33

44
You can override the default source for downloading **clang-tools** by setting the following environment variables:
55

docs/wheel_cli_args.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
clang-tools-wheel --help
2+
==============================
3+
4+
.. code-block:: text
5+
:caption: Usage
6+
:class: no-copy
7+
8+
clang-tools-wheel [-h] [--tool {clang-format,clang-tidy}] [--version VERSION]
9+
10+
.. std:option:: --tool
11+
12+
:badge-version:`0.11.0` :badge-default:`clang-format`
13+
14+
Tool to install (clang-format or clang-tidy)
15+
16+
.. std:option:: --version
17+
18+
:badge-version:`0.1.0`
19+
20+
Version to install (e.g., 21 or 21.1.2). Defaults to latest compatible version.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ dynamic = ["version"]
3939

4040
[project.scripts]
4141
clang-tools = "clang_tools.main:main"
42-
clang-tools-binary = "clang_tools.main:main"
4342
clang-tools-wheel = "clang_tools.wheel:main"
4443

4544
[project.urls]

0 commit comments

Comments
 (0)