Skip to content

Commit 837bd50

Browse files
committed
[clang-tidy][docs] Fix formatting and improve clarity in Clang-Tidy documentation
1 parent 15f16bc commit 837bd50

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

clang-tools-extra/docs/clang-tidy/index.rst

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -339,27 +339,28 @@ An overview of all the command-line options:
339339
Clang-Tidy Automation
340340
=====================
341341

342-
:program:`clang-tidy` can analyze multiple source files by specifying them on the
343-
command line. For larger projects, automation
344-
scripts provide additional functionality like parallel execution and integration
345-
with version control systems.
342+
:program:`clang-tidy` can analyze multiple source files by specifying them on
343+
the command line. For larger projects, automation scripts provide additional
344+
functionality like parallel execution and integration with version control
345+
systems.
346346

347347
Running Clang-Tidy in Parallel
348348
-------------------------------
349349

350350
:program:`clang-tidy` can process multiple files sequentially, but for projects
351-
with many source files, the :program:`run-clang-tidy.py` script provides parallel
352-
execution to significantly reduce analysis time. This script is included with
353-
clang-tidy and runs :program:`clang-tidy` over all files in a compilation database
354-
or a specified path concurrently.
351+
with many source files, the :program:`run-clang-tidy.py` script provides
352+
parallel execution to significantly reduce analysis time. This script is
353+
included with clang-tidy and runs :program:`clang-tidy` over all files in a
354+
compilation database or a specified path concurrently.
355355

356-
The script requires a compilation database (``compile_commands.json``) which can
357-
be generated by build systems like CMake (using ``-DCMAKE_EXPORT_COMPILE_COMMANDS=ON``)
358-
or by tools like `Bear`_.
356+
The script requires a compilation database (``compile_commands.json``) which
357+
can be generated by build systems like CMake (using
358+
``-DCMAKE_EXPORT_COMPILE_COMMANDS=ON``) or by tools like `Bear`_.
359359

360360
The script supports most of the same options as :program:`clang-tidy` itself,
361-
including ``-checks=``, ``-fix``, ``-header-filter=``, and configuration options.
362-
Run ``run-clang-tidy.py --help`` for a complete list of available options.
361+
including ``-checks=``, ``-fix``, ``-header-filter=``, and configuration
362+
options. Run ``run-clang-tidy.py --help`` for a complete list of available
363+
options.
363364

364365
Example invocations:
365366

@@ -380,12 +381,12 @@ Example invocations:
380381
Running Clang-Tidy on Diff
381382
---------------------------
382383

383-
The :program:`clang-tidy-diff.py` script allows you to run :program:`clang-tidy`
384-
on the lines that have been modified in your working directory or in a
385-
specific diff. Importantly, clang-tidy-diff only reports diagnostics for changed
386-
lines; :program:`clang-tidy` still analyzes the entire file and filters out
387-
unchanged lines after analysis, so this does not improve performance. This is
388-
particularly useful for code reviews and continuous
384+
The :program:`clang-tidy-diff.py` script allows you to run
385+
:program:`clang-tidy` on the lines that have been modified in your working
386+
directory or in a specific diff. Importantly, clang-tidy-diff only reports
387+
diagnostics for changed lines; :program:`clang-tidy` still analyzes the entire
388+
file and filters out unchanged lines after analysis, so this does not improve
389+
performance. This is particularly useful for code reviews and continuous
389390
integration, as it focuses analysis on the changed code rather than the entire
390391
codebase.
391392

@@ -404,7 +405,8 @@ Example invocations:
404405
$ git diff -U0 --no-color HEAD^ | clang-tidy-diff.py -p1
405406
406407
# Run with specific checks and apply fixes
407-
$ git diff -U0 --no-color HEAD^ | clang-tidy-diff.py -p1 -fix -checks=-*,readability-*
408+
$ git diff -U0 --no-color HEAD^ | clang-tidy-diff.py -p1 -fix \
409+
-checks=-*,readability-*
408410
409411
# Run on staged changes
410412
$ git diff -U0 --no-color --cached | clang-tidy-diff.py -p1
@@ -415,20 +417,21 @@ Example invocations:
415417
# Run on a patch file
416418
$ clang-tidy-diff.py -p1 < changes.patch
417419
418-
The ``-p1`` option tells the script to strip one level of path prefix from the
419-
diff, which is typically needed for Git diffs. The script supports most of the
420-
same options as :program:`clang-tidy` itself, including ``-checks=``, ``-fix``,
421-
``-header-filter=``, and configuration options.
420+
The ``-p1`` option tells the script to strip one level of path prefix from
421+
the diff, which is typically needed for Git diffs. The script supports most of
422+
the same options as :program:`clang-tidy` itself, including ``-checks=``,
423+
``-fix``, ``-header-filter=``, and configuration options.
422424

423425
While :program:`clang-tidy-diff.py` is useful for focusing on recent changes,
424426
relying solely on it may lead to incomplete analysis. Since the script only
425427
reports warnings from the modified lines, it may miss issues that are caused
426428
by the changes but manifest elsewhere in the code. For example, changes that
427429
only add lines to a function may cause it to violate size limits (e.g.,
428-
`readability-function-size <checks/readability/function-size.html>`_), but the diagnostic will be reported at the
429-
function declaration, which may not be in the diff and thus filtered out.
430-
Modifications to header files may also affect many implementation files, but
431-
only warnings in the modified header lines will be reported.
430+
`readability-function-size <checks/readability/function-size.html>`_), but the
431+
diagnostic will be reported at the function declaration, which may not be in
432+
the diff and thus filtered out. Modifications to header files may also affect
433+
many implementation files, but only warnings in the modified header lines will
434+
be reported.
432435

433436
For comprehensive analysis, especially before merging significant changes,
434437
consider running :program:`clang-tidy` on the entire affected files or the

0 commit comments

Comments
 (0)