16
16
import os
17
17
import re
18
18
import sys
19
+ import textwrap
19
20
20
21
# Adapts the module's CMakelist file. Returns 'True' if it could add a new
21
22
# entry and 'False' if the entry already existed.
@@ -53,7 +54,8 @@ def adapt_cmake(module_path, check_name_camel):
53
54
54
55
55
56
# Adds a header for the new check.
56
- def write_header (module_path , module , namespace , check_name , check_name_camel ):
57
+ def write_header (module_path , module , namespace , check_name , check_name_camel , description ):
58
+ wrapped_desc = '\n ' .join (textwrap .wrap (description , width = 80 , initial_indent = '/// ' , subsequent_indent = '/// ' ))
57
59
filename = os .path .join (module_path , check_name_camel ) + ".h"
58
60
print ("Creating %s..." % filename )
59
61
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):
85
87
86
88
namespace clang::tidy::%(namespace)s {
87
89
88
- /// FIXME: Write a short description.
90
+ %( description)s
89
91
///
90
92
/// For the user-facing documentation see:
91
93
/// 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 {
107
109
"check_name" : check_name ,
108
110
"module" : module ,
109
111
"namespace" : namespace ,
112
+ "description" : wrapped_desc
110
113
}
111
114
)
112
115
@@ -235,7 +238,8 @@ def adapt_module(module_path, module, check_name, check_name_camel):
235
238
236
239
237
240
# Adds a release notes entry.
238
- def add_release_notes (module_path , module , check_name ):
241
+ def add_release_notes (module_path , module , check_name , description ):
242
+ wrapped_desc = '\n ' .join (textwrap .wrap (description , width = 80 , initial_indent = ' ' , subsequent_indent = ' ' ))
239
243
check_name_dashes = module + "-" + check_name
240
244
filename = os .path .normpath (
241
245
os .path .join (module_path , "../../docs/ReleaseNotes.rst" )
@@ -281,10 +285,10 @@ def add_release_notes(module_path, module, check_name):
281
285
"""- New :doc:`%s
282
286
<clang-tidy/checks/%s/%s>` check.
283
287
284
- FIXME: add release notes.
288
+ %s
285
289
286
290
"""
287
- % (check_name_dashes , module , check_name )
291
+ % (check_name_dashes , module , check_name , wrapped_desc )
288
292
)
289
293
note_added = True
290
294
@@ -612,6 +616,12 @@ def main():
612
616
default = "c++" ,
613
617
metavar = "LANG" ,
614
618
)
619
+ parser .add_argument (
620
+ '--description' ,'-d' ,
621
+ help = "short description of what the check does" ,
622
+ default = "FIXME: Write a short description" ,
623
+ type = str
624
+ )
615
625
parser .add_argument (
616
626
"module" ,
617
627
nargs = "?" ,
@@ -652,10 +662,14 @@ def main():
652
662
else :
653
663
namespace = module
654
664
655
- write_header (module_path , module , namespace , check_name , check_name_camel )
665
+ description = args .description
666
+ if not description .endswith ('.' ):
667
+ description += '.'
668
+
669
+ write_header (module_path , module , namespace , check_name , check_name_camel , description )
656
670
write_implementation (module_path , module , namespace , check_name_camel )
657
671
adapt_module (module_path , module , check_name , check_name_camel )
658
- add_release_notes (module_path , module , check_name )
672
+ add_release_notes (module_path , module , check_name , description )
659
673
test_extension = language_to_extension .get (args .language )
660
674
write_test (module_path , module , check_name , test_extension )
661
675
write_docs (module_path , module , check_name )
0 commit comments