[gtk-doc] fixxref: add warning about broken links. Fixes #602026



commit 2415121e8f5f7f6e3ce325c8bdad47287b206b9b
Author: Stefan Kost <ensonic users sf net>
Date:   Wed Nov 25 12:26:07 2009 +0200

    fixxref: add warning about broken links. Fixes #602026
    
    Produce less links (e.g. for symbols with spaces). Add a log warning for first
    time use of non xrefable links (no line number :/).

 gtkdoc-common.pl.in |    2 ++
 gtkdoc-fixxref.in   |   22 +++++++++++++++++++---
 gtkdoc-mkdb.in      |   10 +++++++++-
 3 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/gtkdoc-common.pl.in b/gtkdoc-common.pl.in
index 2d6d75a..5b014cf 100644
--- a/gtkdoc-common.pl.in
+++ b/gtkdoc-common.pl.in
@@ -359,6 +359,8 @@ sub CreateValidSGMLID {
     $id =~ s/:/--/g;
 
     # Append ":CAPS" to all all-caps identifiers
+    # FIXME: there are some inconsistencies here, we have sgml.index files
+    # containing e.g. TRUE--CAPS
     if ($id !~ /[a-z]/ && $id !~ /-CAPS$/) { $id .= ":CAPS" };
 
     return $id;
diff --git a/gtkdoc-fixxref.in b/gtkdoc-fixxref.in
index 90727a9..b7f6ef7 100755
--- a/gtkdoc-fixxref.in
+++ b/gtkdoc-fixxref.in
@@ -77,6 +77,19 @@ my %Links;
 # This hold the path entries we already scanned
 my @VisitedPaths;
 
+# failing link targets we don't warn about even once
+my %NoLinks = (
+    'char'  => 1,
+    'double'  => 1,
+    'float'  => 1,
+    'int'  => 1,
+    'long'  => 1,
+    'main'  => 1,
+    'signed'  => 1,
+    'unsigned'  => 1,
+    'void'  => 1,
+    'GInterface' => 1
+    );
 
 my $path_prefix="";
 if ($HTML_DIR =~ m%(.*?)/share/gtk-doc/html%) {
@@ -254,7 +267,7 @@ sub FixHTMLFile {
         $entire_file =~ s%(<span class=\"normal\">\s*)(.+?)((\s+.+?)?\s*</span>)%&MakeGtkDocLink($1,$2,$3);%gse;
     }
 
-    $entire_file =~ s%<GTKDOCLINK\s+HREF="([^"]*)"\s*>(.*?)</GTKDOCLINK\s*>% &MakeXRef($1,$2); %gse;
+    $entire_file =~ s%<GTKDOCLINK\s+HREF="([^"]*)"\s*>(.*?)</GTKDOCLINK\s*>% &MakeXRef($file, $1,$2); %gse;
 
     open (NEWFILE, ">$file.new")
 	|| die "Can't open $file: $!";
@@ -267,9 +280,8 @@ sub FixHTMLFile {
 	|| die "Can't rename $file.new: $!";
 }
 
-
 sub MakeXRef {
-    my ($id, $text) = @_;
+    my ($file, $id, $text) = @_;
 
     my $href = $Links{$id};
 
@@ -283,6 +295,10 @@ sub MakeXRef {
         return "<a href=\"$href\">$text</a>";
     } else {
         #print "  no link for: $id, $text\n";
+        if (!exists($NoLinks{$id})) {
+          &LogWarning ($file, 1, "no link for: '$id' -> ($text).");
+          $NoLinks{$id} = 1;
+        }
 	return $text;
     }
 }
diff --git a/gtkdoc-mkdb.in b/gtkdoc-mkdb.in
index 132f115..44b0f72 100755
--- a/gtkdoc-mkdb.in
+++ b/gtkdoc-mkdb.in
@@ -2568,6 +2568,10 @@ sub tagify {
 
 sub MakeXRef {
     my ($symbol, $text) = ($_[0], $_[1]);
+
+    $symbol =~ s/^\s+//;
+    $symbol =~ s/\s+$//;
+
     if (!defined($text)) {
 	$text = $symbol;
 
@@ -2575,6 +2579,10 @@ sub MakeXRef {
 	$text =~ s/-struct$//;
     }
 
+    if ($symbol =~ m/ /) {
+        return "$text";
+    }
+
     #print "Getting type link for $symbol -> $text\n";
 
     my $symbol_id = &CreateValidSGMLID ($symbol);
@@ -3022,7 +3030,7 @@ sub GetSignals {
                         }
                         else {
 		            $xref = &MakeXRef ($type);
-                            $pad = ' ' x ($type_len - length($type) - length($pointer));
+		            $pad = ' ' x ($type_len - length($type) - length($pointer));
 		            $desc .= "$xref$pad $pointer$name,\n";
 		            $desc .= (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
 			}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]