llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: Nathan James (njames93) <details> <summary>Changes</summary> Adds a description parameter that automatically fills in the Release notes and first line of the checks documentation. If omitted the usually FIXME markers are left in their place. --- Full diff: https://github.com/llvm/llvm-project/pull/100111.diff 1 Files Affected: - (modified) clang-tools-extra/clang-tidy/add_new_check.py (+21-7) ``````````diff diff --git a/clang-tools-extra/clang-tidy/add_new_check.py b/clang-tools-extra/clang-tidy/add_new_check.py index 3a62df1f510ba..78ac4531de74a 100755 --- a/clang-tools-extra/clang-tidy/add_new_check.py +++ b/clang-tools-extra/clang-tidy/add_new_check.py @@ -16,6 +16,7 @@ import os import re import sys +import textwrap # Adapts the module's CMakelist file. Returns 'True' if it could add a new # entry and 'False' if the entry already existed. @@ -53,7 +54,8 @@ def adapt_cmake(module_path, check_name_camel): # Adds a header for the new check. -def write_header(module_path, module, namespace, check_name, check_name_camel): +def write_header(module_path, module, namespace, check_name, check_name_camel, description): + wrapped_desc = '\n'.join(textwrap.wrap(description, width=80, initial_indent='/// ', subsequent_indent='/// ')) filename = os.path.join(module_path, check_name_camel) + ".h" print("Creating %s..." % filename) with io.open(filename, "w", encoding="utf8", newline="\n") as f: @@ -85,7 +87,7 @@ def write_header(module_path, module, namespace, check_name, check_name_camel): namespace clang::tidy::%(namespace)s { -/// FIXME: Write a short description. +%(description)s /// /// For the user-facing documentation see: /// http://clang.llvm.org/extra/clang-tidy/checks/%(module)s/%(check_name)s.html @@ -107,6 +109,7 @@ class %(check_name_camel)s : public ClangTidyCheck { "check_name": check_name, "module": module, "namespace": namespace, + "description": wrapped_desc } ) @@ -235,7 +238,8 @@ def adapt_module(module_path, module, check_name, check_name_camel): # Adds a release notes entry. -def add_release_notes(module_path, module, check_name): +def add_release_notes(module_path, module, check_name, description): + wrapped_desc = '\n'.join(textwrap.wrap(description, width=80, initial_indent=' ', subsequent_indent=' ')) check_name_dashes = module + "-" + check_name filename = os.path.normpath( os.path.join(module_path, "../../docs/ReleaseNotes.rst") @@ -281,10 +285,10 @@ def add_release_notes(module_path, module, check_name): """- New :doc:`%s <clang-tidy/checks/%s/%s>` check. - FIXME: add release notes. +%s """ - % (check_name_dashes, module, check_name) + % (check_name_dashes, module, check_name, wrapped_desc) ) note_added = True @@ -612,6 +616,12 @@ def main(): default="c++", metavar="LANG", ) + parser.add_argument( + '--description','-d', + help="short description of what the check does", + default="FIXME: Write a short description", + type=str + ) parser.add_argument( "module", nargs="?", @@ -652,10 +662,14 @@ def main(): else: namespace = module - write_header(module_path, module, namespace, check_name, check_name_camel) + description = args.description + if not description.endswith('.'): + description += '.' + + write_header(module_path, module, namespace, check_name, check_name_camel, description) write_implementation(module_path, module, namespace, check_name_camel) adapt_module(module_path, module, check_name, check_name_camel) - add_release_notes(module_path, module, check_name) + add_release_notes(module_path, module, check_name, description) test_extension = language_to_extension.get(args.language) write_test(module_path, module, check_name, test_extension) write_docs(module_path, module, check_name) `````````` </details> https://github.com/llvm/llvm-project/pull/100111 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits