Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Paolo Bonzini and committed by
Jonathan Corbet
df31175b 5267dd35

+50 -18
+50 -18
scripts/kernel-doc
··· 214 214 my $type_func = '(\w+)\(\)'; 215 215 my $type_param = '\@(\w+(\.\.\.)?)'; 216 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 = '\\&amp;((struct\s*)*[_\w]+)'; 219 217 my $type_env = '(\$\w+)'; 220 - my $type_enum_full = '\&(enum)\s*([_\w]+)'; 221 - my $type_struct_full = '\&(struct)\s*([_\w]+)'; 222 - my $type_typedef_full = '\&(typedef)\s*([_\w]+)'; 223 - my $type_union_full = '\&(union)\s*([_\w]+)'; 218 + my $type_enum = '\&(enum\s*([_\w]+))'; 219 + my $type_struct = '\&(struct\s*([_\w]+))'; 220 + my $type_typedef = '\&(typedef\s*([_\w]+))'; 221 + my $type_union = '\&(union\s*([_\w]+))'; 224 222 my $type_member = '\&([_\w]+)(\.|->)([_\w]+)'; 223 + my $type_fallback = '\&([_\w]+)'; 224 + my $type_enum_xml = '\&amp;(enum\s*([_\w]+))'; 225 + my $type_struct_xml = '\&amp;(struct\s*([_\w]+))'; 226 + my $type_typedef_xml = '\&amp;(typedef\s*([_\w]+))'; 227 + my $type_union_xml = '\&amp;(union\s*([_\w]+))'; 225 228 my $type_member_xml = '\&amp;([_\w]+)(\.|-\&gt;)([_\w]+)'; 229 + my $type_fallback_xml = '\&amp([_\w]+)'; 226 230 my $type_member_func = $type_member . '\(\)'; 227 231 228 232 # Output conversion substitutions. ··· 236 232 my @highlights_html = ( 237 233 [$type_constant, "<i>\$1</i>"], 238 234 [$type_func, "<b>\$1</b>"], 235 + [$type_enum_xml, "<i>\$1</i>"], 239 236 [$type_struct_xml, "<i>\$1</i>"], 237 + [$type_typedef_xml, "<i>\$1</i>"], 238 + [$type_union_xml, "<i>\$1</i>"], 240 239 [$type_env, "<b><i>\$1</i></b>"], 241 240 [$type_param, "<tt><b>\$1</b></tt>"], 242 - [$type_member_xml, "<tt><i>\$1</i>\$2\$3</tt>"] 241 + [$type_member_xml, "<tt><i>\$1</i>\$2\$3</tt>"], 242 + [$type_fallback_xml, "<i>\$1</i>"] 243 243 ); 244 244 my $local_lt = "\\\\\\\\lt:"; 245 245 my $local_gt = "\\\\\\\\gt:"; ··· 253 245 my @highlights_html5 = ( 254 246 [$type_constant, "<span class=\"const\">\$1</span>"], 255 247 [$type_func, "<span class=\"func\">\$1</span>"], 248 + [$type_enum_xml, "<span class=\"enum\">\$1</span>"], 256 249 [$type_struct_xml, "<span class=\"struct\">\$1</span>"], 250 + [$type_typedef_xml, "<span class=\"typedef\">\$1</span>"], 251 + [$type_union_xml, "<span class=\"union\">\$1</span>"], 257 252 [$type_env, "<span class=\"env\">\$1</span>"], 258 253 [$type_param, "<span class=\"param\">\$1</span>]"], 259 - [$type_member_xml, "<span class=\"literal\"><span class=\"struct\">\$1</span>\$2<span class=\"member\">\$3</span></span>"] 254 + [$type_member_xml, "<span class=\"literal\"><span class=\"struct\">\$1</span>\$2<span class=\"member\">\$3</span></span>"], 255 + [$type_fallback_xml, "<span class=\"struct\">\$1</span>"] 260 256 ); 261 257 my $blankline_html5 = $local_lt . "br /" . $local_gt; 262 258 ··· 268 256 my @highlights_xml = ( 269 257 ["([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>"], 270 258 [$type_constant, "<constant>\$1</constant>"], 259 + [$type_enum_xml, "<type>\$1</type>"], 271 260 [$type_struct_xml, "<structname>\$1</structname>"], 261 + [$type_typedef_xml, "<type>\$1</type>"], 262 + [$type_union_xml, "<structname>\$1</structname>"], 272 263 [$type_param, "<parameter>\$1</parameter>"], 273 264 [$type_func, "<function>\$1</function>"], 274 265 [$type_env, "<envar>\$1</envar>"], 275 - [$type_member_xml, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"] 266 + [$type_member_xml, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"], 267 + [$type_fallback_xml, "<structname>\$1</structname>"] 276 268 ); 277 269 my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n"; 278 270 ··· 284 268 my @highlights_gnome = ( 285 269 [$type_constant, "<replaceable class=\"option\">\$1</replaceable>"], 286 270 [$type_func, "<function>\$1</function>"], 271 + [$type_enum, "<type>\$1</type>"], 287 272 [$type_struct, "<structname>\$1</structname>"], 273 + [$type_typedef, "<type>\$1</type>"], 274 + [$type_union, "<structname>\$1</structname>"], 288 275 [$type_env, "<envar>\$1</envar>"], 289 276 [$type_param, "<parameter>\$1</parameter>" ], 290 - [$type_member, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"] 277 + [$type_member, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"], 278 + [$type_fallback, "<structname>\$1</structname>"] 291 279 ); 292 280 my $blankline_gnome = "</para><para>\n"; 293 281 ··· 299 279 my @highlights_man = ( 300 280 [$type_constant, "\$1"], 301 281 [$type_func, "\\\\fB\$1\\\\fP"], 282 + [$type_enum, "\\\\fI\$1\\\\fP"], 302 283 [$type_struct, "\\\\fI\$1\\\\fP"], 284 + [$type_typedef, "\\\\fI\$1\\\\fP"], 285 + [$type_union, "\\\\fI\$1\\\\fP"], 303 286 [$type_param, "\\\\fI\$1\\\\fP"], 304 - [$type_member, "\\\\fI\$1\$2\$3\\\\fP"] 287 + [$type_member, "\\\\fI\$1\$2\$3\\\\fP"], 288 + [$type_fallback, "\\\\fI\$1\\\\fP"] 305 289 ); 306 290 my $blankline_man = ""; 307 291 ··· 313 289 my @highlights_text = ( 314 290 [$type_constant, "\$1"], 315 291 [$type_func, "\$1"], 292 + [$type_enum, "\$1"], 316 293 [$type_struct, "\$1"], 294 + [$type_typedef, "\$1"], 295 + [$type_union, "\$1"], 317 296 [$type_param, "\$1"], 318 - [$type_member, "\$1\$2\$3"] 297 + [$type_member, "\$1\$2\$3"], 298 + [$type_fallback, "\$1"] 319 299 ); 320 300 my $blankline_text = ""; 321 301 ··· 331 303 [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"], 332 304 [$type_fp_param, "**\$1\\\\(\\\\)**"], 333 305 [$type_func, "\\:c\\:func\\:`\$1()`"], 334 - [$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], 335 - [$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], 336 - [$type_typedef_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], 337 - [$type_union_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], 306 + [$type_enum, "\\:c\\:type\\:`\$1 <\$2>`"], 307 + [$type_struct, "\\:c\\:type\\:`\$1 <\$2>`"], 308 + [$type_typedef, "\\:c\\:type\\:`\$1 <\$2>`"], 309 + [$type_union, "\\:c\\:type\\:`\$1 <\$2>`"], 338 310 # in rst this can refer to any type 339 - [$type_struct, "\\:c\\:type\\:`\$1`"], 311 + [$type_fallback, "\\:c\\:type\\:`\$1`"], 340 312 [$type_param, "**\$1**"] 341 313 ); 342 314 my $blankline_rst = "\n"; ··· 345 317 my @highlights_list = ( 346 318 [$type_constant, "\$1"], 347 319 [$type_func, "\$1"], 320 + [$type_enum, "\$1"], 348 321 [$type_struct, "\$1"], 322 + [$type_typedef, "\$1"], 323 + [$type_union, "\$1"], 349 324 [$type_param, "\$1"], 350 - [$type_member, "\$1"] 325 + [$type_member, "\$1"], 326 + [$type_fallback, "\$1"] 351 327 ); 352 328 my $blankline_list = ""; 353 329