kernel-doc (fc6d7af89fa968c378d4437d7905ccd76efa6af4) kernel-doc (5267dd354bcd267f76d0f97193fe8a93899f8986)
1#!/usr/bin/perl -w
2
3use strict;
4
5## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
6## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
7## Copyright (C) 2001 Simon Huggins ##
8## Copyright (C) 2005-2012 Randy Dunlap ##

--- 185 unchanged lines hidden (view full) ---

194#
195#
196# All descriptive text is further processed, scanning for the following special
197# patterns, which are highlighted appropriately.
198#
199# 'funcname()' - function
200# '$ENVVAR' - environmental variable
201# '&struct_name' - name of a structure (up to two words including 'struct')
1#!/usr/bin/perl -w
2
3use strict;
4
5## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
6## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
7## Copyright (C) 2001 Simon Huggins ##
8## Copyright (C) 2005-2012 Randy Dunlap ##

--- 185 unchanged lines hidden (view full) ---

194#
195#
196# All descriptive text is further processed, scanning for the following special
197# patterns, which are highlighted appropriately.
198#
199# 'funcname()' - function
200# '$ENVVAR' - environmental variable
201# '&struct_name' - name of a structure (up to two words including 'struct')
202# '&struct_name.member' - name of a structure member
202# '@parameter' - name of a parameter
203# '%CONST' - name of a constant.
204
205## init lots of data
206
203# '@parameter' - name of a parameter
204# '%CONST' - name of a constant.
205
206## init lots of data
207
207
208my $errors = 0;
209my $warnings = 0;
210my $anon_struct_union = 0;
211
212# match expressions used to find embedded type information
213my $type_constant = '\%([-_\w]+)';
214my $type_func = '(\w+)\(\)';
215my $type_param = '\@(\w+(\.\.\.)?)';
216my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params
217my $type_struct = '\&((struct\s*)*[_\w]+)';
218my $type_struct_xml = '\\&amp;((struct\s*)*[_\w]+)';
219my $type_env = '(\$\w+)';
220my $type_enum_full = '\&(enum)\s*([_\w]+)';
221my $type_struct_full = '\&(struct)\s*([_\w]+)';
222my $type_typedef_full = '\&(typedef)\s*([_\w]+)';
223my $type_union_full = '\&(union)\s*([_\w]+)';
208my $errors = 0;
209my $warnings = 0;
210my $anon_struct_union = 0;
211
212# match expressions used to find embedded type information
213my $type_constant = '\%([-_\w]+)';
214my $type_func = '(\w+)\(\)';
215my $type_param = '\@(\w+(\.\.\.)?)';
216my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params
217my $type_struct = '\&((struct\s*)*[_\w]+)';
218my $type_struct_xml = '\\&amp;((struct\s*)*[_\w]+)';
219my $type_env = '(\$\w+)';
220my $type_enum_full = '\&(enum)\s*([_\w]+)';
221my $type_struct_full = '\&(struct)\s*([_\w]+)';
222my $type_typedef_full = '\&(typedef)\s*([_\w]+)';
223my $type_union_full = '\&(union)\s*([_\w]+)';
224my $type_member = '\&([_\w]+)((\.|->)[_\w]+)';
224my $type_member = '\&([_\w]+)(\.|->)([_\w]+)';
225my $type_member_xml = '\&amp;([_\w]+)(\.|-\&gt;)([_\w]+)';
225my $type_member_func = $type_member . '\(\)';
226
227# Output conversion substitutions.
228# One for each output format
229
230# these work fairly well
231my @highlights_html = (
232 [$type_constant, "<i>\$1</i>"],
233 [$type_func, "<b>\$1</b>"],
234 [$type_struct_xml, "<i>\$1</i>"],
235 [$type_env, "<b><i>\$1</i></b>"],
226my $type_member_func = $type_member . '\(\)';
227
228# Output conversion substitutions.
229# One for each output format
230
231# these work fairly well
232my @highlights_html = (
233 [$type_constant, "<i>\$1</i>"],
234 [$type_func, "<b>\$1</b>"],
235 [$type_struct_xml, "<i>\$1</i>"],
236 [$type_env, "<b><i>\$1</i></b>"],
236 [$type_param, "<tt><b>\$1</b></tt>"]
237 [$type_param, "<tt><b>\$1</b></tt>"],
238 [$type_member_xml, "<tt><i>\$1</i>\$2\$3</tt>"]
237 );
238my $local_lt = "\\\\\\\\lt:";
239my $local_gt = "\\\\\\\\gt:";
240my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>"
241
242# html version 5
243my @highlights_html5 = (
244 [$type_constant, "<span class=\"const\">\$1</span>"],
245 [$type_func, "<span class=\"func\">\$1</span>"],
246 [$type_struct_xml, "<span class=\"struct\">\$1</span>"],
247 [$type_env, "<span class=\"env\">\$1</span>"],
239 );
240my $local_lt = "\\\\\\\\lt:";
241my $local_gt = "\\\\\\\\gt:";
242my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>"
243
244# html version 5
245my @highlights_html5 = (
246 [$type_constant, "<span class=\"const\">\$1</span>"],
247 [$type_func, "<span class=\"func\">\$1</span>"],
248 [$type_struct_xml, "<span class=\"struct\">\$1</span>"],
249 [$type_env, "<span class=\"env\">\$1</span>"],
248 [$type_param, "<span class=\"param\">\$1</span>]"]
250 [$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>"]
249 );
250my $blankline_html5 = $local_lt . "br /" . $local_gt;
251
252# XML, docbook format
253my @highlights_xml = (
254 ["([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>"],
255 [$type_constant, "<constant>\$1</constant>"],
256 [$type_struct_xml, "<structname>\$1</structname>"],
257 [$type_param, "<parameter>\$1</parameter>"],
258 [$type_func, "<function>\$1</function>"],
252 );
253my $blankline_html5 = $local_lt . "br /" . $local_gt;
254
255# XML, docbook format
256my @highlights_xml = (
257 ["([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>"],
258 [$type_constant, "<constant>\$1</constant>"],
259 [$type_struct_xml, "<structname>\$1</structname>"],
260 [$type_param, "<parameter>\$1</parameter>"],
261 [$type_func, "<function>\$1</function>"],
259 [$type_env, "<envar>\$1</envar>"]
262 [$type_env, "<envar>\$1</envar>"],
263 [$type_member_xml, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"]
260 );
261my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n";
262
263# gnome, docbook format
264my @highlights_gnome = (
265 [$type_constant, "<replaceable class=\"option\">\$1</replaceable>"],
266 [$type_func, "<function>\$1</function>"],
267 [$type_struct, "<structname>\$1</structname>"],
268 [$type_env, "<envar>\$1</envar>"],
264 );
265my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n";
266
267# gnome, docbook format
268my @highlights_gnome = (
269 [$type_constant, "<replaceable class=\"option\">\$1</replaceable>"],
270 [$type_func, "<function>\$1</function>"],
271 [$type_struct, "<structname>\$1</structname>"],
272 [$type_env, "<envar>\$1</envar>"],
269 [$type_param, "<parameter>\$1</parameter>" ]
273 [$type_param, "<parameter>\$1</parameter>" ],
274 [$type_member, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"]
270 );
271my $blankline_gnome = "</para><para>\n";
272
273# these are pretty rough
274my @highlights_man = (
275 [$type_constant, "\$1"],
276 [$type_func, "\\\\fB\$1\\\\fP"],
277 [$type_struct, "\\\\fI\$1\\\\fP"],
275 );
276my $blankline_gnome = "</para><para>\n";
277
278# these are pretty rough
279my @highlights_man = (
280 [$type_constant, "\$1"],
281 [$type_func, "\\\\fB\$1\\\\fP"],
282 [$type_struct, "\\\\fI\$1\\\\fP"],
278 [$type_param, "\\\\fI\$1\\\\fP"]
283 [$type_param, "\\\\fI\$1\\\\fP"],
284 [$type_member, "\\\\fI\$1\$2\$3\\\\fP"]
279 );
280my $blankline_man = "";
281
282# text-mode
283my @highlights_text = (
284 [$type_constant, "\$1"],
285 [$type_func, "\$1"],
286 [$type_struct, "\$1"],
285 );
286my $blankline_man = "";
287
288# text-mode
289my @highlights_text = (
290 [$type_constant, "\$1"],
291 [$type_func, "\$1"],
292 [$type_struct, "\$1"],
287 [$type_param, "\$1"]
293 [$type_param, "\$1"],
294 [$type_member, "\$1\$2\$3"]
288 );
289my $blankline_text = "";
290
291# rst-mode
292my @highlights_rst = (
293 [$type_constant, "``\$1``"],
294 # Note: need to escape () to avoid func matching later
295 );
296my $blankline_text = "";
297
298# rst-mode
299my @highlights_rst = (
300 [$type_constant, "``\$1``"],
301 # Note: need to escape () to avoid func matching later
295 [$type_member_func, "\\:c\\:type\\:`\$1\$2\\\\(\\\\) <\$1>`"],
296 [$type_member, "\\:c\\:type\\:`\$1\$2 <\$1>`"],
302 [$type_member_func, "\\:c\\:type\\:`\$1\$2\$3\\\\(\\\\) <\$1>`"],
303 [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"],
297 [$type_fp_param, "**\$1\\\\(\\\\)**"],
298 [$type_func, "\\:c\\:func\\:`\$1()`"],
299 [$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
300 [$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
301 [$type_typedef_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
302 [$type_union_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
303 # in rst this can refer to any type
304 [$type_struct, "\\:c\\:type\\:`\$1`"],
305 [$type_param, "**\$1**"]
306 );
307my $blankline_rst = "\n";
308
309# list mode
310my @highlights_list = (
311 [$type_constant, "\$1"],
312 [$type_func, "\$1"],
313 [$type_struct, "\$1"],
304 [$type_fp_param, "**\$1\\\\(\\\\)**"],
305 [$type_func, "\\:c\\:func\\:`\$1()`"],
306 [$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
307 [$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
308 [$type_typedef_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
309 [$type_union_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
310 # in rst this can refer to any type
311 [$type_struct, "\\:c\\:type\\:`\$1`"],
312 [$type_param, "**\$1**"]
313 );
314my $blankline_rst = "\n";
315
316# list mode
317my @highlights_list = (
318 [$type_constant, "\$1"],
319 [$type_func, "\$1"],
320 [$type_struct, "\$1"],
314 [$type_param, "\$1"]
321 [$type_param, "\$1"],
322 [$type_member, "\$1"]
315 );
316my $blankline_list = "";
317
318# read arguments
319if ($#ARGV == -1) {
320 usage();
321}
322

--- 2843 unchanged lines hidden ---
323 );
324my $blankline_list = "";
325
326# read arguments
327if ($#ARGV == -1) {
328 usage();
329}
330

--- 2843 unchanged lines hidden ---