Skip to content

Commit

Permalink
[clang-tidy][NFC] Update add_new_check.py to handle more proper list.rst
Browse files Browse the repository at this point in the history
Update script to generate list.rst in format that is
in-sync with gen-static-analyzer-docs.py.
Re-generate list.rst.
  • Loading branch information
PiotrZSL committed Aug 11, 2023
1 parent 2e79d0a commit cd9e923
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 37 deletions.
44 changes: 28 additions & 16 deletions clang-tools-extra/clang-tidy/add_new_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def process_doc(doc_file):

def format_link(doc_file):
check_name, match = process_doc(doc_file)
if not match and check_name:
if not match and check_name and not check_name.startswith("clang-analyzer-"):
return " `%(check_name)s <%(module)s/%(check)s.html>`_,%(autofix)s\n" % {
"check_name": check_name,
"module": doc_file[0],
Expand All @@ -495,32 +495,44 @@ def format_link(doc_file):

def format_link_alias(doc_file):
check_name, match = process_doc(doc_file)
if match and check_name:
if (match or (check_name.startswith("clang-analyzer-"))) and check_name:
module = doc_file[0]
check_file = doc_file[1].replace(".rst", "")
if match.group(1) == "https://clang.llvm.org/docs/analyzer/checkers":
if not match or match.group(1) == "https://clang.llvm.org/docs/analyzer/checkers":
title = "Clang Static Analyzer " + check_file
# Preserve the anchor in checkers.html from group 2.
target = match.group(1) + ".html" + match.group(2)
target = "" if not match else match.group(1) + ".html" + match.group(2)
autofix = ""
else:
redirect_parts = re.search("^\.\./([^/]*)/([^/]*)$", match.group(1))
title = redirect_parts[1] + "-" + redirect_parts[2]
target = redirect_parts[1] + "/" + redirect_parts[2] + ".html"
autofix = has_auto_fix(title)

# The checker is just a redirect.
return (
" `%(check_name)s <%(module)s/%(check_file)s.html>`_, `%(title)s <%(target)s>`_,%(autofix)s\n"
% {
"check_name": check_name,
"module": module,
"check_file": check_file,
"target": target,
"title": title,
"autofix": autofix,
}
)
if target:
# The checker is just a redirect.
return (
" `%(check_name)s <%(module)s/%(check_file)s.html>`_, `%(title)s <%(target)s>`_,%(autofix)s\n"
% {
"check_name": check_name,
"module": module,
"check_file": check_file,
"target": target,
"title": title,
"autofix": autofix,
})
else:
# The checker is just a alias without redirect.
return (
" `%(check_name)s <%(module)s/%(check_file)s.html>`_, %(title)s,%(autofix)s\n"
% {
"check_name": check_name,
"module": module,
"check_file": check_file,
"target": target,
"title": title,
"autofix": autofix,
})
return ""

checks = map(format_link, doc_files)
Expand Down
22 changes: 1 addition & 21 deletions clang-tools-extra/docs/clang-tidy/checks/list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,6 @@ Clang-Tidy Checks
`cert-msc51-cpp <cert/msc51-cpp.html>`_,
`cert-oop57-cpp <cert/oop57-cpp.html>`_,
`cert-oop58-cpp <cert/oop58-cpp.html>`_,
`clang-analyzer-core.DynamicTypePropagation <clang-analyzer/core.DynamicTypePropagation.html>`_,
`clang-analyzer-core.uninitialized.CapturedBlockVariable <clang-analyzer/core.uninitialized.CapturedBlockVariable.html>`_,
`clang-analyzer-cplusplus.InnerPointer <clang-analyzer/cplusplus.InnerPointer.html>`_,
`clang-analyzer-nullability.NullableReturnedFromNonnull <clang-analyzer/nullability.NullableReturnedFromNonnull.html>`_,
`clang-analyzer-optin.osx.OSObjectCStyleCast <clang-analyzer/optin.osx.OSObjectCStyleCast.html>`_,
`clang-analyzer-optin.performance.GCDAntipattern <clang-analyzer/optin.performance.GCDAntipattern.html>`_,
`clang-analyzer-optin.performance.Padding <clang-analyzer/optin.performance.Padding.html>`_,
`clang-analyzer-optin.portability.UnixAPI <clang-analyzer/optin.portability.UnixAPI.html>`_,
`clang-analyzer-osx.MIG <clang-analyzer/osx.MIG.html>`_,
`clang-analyzer-osx.NumberObjectConversion <clang-analyzer/osx.NumberObjectConversion.html>`_,
`clang-analyzer-osx.OSObjectRetainCount <clang-analyzer/osx.OSObjectRetainCount.html>`_,
`clang-analyzer-osx.ObjCProperty <clang-analyzer/osx.ObjCProperty.html>`_,
`clang-analyzer-osx.cocoa.AutoreleaseWrite <clang-analyzer/osx.cocoa.AutoreleaseWrite.html>`_,
`clang-analyzer-osx.cocoa.Loops <clang-analyzer/osx.cocoa.Loops.html>`_,
`clang-analyzer-osx.cocoa.MissingSuperCall <clang-analyzer/osx.cocoa.MissingSuperCall.html>`_,
`clang-analyzer-osx.cocoa.NonNilReturnValue <clang-analyzer/osx.cocoa.NonNilReturnValue.html>`_,
`clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak <clang-analyzer/osx.cocoa.RunLoopAutoreleaseLeak.html>`_,
`clang-analyzer-valist.CopyToSelf <clang-analyzer/valist.CopyToSelf.html>`_,
`clang-analyzer-valist.Uninitialized <clang-analyzer/valist.Uninitialized.html>`_,
`clang-analyzer-valist.Unterminated <clang-analyzer/valist.Unterminated.html>`_,
`concurrency-mt-unsafe <concurrency/mt-unsafe.html>`_,
`concurrency-thread-canceltype-asynchronous <concurrency/thread-canceltype-asynchronous.html>`_,
`cppcoreguidelines-avoid-capturing-lambda-coroutines <cppcoreguidelines/avoid-capturing-lambda-coroutines.html>`_,
Expand Down Expand Up @@ -255,7 +235,7 @@ Clang-Tidy Checks
`llvm-twine-local <llvm/twine-local.html>`_, "Yes"
`llvmlibc-callee-namespace <llvmlibc/callee-namespace.html>`_,
`llvmlibc-implementation-in-namespace <llvmlibc/implementation-in-namespace.html>`_,
`llvmlibc-inline-function-decl <llvmlibc/inline-function-decl.html>`_,
`llvmlibc-inline-function-decl <llvmlibc/inline-function-decl.html>`_, "Yes"
`llvmlibc-restrict-system-libc-headers <llvmlibc/restrict-system-libc-headers.html>`_, "Yes"
`misc-confusable-identifiers <misc/confusable-identifiers.html>`_,
`misc-const-correctness <misc/const-correctness.html>`_, "Yes"
Expand Down

0 comments on commit cd9e923

Please sign in to comment.