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

kernel-doc: make member highlighting available in all backends

Note that, in order to produce the correct Docbook markup, the "." or "->"
must be separated from the member name in the regex's captured fields. For
consistency, this change is applied to $type_member and $type_member_func
too, not just to $type_member_xml.

List mode only prints the struct name, to avoid any undesired change in
the operation of docproc.

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
5267dd35 fc6d7af8

+19 -11
+19 -11
scripts/kernel-doc
··· 199 199 # 'funcname()' - function 200 200 # '$ENVVAR' - environmental variable 201 201 # '&struct_name' - name of a structure (up to two words including 'struct') 202 + # '&struct_name.member' - name of a structure member 202 203 # '@parameter' - name of a parameter 203 204 # '%CONST' - name of a constant. 204 205 205 206 ## init lots of data 206 - 207 207 208 208 my $errors = 0; 209 209 my $warnings = 0; ··· 221 221 my $type_struct_full = '\&(struct)\s*([_\w]+)'; 222 222 my $type_typedef_full = '\&(typedef)\s*([_\w]+)'; 223 223 my $type_union_full = '\&(union)\s*([_\w]+)'; 224 - my $type_member = '\&([_\w]+)((\.|->)[_\w]+)'; 224 + my $type_member = '\&([_\w]+)(\.|->)([_\w]+)'; 225 + my $type_member_xml = '\&amp;([_\w]+)(\.|-\&gt;)([_\w]+)'; 225 226 my $type_member_func = $type_member . '\(\)'; 226 227 227 228 # Output conversion substitutions. ··· 234 233 [$type_func, "<b>\$1</b>"], 235 234 [$type_struct_xml, "<i>\$1</i>"], 236 235 [$type_env, "<b><i>\$1</i></b>"], 237 - [$type_param, "<tt><b>\$1</b></tt>"] 236 + [$type_param, "<tt><b>\$1</b></tt>"], 237 + [$type_member_xml, "<tt><i>\$1</i>\$2\$3</tt>"] 238 238 ); 239 239 my $local_lt = "\\\\\\\\lt:"; 240 240 my $local_gt = "\\\\\\\\gt:"; ··· 247 245 [$type_func, "<span class=\"func\">\$1</span>"], 248 246 [$type_struct_xml, "<span class=\"struct\">\$1</span>"], 249 247 [$type_env, "<span class=\"env\">\$1</span>"], 250 - [$type_param, "<span class=\"param\">\$1</span>]"] 248 + [$type_param, "<span class=\"param\">\$1</span>]"], 249 + [$type_member_xml, "<span class=\"literal\"><span class=\"struct\">\$1</span>\$2<span class=\"member\">\$3</span></span>"] 251 250 ); 252 251 my $blankline_html5 = $local_lt . "br /" . $local_gt; 253 252 ··· 259 256 [$type_struct_xml, "<structname>\$1</structname>"], 260 257 [$type_param, "<parameter>\$1</parameter>"], 261 258 [$type_func, "<function>\$1</function>"], 262 - [$type_env, "<envar>\$1</envar>"] 259 + [$type_env, "<envar>\$1</envar>"], 260 + [$type_member_xml, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"] 263 261 ); 264 262 my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n"; 265 263 ··· 270 266 [$type_func, "<function>\$1</function>"], 271 267 [$type_struct, "<structname>\$1</structname>"], 272 268 [$type_env, "<envar>\$1</envar>"], 273 - [$type_param, "<parameter>\$1</parameter>" ] 269 + [$type_param, "<parameter>\$1</parameter>" ], 270 + [$type_member, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"] 274 271 ); 275 272 my $blankline_gnome = "</para><para>\n"; 276 273 ··· 280 275 [$type_constant, "\$1"], 281 276 [$type_func, "\\\\fB\$1\\\\fP"], 282 277 [$type_struct, "\\\\fI\$1\\\\fP"], 283 - [$type_param, "\\\\fI\$1\\\\fP"] 278 + [$type_param, "\\\\fI\$1\\\\fP"], 279 + [$type_member, "\\\\fI\$1\$2\$3\\\\fP"] 284 280 ); 285 281 my $blankline_man = ""; 286 282 ··· 290 284 [$type_constant, "\$1"], 291 285 [$type_func, "\$1"], 292 286 [$type_struct, "\$1"], 293 - [$type_param, "\$1"] 287 + [$type_param, "\$1"], 288 + [$type_member, "\$1\$2\$3"] 294 289 ); 295 290 my $blankline_text = ""; 296 291 ··· 299 292 my @highlights_rst = ( 300 293 [$type_constant, "``\$1``"], 301 294 # Note: need to escape () to avoid func matching later 302 - [$type_member_func, "\\:c\\:type\\:`\$1\$2\\\\(\\\\) <\$1>`"], 303 - [$type_member, "\\:c\\:type\\:`\$1\$2 <\$1>`"], 295 + [$type_member_func, "\\:c\\:type\\:`\$1\$2\$3\\\\(\\\\) <\$1>`"], 296 + [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"], 304 297 [$type_fp_param, "**\$1\\\\(\\\\)**"], 305 298 [$type_func, "\\:c\\:func\\:`\$1()`"], 306 299 [$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], ··· 318 311 [$type_constant, "\$1"], 319 312 [$type_func, "\$1"], 320 313 [$type_struct, "\$1"], 321 - [$type_param, "\$1"] 314 + [$type_param, "\$1"], 315 + [$type_member, "\$1"] 322 316 ); 323 317 my $blankline_list = ""; 324 318