⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kernel-doc

📁 这是Linux环境下的openobex
💻
📖 第 1 页 / 共 2 页
字号:
#    if ($#{$args{'parameterlist'}} >= 0) {#	print " <variablelist>\n";#	foreach $parameter (@{$args{'parameterlist'}}) {#	    print "  <varlistentry>\n   <term><parameter>$parameter</parameter></term>\n";#	    print "   <listitem>\n    <para>\n";#	    $lineprefix="     ";#	    output_highlight($args{'parameters'}{$parameter});#	    print "    </para>\n   </listitem>\n  </varlistentry>\n";#	}#	print " </variablelist>\n";#    } else {#	print " <para>\n  None\n </para>\n";#    }#    print "</simplesect>\n";#    print "<simplesect>\n <title>Arguments</title>\n";    if ($#{$args{'parameterlist'}} >= 0) {	print " <informaltable pgwide=\"1\" frame=\"none\" role=\"params\">\n";	print "<tgroup cols=\"2\">\n";	print "<colspec colwidth=\"2*\">\n";	print "<colspec colwidth=\"8*\">\n";	print "<tbody>\n";	foreach $parameter (@{$args{'parameterlist'}}) {	    print "  <row><entry align=\"right\"><parameter>$parameter</parameter></entry>\n";	    print "   <entry>\n";	    $lineprefix="     ";	    output_highlight($args{'parameters'}{$parameter});	    print "    </entry></row>\n";	}	print " </tbody></tgroup></informaltable>\n";    } else {	print " <para>\n  None\n </para>\n";    }#    print "</simplesect>\n";    # print out each section    $lineprefix="   ";    foreach $section (@{$args{'sectionlist'}}) {	print "<simplesect>\n <title>$section</title>\n";#	print "<para>\n$section\n";	if ($section =~ m/EXAMPLE/i) {	    print "<example><programlisting>\n";	} else {	}	print "<para>\n";	output_highlight($args{'sections'}{$section});#	print "</para>";	print "</para>\n";	if ($section =~ m/EXAMPLE/i) {	    print "</programlisting></example>\n";	} else {	}	print " </simplesect>\n";    }    print "</sect2>\n\n";}### output in mansub output_man {    my %args = %{$_[0]};    my ($parameter, $section);    my $count;    print ".TH \"$args{'module'}\" 4 \"$args{'function'}\" \"25 May 1998\" \"API Manual\" LINUX\n";    print ".SH NAME\n";    print $args{'function'}." \\- ".$args{'purpose'}."\n";    print ".SH SYNOPSIS\n";    print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n";    $count = 0;    $parenth = "(";    $post = ",";    foreach $parameter (@{$args{'parameterlist'}}) {	if ($count == $#{$args{'parameterlist'}}) {	    $post = ");";	}	$type = $args{'parametertypes'}{$parameter};	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {	    # pointer-to-function	    print ".BI \"".$parenth.$1."\" ".$parameter." \") (".$2.")".$post."\"\n";	} else {	    $type =~ s/([^\*])$/\1 /;	    print ".BI \"".$parenth.$type."\" ".$parameter." \"".$post."\"\n";	}	$count++;	$parenth = "";    }    print ".SH Arguments\n";    foreach $parameter (@{$args{'parameterlist'}}) {	print ".IP \"".$parameter."\" 12\n";	output_highlight($args{'parameters'}{$parameter});    }    foreach $section (@{$args{'sectionlist'}}) {	print ".SH \"$section\"\n";	output_highlight($args{'sections'}{$section});    }}sub output_intro_man {    my %args = %{$_[0]};    my ($parameter, $section);    my $count;    print ".TH \"$args{'module'}\" 4 \"$args{'module'}\" \"25 May 1998\" \"API Manual\" LINUX\n";    foreach $section (@{$args{'sectionlist'}}) {	print ".SH \"$section\"\n";	output_highlight($args{'sections'}{$section});    }}### output in textsub output_text {    my %args = %{$_[0]};    my ($parameter, $section);    print "Function:\n\n";    $start=$args{'functiontype'}." ".$args{'function'}." (";    print $start;    $count = 0;    foreach $parameter (@{$args{'parameterlist'}}) {	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {	    # pointer-to-function	    print $1.$parameter.") (".$2;	} else {	    print $type." ".$parameter;	}	if ($count != $#{$args{'parameterlist'}}) {	    $count++;	    print ",\n";	    print " " x length($start);	} else {	    print ");\n\n";	}    }    print "Arguments:\n\n";    foreach $parameter (@{$args{'parameterlist'}}) {	print $parameter."\n\t".$args{'parameters'}{$parameter}."\n";    }    foreach $section (@{$args{'sectionlist'}}) {	print "$section:\n\n";	output_highlight($args{'sections'}{$section});    }    print "\n\n";}sub output_intro_text {    my %args = %{$_[0]};    my ($parameter, $section);    foreach $section (@{$args{'sectionlist'}}) {	print " $section:\n";	print "    -> ";	output_highlight($args{'sections'}{$section});    }}### generic output function - calls the right one based# on current output mode.sub output_function {#    output_html(@_);    eval "output_".$output_mode."(\@_);";}### generic output function - calls the right one based# on current output mode.sub output_intro {#    output_html(@_);    eval "output_intro_".$output_mode."(\@_);";}### takes a function prototype and spits out all the details# stored in the global arrays/hsahes.sub dump_function {    my $prototype = shift @_;    $prototype =~ s/^static+ //;    $prototype =~ s/^extern+ //;    $prototype =~ s/^inline+ //;    $prototype =~ s/^__inline__+ //;    if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||	$prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||	$prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||	$prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||	$prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/)  {	$return_type = $1;	$function_name = $2;	$args = $3;	# allow for up to fours args to function pointers	$args =~ s/(\([^\),]+),/\1#/g;	$args =~ s/(\([^\),]+),/\1#/g;	$args =~ s/(\([^\),]+),/\1#/g;#	print STDERR "ARGS = '$args'\n";	foreach $arg (split ',', $args) {	    # strip leading/trailing spaces	    $arg =~ s/^\s*//;	    $arg =~ s/\s*$//;	    if ($arg =~ m/\(/) {		# pointer-to-function		$arg =~ tr/#/,/;		$arg =~ m/[^\(]+\(\*([^\)]+)\)/;		$param = $1;		$type = $arg;		$type =~ s/([^\(]+\(\*)$param/\1/;	    } else {		# evil magic to get fixed array parameters to work		$arg =~ s/(.+\s+)(.+)\[.*/\1* \2/;#		print STDERR "SCAN ARG: '$arg'\n";		@args = split('\s', $arg);#		print STDERR " -> @args\n";		$param = pop @args;#		print STDERR " -> @args\n";		if ($param =~ m/^(\*+)(.*)/) {		    $param = $2;		    push @args, $1;		}		$type = join " ", @args;	    }	    if ($type eq "" && $param eq "...")	    {		$type="...";		$param="...";		$parameters{"..."} = "variable arguments";	    }	    if ($type eq "")	    {		$type="";		$param="void";		$parameters{void} = "no arguments";	    }            if ($parameters{$param} eq "") {	        $parameters{$param} = "-- undescribed --";	        print STDERR "Warning($file:$lineno): Function parameter '$param' not described in '$function_name'\n";	    }	    push @parameterlist, $param;	    $parametertypes{$param} = $type;#	    print STDERR "param = '$param', type = '$type'\n";	}    } else {	print STDERR "Error($lineno): cannot understand prototype: '$prototype'\n";	return;    }    if ($function_only==0 ||      ( $function_only == 1 && defined($function_table{$function_name})) ||      ( $function_only == 2 && !defined($function_table{$function_name})))    {	output_function({'function' => $function_name,			 'module' => $modulename,			 'functiontype' => $return_type,			 'parameterlist' => \@parameterlist,			 'parameters' => \%parameters,			 'parametertypes' => \%parametertypes,			 'sectionlist' => \@sectionlist,			 'sections' => \%sections,			 'purpose' => $function_purpose			 });    }}####################################################################### main# states# 0 - normal code# 1 - looking for function name# 2 - scanning field start.# 3 - scanning prototype.$state = 0;$section = "";$doc_special = "\@\%\$\&";$doc_start = "^/\\*\\*\$";$doc_end = "\\*/";$doc_com = "\\s*\\*\\s*";$doc_func = $doc_com."(\\w+):?";$doc_sect = $doc_com."([".$doc_special."]?[\\w ]+):(.*)";$doc_content = $doc_com."(.*)";$doc_block = $doc_com."DOC:\\s*(.*)?";%constants = ();%parameters = ();@parameterlist = ();%sections = ();@sectionlist = ();$contents = "";$section_default = "Description";	# default section$section_intro = "Introduction";$section = $section_default;$lineno = 0;foreach $file (@ARGV) {    chomp($file);    if (!open(IN,"<$file")) {	print STDERR "Error: Cannot open file $file\n";	next;    }    while (<IN>) {	$lineno++;	if ($state == 0) {	    if (/$doc_start/o) {		$state = 1;		# next line is always the function name	    }	} elsif ($state == 1) {	# this line is the function name (always)	    if (/$doc_block/o) {		$state = 4;		$contents = "";		if ( $1 eq "" ) {			$section = $section_intro;		} else {			$section = $1;		}            }	    elsif (/$doc_func/o) {		$function = $1;		$state = 2;		if (/-(.*)/) {		    $function_purpose = $1;		} else {		    $function_purpose = "";		}		if ($verbose) {		    print STDERR "Info($lineno): Scanning doc for $function\n";		}	    } else {		print STDERR "WARN($lineno): Cannot understand $_ on line $lineno",		" - I thought it was a doc line\n";		$state = 0;	    }	} elsif ($state == 2) {	# look for head: lines, and include content	    if (/$doc_sect/o) {		$newsection = $1;		$newcontents = $2;		if ($contents ne "") {		    $contents =~ s/\&/\\\\\\amp;/g;		    $contents =~ s/\</\\\\\\lt;/g;		    $contents =~ s/\>/\\\\\\gt;/g;		    dump_section($section, $contents);		    $section = $section_default;		}		$contents = $newcontents;		if ($contents ne "") {		    $contents .= "\n";		}		$section = $newsection;	    } elsif (/$doc_end/) {		if ($contents ne "") {		    $contents =~ s/\&/\\\\\\amp;/g;		    $contents =~ s/\</\\\\\\lt;/g;		    $contents =~ s/\>/\\\\\\gt;/g;		    dump_section($section, $contents);		    $section = $section_default;		    $contents = "";		}#	    print STDERR "end of doc comment, looking for prototype\n";		$prototype = "";		$state = 3;	    } elsif (/$doc_content/) {		# miguel-style comment kludge, look for blank lines after		# @parameter line to signify start of description		if ($1 eq "" && $section =~ m/^@/) {		    $contents =~ s/\&/\\\\\\amp;/g;		    $contents =~ s/\</\\\\\\lt;/g;		    $contents =~ s/\>/\\\\\\gt;/g;		    dump_section($section, $contents);		    $section = $section_default;		    $contents = "";		} else {		    $contents .= $1."\n";		}	    } else {		# i dont know - bad line?  ignore.		print STDERR "WARNING($lineno): bad line: $_"; 	    }	} elsif ($state == 3) {	# scanning for function { (end of prototype)	    if (m#\s*/\*\s+MACDOC\s*#io) {	      # do nothing	    }	    elsif (/([^\{]*)/) {		$prototype .= $1;	    }	    if (/\{/) {		$prototype =~ s@/\*.*?\*/@@gos;	# strip comments.		$prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.		$prototype =~ s@^ +@@gos; # strip leading spaces		dump_function($prototype);		$function = "";		%constants = ();		%parameters = ();		%parametertypes = ();		@parameterlist = ();		%sections = ();		@sectionlist = ();		$prototype = "";		$state = 0;	    }	} elsif ($state == 4) {		# Documentation block	        if (/$doc_block/) {			dump_section($section, $contents);			output_intro({'sectionlist' => \@sectionlist,				      'sections' => \%sections });			$contents = "";			$function = "";			%constants = ();			%parameters = ();			%parametertypes = ();			@parameterlist = ();			%sections = ();			@sectionlist = ();			$prototype = "";			if ( $1 eq "" ) {				$section = $section_intro;			} else {				$section = $1;			}                }		elsif (/$doc_end/)		{			dump_section($section, $contents);			output_intro({'sectionlist' => \@sectionlist,				      'sections' => \%sections });			$contents = "";			$function = "";			%constants = ();			%parameters = ();			%parametertypes = ();			@parameterlist = ();			%sections = ();			@sectionlist = ();			$prototype = "";			$state = 0;		}		elsif (/$doc_content/)		{			if ( $1 eq "" )			{				$contents .= $blankline;			}			else			{				$contents .= $1 . "\n";			}	        	}          }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -