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,14 @@ 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 (
58
+ module_path , module , namespace , check_name , check_name_camel , description
59
+ ):
60
+ wrapped_desc = "\n " .join (
61
+ textwrap .wrap (
62
+ description , width = 80 , initial_indent = "/// " , subsequent_indent = "/// "
63
+ )
64
+ )
57
65
filename = os .path .join (module_path , check_name_camel ) + ".h"
58
66
print ("Creating %s..." % filename )
59
67
with io .open (filename , "w" , encoding = "utf8" , newline = "\n " ) as f :
@@ -85,7 +93,7 @@ def write_header(module_path, module, namespace, check_name, check_name_camel):
85
93
86
94
namespace clang::tidy::%(namespace)s {
87
95
88
- /// FIXME: Write a short description.
96
+ %( description)s
89
97
///
90
98
/// For the user-facing documentation see:
91
99
/// http://clang.llvm.org/extra/clang-tidy/checks/%(module)s/%(check_name)s.html
@@ -107,6 +115,7 @@ class %(check_name_camel)s : public ClangTidyCheck {
107
115
"check_name" : check_name ,
108
116
"module" : module ,
109
117
"namespace" : namespace ,
118
+ "description" : wrapped_desc ,
110
119
}
111
120
)
112
121
@@ -235,7 +244,12 @@ def adapt_module(module_path, module, check_name, check_name_camel):
235
244
236
245
237
246
# Adds a release notes entry.
238
- def add_release_notes (module_path , module , check_name ):
247
+ def add_release_notes (module_path , module , check_name , description ):
248
+ wrapped_desc = "\n " .join (
249
+ textwrap .wrap (
250
+ description , width = 80 , initial_indent = " " , subsequent_indent = " "
251
+ )
252
+ )
239
253
check_name_dashes = module + "-" + check_name
240
254
filename = os .path .normpath (
241
255
os .path .join (module_path , "../../docs/ReleaseNotes.rst" )
@@ -281,10 +295,10 @@ def add_release_notes(module_path, module, check_name):
281
295
"""- New :doc:`%s
282
296
<clang-tidy/checks/%s/%s>` check.
283
297
284
- FIXME: add release notes.
298
+ %s
285
299
286
300
"""
287
- % (check_name_dashes , module , check_name )
301
+ % (check_name_dashes , module , check_name , wrapped_desc )
288
302
)
289
303
note_added = True
290
304
@@ -612,6 +626,13 @@ def main():
612
626
default = "c++" ,
613
627
metavar = "LANG" ,
614
628
)
629
+ parser .add_argument (
630
+ "--description" ,
631
+ "-d" ,
632
+ help = "short description of what the check does" ,
633
+ default = "FIXME: Write a short description" ,
634
+ type = str ,
635
+ )
615
636
parser .add_argument (
616
637
"module" ,
617
638
nargs = "?" ,
@@ -652,10 +673,16 @@ def main():
652
673
else :
653
674
namespace = module
654
675
655
- write_header (module_path , module , namespace , check_name , check_name_camel )
676
+ description = args .description
677
+ if not description .endswith ("." ):
678
+ description += "."
679
+
680
+ write_header (
681
+ module_path , module , namespace , check_name , check_name_camel , description
682
+ )
656
683
write_implementation (module_path , module , namespace , check_name_camel )
657
684
adapt_module (module_path , module , check_name , check_name_camel )
658
- add_release_notes (module_path , module , check_name )
685
+ add_release_notes (module_path , module , check_name , description )
659
686
test_extension = language_to_extension .get (args .language )
660
687
write_test (module_path , module , check_name , test_extension )
661
688
write_docs (module_path , module , check_name )
0 commit comments