KVM: x86: Move vendor CR4 validity check to dedicated kvm_x86_ops hook
[linux-2.6-microblaze.git] / scripts / get_abi.pl
index 5612f01..68dab82 100755 (executable)
@@ -3,6 +3,7 @@
 
 use strict;
 use warnings;
+use utf8;
 use Pod::Usage;
 use Getopt::Long;
 use File::Find;
@@ -17,7 +18,7 @@ my $prefix="Documentation/ABI";
 #
 # If true, assumes that the description is formatted with ReST
 #
-my $description_is_rst = 0;
+my $description_is_rst = 1;
 
 GetOptions(
        "debug|d+" => \$debug,
@@ -49,7 +50,15 @@ my %symbols;
 sub parse_error($$$$) {
        my ($file, $ln, $msg, $data) = @_;
 
-       print STDERR "file $file#$ln: $msg at\n\t$data";
+       $data =~ s/\s+$/\n/;
+
+       print STDERR "Warning: file $file#$ln:\n\t$msg";
+
+       if ($data ne "") {
+               print STDERR ". Line\n\t\t$data";
+       } else {
+           print STDERR "\n";
+       }
 }
 
 #
@@ -109,7 +118,7 @@ sub parse_abi {
 
                        # Invalid, but it is a common mistake
                        if ($new_tag eq "where") {
-                               parse_error($file, $ln, "tag 'Where' is invalid. Should be 'What:' instead", $_);
+                               parse_error($file, $ln, "tag 'Where' is invalid. Should be 'What:' instead", "");
                                $new_tag = "what";
                        }
 
@@ -224,7 +233,7 @@ sub parse_abi {
                }
 
                # Everything else is error
-               parse_error($file, $ln, "Unexpected line:", $_);
+               parse_error($file, $ln, "Unexpected content", $_);
        }
        $data{$nametag}->{description} =~ s/^\n+// if ($data{$nametag}->{description});
        if ($what) {
@@ -272,9 +281,14 @@ sub create_labels {
 # Outputs the book on ReST format
 #
 
+# \b doesn't work well with paths. So, we need to define something else
+my $bondary = qr { (?<![\w\/\`\{])(?=[\w\/\`\{])|(?<=[\w\/\`\{])(?![\w\/\`\{]) }x;
+
 sub output_rest {
        create_labels();
 
+       my $part = "";
+
        foreach my $what (sort {
                                ($data{$a}->{type} eq "File") cmp ($data{$b}->{type} eq "File") ||
                                $a cmp $b
@@ -294,17 +308,31 @@ sub output_rest {
                $w =~ s/([\(\)\_\-\*\=\^\~\\])/\\$1/g;
 
                if ($type ne "File") {
+                       my $cur_part = $what;
+                       if ($what =~ '/') {
+                               if ($what =~ m#^(\/?(?:[\w\-]+\/?){1,2})#) {
+                                       $cur_part = "Symbols under $1";
+                                       $cur_part =~ s,/$,,;
+                               }
+                       }
+
+                       if ($cur_part ne "" && $part ne $cur_part) {
+                           $part = $cur_part;
+                           my $bar = $part;
+                           $bar =~ s/./-/g;
+                           print "$part\n$bar\n\n";
+                       }
+
                        printf ".. _%s:\n\n", $data{$what}->{label};
 
                        my @names = split /, /,$w;
                        my $len = 0;
 
                        foreach my $name (@names) {
+                               $name = "**$name**";
                                $len = length($name) if (length($name) > $len);
                        }
 
-                       print "What:\n\n";
-
                        print "+-" . "-" x $len . "-+\n";
                        foreach my $name (@names) {
                                printf "| %s", $name . " " x ($len - length($name)) . " |\n";
@@ -341,6 +369,39 @@ sub output_rest {
 
                if (!($desc =~ /^\s*$/)) {
                        if ($description_is_rst) {
+                               # Remove title markups from the description
+                               # Having titles inside ABI files will only work if extra
+                               # care would be taken in order to strictly follow the same
+                               # level order for each markup.
+                               $desc =~ s/\n[\-\*\=\^\~]+\n/\n\n/g;
+
+                               # Enrich text by creating cross-references
+
+                               $desc =~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g;
+
+                               my @matches = $desc =~ m,Documentation/ABI/([\w\/\-]+),;
+                               foreach my $f (@matches) {
+                                       my $xref = $f;
+                                       my $path = $f;
+                                       $path =~ s,.*/(.*/.*),$1,;;
+                                       $path =~ s,[/\-],_,g;;
+                                       $xref .= " <abi_file_" . $path . ">";
+                                       $desc =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g;
+                               }
+
+                               @matches = $desc =~ m,$bondary(/sys/[^\s\.\,\;\:\*\s\`\'\(\)]+)$bondary,;
+
+                               foreach my $s (@matches) {
+                                       if (defined($data{$s}) && defined($data{$s}->{label})) {
+                                               my $xref = $s;
+
+                                               $xref =~ s/([\x00-\x1f\x21-\x2f\x3a-\x40\x7b-\xff])/\\$1/g;
+                                               $xref = ":ref:`$xref <" . $data{$s}->{label} . ">`";
+
+                                               $desc =~ s,$bondary$s$bondary,$xref,g;
+                                       }
+                               }
+
                                print "$desc\n\n";
                        } else {
                                $desc =~ s/^\s+//;