You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Docstrings generation was requested by @shenxianpeng.
* #138 (comment)
The following files were modified:
* `cpp_linter_hooks/clang_format.py`
* `cpp_linter_hooks/clang_tidy.py`
* `cpp_linter_hooks/util.py`
Copy file name to clipboardExpand all lines: cpp_linter_hooks/clang_format.py
+15-1Lines changed: 15 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,20 @@
14
14
15
15
16
16
defrun_clang_format(args=None) ->Tuple[int, str]:
17
+
"""
18
+
Run clang-format with the given arguments and return its exit code and combined output.
19
+
20
+
Parses known hook options from `args`, optionally ensures a specific clang-format version is installed, builds and executes a clang-format command (modifying files in-place by default), and captures stdout and stderr merged into a single output string.
21
+
22
+
Parameters:
23
+
args (Optional[Sequence[str]]): Argument list to parse (typically sys.argv[1:]). If omitted, uses parser defaults.
24
+
25
+
Returns:
26
+
tuple[int, str]: A pair (retval, output) where `output` is the concatenation of stdout and stderr.
27
+
`retval` is the subprocess return code, except:
28
+
- `-1` when the command included `--dry-run` (special sentinel to indicate dry-run mode),
29
+
- `1` when clang-format could not be found (FileNotFoundError converted to an exit-like code).
Copy file name to clipboardExpand all lines: cpp_linter_hooks/clang_tidy.py
+12-1Lines changed: 12 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,17 @@
10
10
11
11
12
12
defrun_clang_tidy(args=None) ->Tuple[int, str]:
13
+
"""
14
+
Run clang-tidy with the given command-line arguments and return a status code and captured output.
15
+
16
+
Parameters:
17
+
args (Optional[Sequence[str]]): Arguments to parse and forward to clang-tidy; if None, uses sys.argv. If the parsed arguments include a --version value, the specified clang-tidy version is ensured to be installed before running.
18
+
19
+
Returns:
20
+
Tuple[int, str]: A pair (status, output).
21
+
- status: 0 when clang-tidy executed and produced no warnings or errors; 1 when clang-tidy reports any "warning:" or "error:", or when clang-tidy cannot be executed.
22
+
- output: Captured stdout from clang-tidy, or the error text if execution failed.
"""Resolve the installation of a tool, checking for version and installing if necessary."""
85
+
"""
86
+
Resolve and install the requested clang tool version and return its executable path.
87
+
88
+
Parameters:
89
+
tool (str): Tool name, expected "clang-format" or "clang-tidy".
90
+
version (Optional[str]): Desired version string (exact match or prefix). If None, falls back to the default version from pyproject.toml when available.
91
+
92
+
Returns:
93
+
Optional[Path]: Path to the installed tool executable if installation succeeded, `None` otherwise.
0 commit comments