summaryrefslogtreecommitdiff
path: root/tools/pm
diff options
context:
space:
mode:
authorHagen Moebius <hagen.moebius@starschiffchen.de>2004-03-09 10:57:51 +0000
committerMurray Cumming <murrayc@src.gnome.org>2004-03-09 10:57:51 +0000
commitff438b108212aa1c40aebe26d1ce980d863e5cb3 (patch)
tree7f71e043a31a16a2dcefbfddbb7daca8a60c9822 /tools/pm
parent487990a6864d81ce05224f71525b029e52da4f0c (diff)
downloadglibmm-ff438b108212aa1c40aebe26d1ce980d863e5cb3.tar.gz
Another change to give better warnings and errors at gmmproc-runtime.
2004-04-08 Hagen Moebius <hagen.moebius@starschiffchen.de> * tools/pm/DocsParser.pm: Another change to give better warnings and errors at gmmproc-runtime. Further improvment of parsing parameter names to strip traling underscres. This not only for reference text, but for the parameter list also.
Diffstat (limited to 'tools/pm')
-rw-r--r--tools/pm/DocsParser.pm65
1 files changed, 43 insertions, 22 deletions
diff --git a/tools/pm/DocsParser.pm b/tools/pm/DocsParser.pm
index c00ad70c..b2048273 100644
--- a/tools/pm/DocsParser.pm
+++ b/tools/pm/DocsParser.pm
@@ -54,11 +54,12 @@ use warnings;
#####################################
+$DocsParser::CurrentFile = "";
$DocsParser::refAppendTo = undef; # string reference to store the data into
$DocsParser::currentParam = undef;
-$DocsParser::objCurrentFunction = 0; #Function
+$DocsParser::objCurrentFunction = undef; #Function
%DocsParser::hasharrayFunctions = (); #Function elements
#~ $DocsParser::bOverride = 0; #First we parse the C docs, then we parse the C++ override docs.
@@ -69,31 +70,41 @@ $DocsParser::commentEnd = " */";
sub read_defs($$$)
{
my ($path, $filename, $filename_override) = @_;
-
- # check that the file is there.
- my $filepath = "$path/$filename";
- if ( ! -r $filepath)
+
+ my $objParser = new XML::Parser(ErrorContext => 0);
+ $objParser->setHandlers(Start => \&parse_on_start, End => \&parse_on_end, Char => \&parse_on_cdata);
+
+ # C documentation:
+ $DocsParser::CurrentFile = "$path/$filename";
+ if ( ! -r $DocsParser::CurrentFile)
{
- print "DocsParser.pm: Error: can't read defs file $filename\n";
+ print "DocsParser.pm: Warning: Can't read file \"" . $DocsParser::CurrentFile . "\".\n";
return;
}
+ # Parse
+ eval { $objParser->parsefile($DocsParser::CurrentFile) };
+ if( $@ )
+ {
+ $@ =~ s/at \/.*?$//s;
+ print "\nError in \"" . $DocsParser::CurrentFile . "\":$@\n";
+ return;
+ }
- my $filepath_override = "$path/$filename_override";
- if ( ! -r $filepath_override)
+ # C++ overide documentation:
+ $DocsParser::CurrentFile = "$path/$filename_override";
+ if ( ! -r $DocsParser::CurrentFile)
{
- print "DocsParser.pm: Error: can't read defs file $filename_override\n";
+ print "DocsParser.pm: Warning: Can't read file \"" . $DocsParser::CurrentFile . "\".\n";
return;
}
-
- my $objParser = new XML::Parser();
- $objParser->setHandlers(Start => \&parse_on_start, End => \&parse_on_end, Char => \&parse_on_cdata);
-
- # Parse the C docs:
- $objParser->parsefile($filepath);
-
- # Parse the C++ overide docs:
- #~ $DocsParser::bOverride = 1; #The callbacks will act differently when this is set.
- $objParser->parsefile($filepath_override);
+ # Parse
+ eval { $objParser->parsefile($DocsParser::CurrentFile) };
+ if( $@ )
+ {
+ $@ =~ s/at \/.*?$//s;
+ print "\nError in \"" . $DocsParser::CurrentFile . "\":$@";
+ return;
+ }
}
sub parse_on_start($$%)
@@ -104,6 +115,11 @@ sub parse_on_start($$%)
if($tag eq "function")
{
+ if(defined $DocsParser::objCurrentFunction)
+ {
+ $objParser->xpcroak("\nClose a function tag before you open another one.");
+ }
+
my $functionName = $attr{name};
#Reuse existing Function, if it exists:
@@ -160,6 +176,10 @@ sub parse_on_start($$%)
{
$$DocsParser::objCurrentFunction{mapped_class} = $attr{class};
}
+ elsif($tag ne "root")
+ {
+ $objParser->xpcroak("\nUnknown tag \"$tag\".");
+ }
}
@@ -227,7 +247,7 @@ sub lookup_documentation($)
if(length($text) eq 0)
{
- print "DocsParser.pm: Warning: No C docs for function:$functionName :\n";
+ print "DocsParser.pm: Warning: No C docs for function: \"$functionName\"\n";
}
@@ -265,8 +285,9 @@ sub append_parameter_docs($$)
foreach my $param (@param_names)
{
my $desc = $$param_descriptions->{$param};
+
+ $param =~ s/([a-zA-Z0-9]*(_[a-zA-Z0-9]+)*)_?/$1/g;
DocsParser::convert_docs_to_cpp($obj_function, \$desc);
-
if(length($desc) > 0)
{
$desc .= '.' unless($desc =~ /(?:^|\.)$/);
@@ -322,7 +343,7 @@ sub convert_tags_to_doxygen($)
# Some argument names are suffixed by "_" -- strip this.
# gtk-doc uses @thearg, but doxygen uses @a thearg.
- s" ?\@(\w*[A-Za-z0-9])_?\b" \@a $1 "g;
+ s" ?\@([a-zA-Z0-9]*(_[a-zA-Z0-9]+)*)_?\b" \@a $1 "g;
s"^Note ?\d?: "\@note "mg;
s"&lt;/?programlisting&gt;""g;