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

[SCM] Debian package checker branch, master, updated. 2.1.0-21-gd15f010



The following commit has been merged in the master branch:
commit dc269f89c72ed48631a23738f64b5720dfaf4472
Author: Adam D. Barratt <adam@adam-barratt.org.uk>
Date:   Sun Dec 7 15:24:06 2008 +0000

    Split read_tag_info() in two and separate out the formatting work.
    
    Move the work of formatting a tag's description to a separate function so
    that it can be called from multiple locations.

diff --git a/lib/Read_taginfo.pm b/lib/Read_taginfo.pm
index dbcd464..cade0ec 100644
--- a/lib/Read_taginfo.pm
+++ b/lib/Read_taginfo.pm
@@ -41,8 +41,6 @@ sub read_tag_info {
     my %tag_info;
     if (defined $type && $type eq 'html') {
 	$dtml_convert = \&dtml_to_html;
-    } else {
-	$dtml_convert = \&dtml_to_text;
     }
 
  #   $debug = 2;
@@ -54,35 +52,51 @@ sub read_tag_info {
 
 	for (my $i=1; $i<=$#secs; $i++) {
 	    (my $tag = $secs[$i]->{'tag'}) or fail("error in description file $f: section $i does not have a `Tag:'");
-
-	    my @foo = split_paragraphs($secs[$i]->{'info'});
-	    if ($secs[$i]->{'ref'}) {
-		push(@foo,"");
-		push(@foo,format_ref($secs[$i]->{'ref'}));
-	    }
-
-	    if ($secs[$i]->{'severity'} and $secs[$i]->{'certainty'}) {
-		push(@foo, "");
-		push(@foo, "Severity: $secs[$i]->{'severity'}; " .
-		           "Certainty: $secs[$i]->{'certainty'}");
-	    }
-
-	    if ($secs[$i]->{'experimental'}) {
-		push(@foo,"");
-		push(@foo,"Please note that this tag is marked Experimental, which "
-		     . "means that the code that generates it is not as well tested "
-		     . "as the rest of Lintian, and might still give surprising "
-		     . "results.  Feel free to ignore Experimental tags that do not "
-		     . "seem to make sense, though of course bug reports are always "
-		     . "welcomed.");
-	    }
-
-	    $tag_info{$tag} = join("\n",&$dtml_convert(@foo));
+	    $tag_info{$tag} = format_tag_description($secs[$i], 0, $dtml_convert);
 	}
     }
+
     return \%tag_info;
 }
 
+sub format_tag_description {
+    my $tag=shift;
+    my $indent=shift;
+    my $dtml_convert=shift;
+
+    if (not defined $dtml_convert) {
+	$dtml_convert = \&dtml_to_text;
+    }
+
+    my @foo = split_paragraphs($tag->{'info'});
+    if ($tag->{'ref'}) {
+	push(@foo,"");
+	push(@foo,format_ref($tag->{'ref'}));
+    }
+
+    if ($tag->{'severity'} and $tag->{'certainty'}) {
+	push(@foo, "");
+	push(@foo, "Severity: $tag->{'severity'}; " .
+	           "Certainty: $tag->{'certainty'}");
+    }
+
+    if ($tag->{'experimental'}) {
+	push(@foo,"");
+	push(@foo,"Please note that this tag is marked Experimental, which "
+	     . "means that the code that generates it is not as well tested "
+	     . "as the rest of Lintian, and might still give surprising "
+	     . "results.  Feel free to ignore Experimental tags that do not "
+	     . "seem to make sense, though of course bug reports are always "
+	     . "welcomed.");
+    }
+
+    if ($indent) {
+	return wrap_paragraphs(" " x $indent, join("\n",&$dtml_convert(@foo)));
+    } else {
+	return join("\n",&$dtml_convert(@foo));
+    }
+}
+
 sub manual_ref {
     my ($man, $sub) = @_;
     my $numbered = ($sub =~ /[A-Z\d\.]+/) ? 1 : 0;

-- 
Debian package checker


Reply to: