diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2017-01-02 10:22:27 -0500 |
|---|---|---|
| committer | Jonathan Corbet <corbet@lwn.net> | 2017-01-04 17:08:14 -0500 |
| commit | df31175bb4d372b99410034a8ac23ae5526f49d2 (patch) | |
| tree | 40cd025d35f1245875def8fd3b92ed095727ad4e /scripts/kernel-doc | |
| parent | 5267dd354bcd267f76d0f97193fe8a93899f8986 (diff) | |
kernel-doc: make highlights more homogenous for the various backends
$type_struct_full and friends are only used by the restructuredText
backend, because it needs to separate enum/struct/typedef/union from
the name of the type. However, $type_struct is *also* used by the rST
backend. This is confusing.
This patch replaces $type_struct's use in the rST backend with a new
$type_fallback; it modifies $type_struct so that it can be used in the
rST backend; and creates regular expressions like $type_struct
for enum/typedef/union, for use in all backends.
Note that, compared to $type_*_full, in the new regexes $1 includes both
the "kind" and the name (before, $1 was pretty much a constant).
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'scripts/kernel-doc')
| -rwxr-xr-x | scripts/kernel-doc | 68 |
1 files changed, 50 insertions, 18 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index d5e9f765b4fc..4c9ada36fe6b 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
| @@ -214,15 +214,19 @@ my $type_constant = '\%([-_\w]+)'; | |||
| 214 | my $type_func = '(\w+)\(\)'; | 214 | my $type_func = '(\w+)\(\)'; |
| 215 | my $type_param = '\@(\w+(\.\.\.)?)'; | 215 | my $type_param = '\@(\w+(\.\.\.)?)'; |
| 216 | my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params | 216 | my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params |
| 217 | my $type_struct = '\&((struct\s*)*[_\w]+)'; | ||
| 218 | my $type_struct_xml = '\\&((struct\s*)*[_\w]+)'; | ||
| 219 | my $type_env = '(\$\w+)'; | 217 | my $type_env = '(\$\w+)'; |
| 220 | my $type_enum_full = '\&(enum)\s*([_\w]+)'; | 218 | my $type_enum = '\&(enum\s*([_\w]+))'; |
| 221 | my $type_struct_full = '\&(struct)\s*([_\w]+)'; | 219 | my $type_struct = '\&(struct\s*([_\w]+))'; |
| 222 | my $type_typedef_full = '\&(typedef)\s*([_\w]+)'; | 220 | my $type_typedef = '\&(typedef\s*([_\w]+))'; |
| 223 | my $type_union_full = '\&(union)\s*([_\w]+)'; | 221 | my $type_union = '\&(union\s*([_\w]+))'; |
| 224 | my $type_member = '\&([_\w]+)(\.|->)([_\w]+)'; | 222 | my $type_member = '\&([_\w]+)(\.|->)([_\w]+)'; |
| 223 | my $type_fallback = '\&([_\w]+)'; | ||
| 224 | my $type_enum_xml = '\&(enum\s*([_\w]+))'; | ||
| 225 | my $type_struct_xml = '\&(struct\s*([_\w]+))'; | ||
| 226 | my $type_typedef_xml = '\&(typedef\s*([_\w]+))'; | ||
| 227 | my $type_union_xml = '\&(union\s*([_\w]+))'; | ||
| 225 | my $type_member_xml = '\&([_\w]+)(\.|-\>)([_\w]+)'; | 228 | my $type_member_xml = '\&([_\w]+)(\.|-\>)([_\w]+)'; |
| 229 | my $type_fallback_xml = '\&([_\w]+)'; | ||
| 226 | my $type_member_func = $type_member . '\(\)'; | 230 | my $type_member_func = $type_member . '\(\)'; |
| 227 | 231 | ||
| 228 | # Output conversion substitutions. | 232 | # Output conversion substitutions. |
| @@ -232,10 +236,14 @@ my $type_member_func = $type_member . '\(\)'; | |||
| 232 | my @highlights_html = ( | 236 | my @highlights_html = ( |
| 233 | [$type_constant, "<i>\$1</i>"], | 237 | [$type_constant, "<i>\$1</i>"], |
| 234 | [$type_func, "<b>\$1</b>"], | 238 | [$type_func, "<b>\$1</b>"], |
| 239 | [$type_enum_xml, "<i>\$1</i>"], | ||
| 235 | [$type_struct_xml, "<i>\$1</i>"], | 240 | [$type_struct_xml, "<i>\$1</i>"], |
| 241 | [$type_typedef_xml, "<i>\$1</i>"], | ||
| 242 | [$type_union_xml, "<i>\$1</i>"], | ||
| 236 | [$type_env, "<b><i>\$1</i></b>"], | 243 | [$type_env, "<b><i>\$1</i></b>"], |
| 237 | [$type_param, "<tt><b>\$1</b></tt>"], | 244 | [$type_param, "<tt><b>\$1</b></tt>"], |
| 238 | [$type_member_xml, "<tt><i>\$1</i>\$2\$3</tt>"] | 245 | [$type_member_xml, "<tt><i>\$1</i>\$2\$3</tt>"], |
| 246 | [$type_fallback_xml, "<i>\$1</i>"] | ||
| 239 | ); | 247 | ); |
| 240 | my $local_lt = "\\\\\\\\lt:"; | 248 | my $local_lt = "\\\\\\\\lt:"; |
| 241 | my $local_gt = "\\\\\\\\gt:"; | 249 | my $local_gt = "\\\\\\\\gt:"; |
| @@ -245,10 +253,14 @@ my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>" | |||
| 245 | my @highlights_html5 = ( | 253 | my @highlights_html5 = ( |
| 246 | [$type_constant, "<span class=\"const\">\$1</span>"], | 254 | [$type_constant, "<span class=\"const\">\$1</span>"], |
| 247 | [$type_func, "<span class=\"func\">\$1</span>"], | 255 | [$type_func, "<span class=\"func\">\$1</span>"], |
| 256 | [$type_enum_xml, "<span class=\"enum\">\$1</span>"], | ||
| 248 | [$type_struct_xml, "<span class=\"struct\">\$1</span>"], | 257 | [$type_struct_xml, "<span class=\"struct\">\$1</span>"], |
| 258 | [$type_typedef_xml, "<span class=\"typedef\">\$1</span>"], | ||
| 259 | [$type_union_xml, "<span class=\"union\">\$1</span>"], | ||
| 249 | [$type_env, "<span class=\"env\">\$1</span>"], | 260 | [$type_env, "<span class=\"env\">\$1</span>"], |
| 250 | [$type_param, "<span class=\"param\">\$1</span>]"], | 261 | [$type_param, "<span class=\"param\">\$1</span>]"], |
| 251 | [$type_member_xml, "<span class=\"literal\"><span class=\"struct\">\$1</span>\$2<span class=\"member\">\$3</span></span>"] | 262 | [$type_member_xml, "<span class=\"literal\"><span class=\"struct\">\$1</span>\$2<span class=\"member\">\$3</span></span>"], |
| 263 | [$type_fallback_xml, "<span class=\"struct\">\$1</span>"] | ||
| 252 | ); | 264 | ); |
| 253 | my $blankline_html5 = $local_lt . "br /" . $local_gt; | 265 | my $blankline_html5 = $local_lt . "br /" . $local_gt; |
| 254 | 266 | ||
| @@ -256,11 +268,15 @@ my $blankline_html5 = $local_lt . "br /" . $local_gt; | |||
| 256 | my @highlights_xml = ( | 268 | my @highlights_xml = ( |
| 257 | ["([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>"], | 269 | ["([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>"], |
| 258 | [$type_constant, "<constant>\$1</constant>"], | 270 | [$type_constant, "<constant>\$1</constant>"], |
| 271 | [$type_enum_xml, "<type>\$1</type>"], | ||
| 259 | [$type_struct_xml, "<structname>\$1</structname>"], | 272 | [$type_struct_xml, "<structname>\$1</structname>"], |
| 273 | [$type_typedef_xml, "<type>\$1</type>"], | ||
| 274 | [$type_union_xml, "<structname>\$1</structname>"], | ||
| 260 | [$type_param, "<parameter>\$1</parameter>"], | 275 | [$type_param, "<parameter>\$1</parameter>"], |
| 261 | [$type_func, "<function>\$1</function>"], | 276 | [$type_func, "<function>\$1</function>"], |
| 262 | [$type_env, "<envar>\$1</envar>"], | 277 | [$type_env, "<envar>\$1</envar>"], |
| 263 | [$type_member_xml, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"] | 278 | [$type_member_xml, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"], |
| 279 | [$type_fallback_xml, "<structname>\$1</structname>"] | ||
| 264 | ); | 280 | ); |
| 265 | my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n"; | 281 | my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n"; |
| 266 | 282 | ||
| @@ -268,10 +284,14 @@ my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $loca | |||
| 268 | my @highlights_gnome = ( | 284 | my @highlights_gnome = ( |
| 269 | [$type_constant, "<replaceable class=\"option\">\$1</replaceable>"], | 285 | [$type_constant, "<replaceable class=\"option\">\$1</replaceable>"], |
| 270 | [$type_func, "<function>\$1</function>"], | 286 | [$type_func, "<function>\$1</function>"], |
| 287 | [$type_enum, "<type>\$1</type>"], | ||
| 271 | [$type_struct, "<structname>\$1</structname>"], | 288 | [$type_struct, "<structname>\$1</structname>"], |
| 289 | [$type_typedef, "<type>\$1</type>"], | ||
| 290 | [$type_union, "<structname>\$1</structname>"], | ||
| 272 | [$type_env, "<envar>\$1</envar>"], | 291 | [$type_env, "<envar>\$1</envar>"], |
| 273 | [$type_param, "<parameter>\$1</parameter>" ], | 292 | [$type_param, "<parameter>\$1</parameter>" ], |
| 274 | [$type_member, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"] | 293 | [$type_member, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"], |
| 294 | [$type_fallback, "<structname>\$1</structname>"] | ||
| 275 | ); | 295 | ); |
| 276 | my $blankline_gnome = "</para><para>\n"; | 296 | my $blankline_gnome = "</para><para>\n"; |
| 277 | 297 | ||
| @@ -279,9 +299,13 @@ my $blankline_gnome = "</para><para>\n"; | |||
| 279 | my @highlights_man = ( | 299 | my @highlights_man = ( |
| 280 | [$type_constant, "\$1"], | 300 | [$type_constant, "\$1"], |
| 281 | [$type_func, "\\\\fB\$1\\\\fP"], | 301 | [$type_func, "\\\\fB\$1\\\\fP"], |
| 302 | [$type_enum, "\\\\fI\$1\\\\fP"], | ||
| 282 | [$type_struct, "\\\\fI\$1\\\\fP"], | 303 | [$type_struct, "\\\\fI\$1\\\\fP"], |
| 304 | [$type_typedef, "\\\\fI\$1\\\\fP"], | ||
| 305 | [$type_union, "\\\\fI\$1\\\\fP"], | ||
| 283 | [$type_param, "\\\\fI\$1\\\\fP"], | 306 | [$type_param, "\\\\fI\$1\\\\fP"], |
| 284 | [$type_member, "\\\\fI\$1\$2\$3\\\\fP"] | 307 | [$type_member, "\\\\fI\$1\$2\$3\\\\fP"], |
| 308 | [$type_fallback, "\\\\fI\$1\\\\fP"] | ||
| 285 | ); | 309 | ); |
| 286 | my $blankline_man = ""; | 310 | my $blankline_man = ""; |
| 287 | 311 | ||
| @@ -289,9 +313,13 @@ my $blankline_man = ""; | |||
| 289 | my @highlights_text = ( | 313 | my @highlights_text = ( |
| 290 | [$type_constant, "\$1"], | 314 | [$type_constant, "\$1"], |
| 291 | [$type_func, "\$1"], | 315 | [$type_func, "\$1"], |
| 316 | [$type_enum, "\$1"], | ||
| 292 | [$type_struct, "\$1"], | 317 | [$type_struct, "\$1"], |
| 318 | [$type_typedef, "\$1"], | ||
| 319 | [$type_union, "\$1"], | ||
| 293 | [$type_param, "\$1"], | 320 | [$type_param, "\$1"], |
| 294 | [$type_member, "\$1\$2\$3"] | 321 | [$type_member, "\$1\$2\$3"], |
| 322 | [$type_fallback, "\$1"] | ||
| 295 | ); | 323 | ); |
| 296 | my $blankline_text = ""; | 324 | my $blankline_text = ""; |
| 297 | 325 | ||
| @@ -303,12 +331,12 @@ my @highlights_rst = ( | |||
| 303 | [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"], | 331 | [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"], |
| 304 | [$type_fp_param, "**\$1\\\\(\\\\)**"], | 332 | [$type_fp_param, "**\$1\\\\(\\\\)**"], |
| 305 | [$type_func, "\\:c\\:func\\:`\$1()`"], | 333 | [$type_func, "\\:c\\:func\\:`\$1()`"], |
| 306 | [$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], | 334 | [$type_enum, "\\:c\\:type\\:`\$1 <\$2>`"], |
| 307 | [$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], | 335 | [$type_struct, "\\:c\\:type\\:`\$1 <\$2>`"], |
| 308 | [$type_typedef_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], | 336 | [$type_typedef, "\\:c\\:type\\:`\$1 <\$2>`"], |
| 309 | [$type_union_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], | 337 | [$type_union, "\\:c\\:type\\:`\$1 <\$2>`"], |
| 310 | # in rst this can refer to any type | 338 | # in rst this can refer to any type |
| 311 | [$type_struct, "\\:c\\:type\\:`\$1`"], | 339 | [$type_fallback, "\\:c\\:type\\:`\$1`"], |
| 312 | [$type_param, "**\$1**"] | 340 | [$type_param, "**\$1**"] |
| 313 | ); | 341 | ); |
| 314 | my $blankline_rst = "\n"; | 342 | my $blankline_rst = "\n"; |
| @@ -317,9 +345,13 @@ my $blankline_rst = "\n"; | |||
| 317 | my @highlights_list = ( | 345 | my @highlights_list = ( |
| 318 | [$type_constant, "\$1"], | 346 | [$type_constant, "\$1"], |
| 319 | [$type_func, "\$1"], | 347 | [$type_func, "\$1"], |
| 348 | [$type_enum, "\$1"], | ||
| 320 | [$type_struct, "\$1"], | 349 | [$type_struct, "\$1"], |
| 350 | [$type_typedef, "\$1"], | ||
| 351 | [$type_union, "\$1"], | ||
| 321 | [$type_param, "\$1"], | 352 | [$type_param, "\$1"], |
| 322 | [$type_member, "\$1"] | 353 | [$type_member, "\$1"], |
| 354 | [$type_fallback, "\$1"] | ||
| 323 | ); | 355 | ); |
| 324 | my $blankline_list = ""; | 356 | my $blankline_list = ""; |
| 325 | 357 | ||
