blob: d134cc1692ee8fc1670f2fd7050183f341160c69 [file] [log] [blame]
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -03001#!/usr/bin/perl
Mauro Carvalho Chehabecb351f2019-06-20 14:23:10 -03002# SPDX-License-Identifier: GPL-2.0
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -03003
4use strict;
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +01005use warnings;
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -03006use Pod::Usage;
7use Getopt::Long;
8use File::Find;
9use Fcntl ':mode';
10
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +010011my $help = 0;
12my $man = 0;
13my $debug = 0;
14my $enable_lineno = 0;
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -030015my $prefix="Documentation/ABI";
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030016
Mauro Carvalho Chehab11ce90a2020-10-30 08:40:20 +010017#
18# If true, assumes that the description is formatted with ReST
19#
20my $description_is_rst = 0;
21
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030022GetOptions(
23 "debug|d+" => \$debug,
Mauro Carvalho Chehab61439c42020-10-30 08:40:22 +010024 "enable-lineno" => \$enable_lineno,
Mauro Carvalho Chehab11ce90a2020-10-30 08:40:20 +010025 "rst-source!" => \$description_is_rst,
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -030026 "dir=s" => \$prefix,
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030027 'help|?' => \$help,
28 man => \$man
29) or pod2usage(2);
30
31pod2usage(1) if $help;
32pod2usage(-exitstatus => 0, -verbose => 2) if $man;
33
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -030034pod2usage(2) if (scalar @ARGV < 1 || @ARGV > 2);
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030035
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -030036my ($cmd, $arg) = @ARGV;
37
Mauro Carvalho Chehab7ce7b892019-06-20 14:23:04 -030038pod2usage(2) if ($cmd ne "search" && $cmd ne "rest" && $cmd ne "validate");
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -030039pod2usage(2) if ($cmd eq "search" && !$arg);
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030040
41require Data::Dumper if ($debug);
42
43my %data;
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +010044my %symbols;
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030045
46#
47# Displays an error message, printing file name and line
48#
49sub parse_error($$$$) {
50 my ($file, $ln, $msg, $data) = @_;
51
52 print STDERR "file $file#$ln: $msg at\n\t$data";
53}
54
55#
56# Parse an ABI file, storing its contents at %data
57#
58sub parse_abi {
59 my $file = $File::Find::name;
60
61 my $mode = (stat($file))[2];
62 return if ($mode & S_IFDIR);
63 return if ($file =~ m,/README,);
64
65 my $name = $file;
66 $name =~ s,.*/,,;
67
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -030068 my $nametag = "File $name";
69 $data{$nametag}->{what} = "File $name";
70 $data{$nametag}->{type} = "File";
71 $data{$nametag}->{file} = $name;
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -030072 $data{$nametag}->{filepath} = $file;
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -030073 $data{$nametag}->{is_file} = 1;
Mauro Carvalho Chehab61439c42020-10-30 08:40:22 +010074 $data{$nametag}->{line_no} = 1;
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -030075
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030076 my $type = $file;
77 $type =~ s,.*/(.*)/.*,$1,;
78
79 my $what;
80 my $new_what;
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +010081 my $tag = "";
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030082 my $ln;
Mauro Carvalho Chehab6619c662019-06-20 14:22:56 -030083 my $xrefs;
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -030084 my $space;
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -030085 my @labels;
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +010086 my $label = "";
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030087
88 print STDERR "Opening $file\n" if ($debug > 1);
89 open IN, $file;
90 while(<IN>) {
91 $ln++;
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -030092 if (m/^(\S+)(:\s*)(.*)/i) {
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030093 my $new_tag = lc($1);
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -030094 my $sep = $2;
95 my $content = $3;
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030096
Mauro Carvalho Chehab7ce7b892019-06-20 14:23:04 -030097 if (!($new_tag =~ m/(what|where|date|kernelversion|contact|description|users)/)) {
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -030098 if ($tag eq "description") {
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -030099 # New "tag" is actually part of
100 # description. Don't consider it a tag
101 $new_tag = "";
Mauro Carvalho Chehab7d7ea8d2019-06-20 14:23:01 -0300102 } elsif ($tag ne "") {
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300103 parse_error($file, $ln, "tag '$tag' is invalid", $_);
104 }
105 }
106
Mauro Carvalho Chehab2c0700e2019-06-20 14:23:03 -0300107 # Invalid, but it is a common mistake
108 if ($new_tag eq "where") {
109 parse_error($file, $ln, "tag 'Where' is invalid. Should be 'What:' instead", $_);
110 $new_tag = "what";
111 }
112
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300113 if ($new_tag =~ m/what/) {
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300114 $space = "";
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100115 $content =~ s/[,.;]$//;
116
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300117 if ($tag =~ m/what/) {
118 $what .= ", " . $content;
119 } else {
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100120 if ($what) {
121 parse_error($file, $ln, "What '$what' doesn't have a description", "") if (!$data{$what}->{description});
122
123 foreach my $w(split /, /, $what) {
124 $symbols{$w} = $what;
125 };
126 }
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300127
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300128 $what = $content;
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -0300129 $label = $content;
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300130 $new_what = 1;
131 }
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -0300132 push @labels, [($content, $label)];
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300133 $tag = $new_tag;
Mauro Carvalho Chehab6619c662019-06-20 14:22:56 -0300134
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100135 push @{$data{$nametag}->{symbols}}, $content if ($data{$nametag}->{what});
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300136 next;
137 }
138
Mauro Carvalho Chehab7d7ea8d2019-06-20 14:23:01 -0300139 if ($tag ne "" && $new_tag) {
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300140 $tag = $new_tag;
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300141
Mauro Carvalho Chehab61439c42020-10-30 08:40:22 +0100142 $data{$what}->{line_no} = $ln;
143
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300144 if ($new_what) {
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100145 @{$data{$what}->{label_list}} = @labels if ($data{$nametag}->{what});
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -0300146 @labels = ();
147 $label = "";
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300148 $new_what = 0;
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300149
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300150 $data{$what}->{type} = $type;
151 $data{$what}->{file} = $name;
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300152 $data{$what}->{filepath} = $file;
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300153 print STDERR "\twhat: $what\n" if ($debug > 1);
154 }
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300155
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300156 if (!$what) {
157 parse_error($file, $ln, "'What:' should come first:", $_);
158 next;
159 }
Mauro Carvalho Chehabf82a8a72020-10-30 08:40:23 +0100160 if ($new_tag eq "description") {
161 $sep =~ s,:, ,;
Mauro Carvalho Chehab11ce90a2020-10-30 08:40:20 +0100162 $content = ' ' x length($new_tag) . $sep . $content;
Mauro Carvalho Chehabf82a8a72020-10-30 08:40:23 +0100163 while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
164 if ($content =~ m/^(\s*)(\S.*)$/) {
165 # Preserve initial spaces for the first line
Mauro Carvalho Chehab11ce90a2020-10-30 08:40:20 +0100166 $space = $1;
Mauro Carvalho Chehabf82a8a72020-10-30 08:40:23 +0100167 $content = "$2\n";
168 $data{$what}->{$tag} .= $content;
169 } else {
170 undef($space);
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300171 }
Mauro Carvalho Chehabe9bca892020-10-30 08:40:21 +0100172
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300173 } else {
174 $data{$what}->{$tag} = $content;
175 }
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300176 next;
177 }
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300178 }
179
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300180 # Store any contents before tags at the database
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -0300181 if (!$tag && $data{$nametag}->{what}) {
182 $data{$nametag}->{description} .= $_;
Mauro Carvalho Chehab6619c662019-06-20 14:22:56 -0300183 next;
184 }
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300185
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300186 if ($tag eq "description") {
Mauro Carvalho Chehabe9bca892020-10-30 08:40:21 +0100187 my $content = $_;
188 while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
Mauro Carvalho Chehabf82a8a72020-10-30 08:40:23 +0100189 if (m/^\s*\n/) {
190 $data{$what}->{$tag} .= "\n";
191 next;
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300192 }
Mauro Carvalho Chehabf82a8a72020-10-30 08:40:23 +0100193
194 if (!defined($space)) {
195 # Preserve initial spaces for the first line
196 if ($content =~ m/^(\s*)(\S.*)$/) {
197 $space = $1;
198 $content = "$2\n";
199 }
200 } else {
201 $space = "" if (!($content =~ s/^($space)//));
202 }
203 $data{$what}->{$tag} .= $content;
204
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300205 next;
206 }
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300207 if (m/^\s*(.*)/) {
208 $data{$what}->{$tag} .= "\n$1";
209 $data{$what}->{$tag} =~ s/\n+$//;
210 next;
211 }
212
213 # Everything else is error
214 parse_error($file, $ln, "Unexpected line:", $_);
215 }
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100216 $data{$nametag}->{description} =~ s/^\n+// if ($data{$nametag}->{description});
217 if ($what) {
218 parse_error($file, $ln, "What '$what' doesn't have a description", "") if (!$data{$what}->{description});
219
220 foreach my $w(split /, /,$what) {
221 $symbols{$w} = $what;
222 };
223 }
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300224 close IN;
225}
226
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100227sub create_labels {
228 my %labels;
229
230 foreach my $what (keys %data) {
231 next if ($data{$what}->{file} eq "File");
232
233 foreach my $p (@{$data{$what}->{label_list}}) {
234 my ($content, $label) = @{$p};
235 $label = "abi_" . $label . " ";
236 $label =~ tr/A-Z/a-z/;
237
238 # Convert special chars to "_"
239 $label =~s/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xff])/_/g;
240 $label =~ s,_+,_,g;
241 $label =~ s,_$,,;
242
243 # Avoid duplicated labels
244 while (defined($labels{$label})) {
245 my @chars = ("A".."Z", "a".."z");
246 $label .= $chars[rand @chars];
247 }
248 $labels{$label} = 1;
249
250 $data{$what}->{label} = $label;
251
252 # only one label is enough
253 last;
254 }
255 }
256}
257
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300258#
259# Outputs the book on ReST format
260#
Mauro Carvalho Chehab45f96512019-06-20 14:23:00 -0300261
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300262sub output_rest {
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100263 create_labels();
264
Mauro Carvalho Chehab45f96512019-06-20 14:23:00 -0300265 foreach my $what (sort {
266 ($data{$a}->{type} eq "File") cmp ($data{$b}->{type} eq "File") ||
267 $a cmp $b
268 } keys %data) {
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300269 my $type = $data{$what}->{type};
270 my $file = $data{$what}->{file};
Mauro Carvalho Chehab45f96512019-06-20 14:23:00 -0300271 my $filepath = $data{$what}->{filepath};
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300272
Mauro Carvalho Chehab61439c42020-10-30 08:40:22 +0100273 if ($enable_lineno) {
274 printf "#define LINENO %s%s#%s\n\n",
275 $prefix, $data{$what}->{file},
276 $data{$what}->{line_no};
277 }
278
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300279 my $w = $what;
280 $w =~ s/([\(\)\_\-\*\=\^\~\\])/\\$1/g;
281
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100282 $filepath =~ s,.*/(.*/.*),$1,;;
Mauro Carvalho Chehab45f96512019-06-20 14:23:00 -0300283 $filepath =~ s,[/\-],_,g;;
284 my $fileref = "abi_file_".$filepath;
285
286 if ($type eq "File") {
287 my $bar = $w;
288 $bar =~ s/./-/g;
289
290 print ".. _$fileref:\n\n";
291 print "$w\n$bar\n\n";
292 } else {
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100293 printf ".. _%s:\n\n", $data{$what}->{label};
Mauro Carvalho Chehab45f96512019-06-20 14:23:00 -0300294
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100295 my @names = split /, /,$w;
Mauro Carvalho Chehab45f96512019-06-20 14:23:00 -0300296 my $len = 0;
297
298 foreach my $name (@names) {
299 $len = length($name) if (length($name) > $len);
300 }
301
302 print "What:\n\n";
303
304 print "+-" . "-" x $len . "-+\n";
305 foreach my $name (@names) {
306 printf "| %s", $name . " " x ($len - length($name)) . " |\n";
307 print "+-" . "-" x $len . "-+\n";
308 }
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100309
310 print "\nDefined on file :ref:`$file <$fileref>`\n\n";
Mauro Carvalho Chehab45f96512019-06-20 14:23:00 -0300311 }
312
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100313 my $desc = "";
314 $desc = $data{$what}->{description} if (defined($data{$what}->{description}));
315 $desc =~ s/\s+$/\n/;
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300316
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300317 if (!($desc =~ /^\s*$/)) {
Mauro Carvalho Chehab11ce90a2020-10-30 08:40:20 +0100318 if ($description_is_rst) {
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300319 print "$desc\n\n";
Mauro Carvalho Chehab11ce90a2020-10-30 08:40:20 +0100320 } else {
321 $desc =~ s/^\s+//;
322
323 # Remove title markups from the description, as they won't work
324 $desc =~ s/\n[\-\*\=\^\~]+\n/\n\n/g;
325
326 if ($desc =~ m/\:\n/ || $desc =~ m/\n[\t ]+/ || $desc =~ m/[\x00-\x08\x0b-\x1f\x7b-\xff]/) {
327 # put everything inside a code block
328 $desc =~ s/\n/\n /g;
329
330 print "::\n\n";
331 print " $desc\n\n";
332 } else {
333 # Escape any special chars from description
334 $desc =~s/([\x00-\x08\x0b-\x1f\x21-\x2a\x2d\x2f\x3c-\x40\x5c\x5e-\x60\x7b-\xff])/\\$1/g;
335 print "$desc\n\n";
336 }
Mauro Carvalho Chehab4e6a6232019-06-20 14:22:57 -0300337 }
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300338 } else {
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -0300339 print "DESCRIPTION MISSING for $what\n\n" if (!$data{$what}->{is_file});
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300340 }
Mauro Carvalho Chehab6619c662019-06-20 14:22:56 -0300341
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100342 if ($data{$what}->{symbols}) {
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -0300343 printf "Has the following ABI:\n\n";
344
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100345 foreach my $content(@{$data{$what}->{symbols}}) {
346 my $label = $data{$symbols{$content}}->{label};
Mauro Carvalho Chehabd0ebaf52019-06-20 14:22:58 -0300347
348 # Escape special chars from content
349 $content =~s/([\x00-\x1f\x21-\x2f\x3a-\x40\x7b-\xff])/\\$1/g;
350
351 print "- :ref:`$content <$label>`\n\n";
352 }
353 }
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300354 }
355}
356
357#
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300358# Searches for ABI symbols
359#
360sub search_symbols {
361 foreach my $what (sort keys %data) {
362 next if (!($what =~ m/($arg)/));
363
364 my $type = $data{$what}->{type};
365 next if ($type eq "File");
366
367 my $file = $data{$what}->{filepath};
368
369 my $bar = $what;
370 $bar =~ s/./-/g;
371
372 print "\n$what\n$bar\n\n";
373
Mauro Carvalho Chehab234948b2020-10-30 08:40:24 +0100374 my $kernelversion = $data{$what}->{kernelversion} if (defined($data{$what}->{kernelversion}));
375 my $contact = $data{$what}->{contact} if (defined($data{$what}->{contact}));
376 my $users = $data{$what}->{users} if (defined($data{$what}->{users}));
377 my $date = $data{$what}->{date} if (defined($data{$what}->{date}));
378 my $desc = $data{$what}->{description} if (defined($data{$what}->{description}));
379
380 $kernelversion =~ s/^\s+// if ($kernelversion);
381 $contact =~ s/^\s+// if ($contact);
382 if ($users) {
383 $users =~ s/^\s+//;
384 $users =~ s/\n//g;
385 }
386 $date =~ s/^\s+// if ($date);
387 $desc =~ s/^\s+// if ($desc);
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300388
389 printf "Kernel version:\t\t%s\n", $kernelversion if ($kernelversion);
390 printf "Date:\t\t\t%s\n", $date if ($date);
391 printf "Contact:\t\t%s\n", $contact if ($contact);
392 printf "Users:\t\t\t%s\n", $users if ($users);
393 print "Defined on file:\t$file\n\n";
394 print "Description:\n\n$desc";
395 }
396}
397
Mauro Carvalho Chehab61439c42020-10-30 08:40:22 +0100398# Ensure that the prefix will always end with a slash
399# While this is not needed for find, it makes the patch nicer
400# with --enable-lineno
401$prefix =~ s,/?$,/,;
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300402
403#
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300404# Parses all ABI files located at $prefix dir
405#
406find({wanted =>\&parse_abi, no_chdir => 1}, $prefix);
407
408print STDERR Data::Dumper->Dump([\%data], [qw(*data)]) if ($debug);
409
410#
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300411# Handles the command
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300412#
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300413if ($cmd eq "rest") {
414 output_rest;
Mauro Carvalho Chehab7ce7b892019-06-20 14:23:04 -0300415} elsif ($cmd eq "search") {
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300416 search_symbols;
417}
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300418
419
420__END__
421
422=head1 NAME
423
424abi_book.pl - parse the Linux ABI files and produce a ReST book.
425
426=head1 SYNOPSIS
427
Mauro Carvalho Chehab61439c42020-10-30 08:40:22 +0100428B<abi_book.pl> [--debug] [--enable-lineno] [--man] [--help]
429 [--(no-)rst-source] [--dir=<dir>] <COMAND> [<ARGUMENT>]
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300430
431Where <COMMAND> can be:
432
433=over 8
434
435B<search> [SEARCH_REGEX] - search for [SEARCH_REGEX] inside ABI
436
Mauro Carvalho Chehab7ce7b892019-06-20 14:23:04 -0300437B<rest> - output the ABI in ReST markup language
438
439B<validate> - validate the ABI contents
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300440
441=back
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300442
443=head1 OPTIONS
444
445=over 8
446
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300447=item B<--dir>
448
449Changes the location of the ABI search. By default, it uses
450the Documentation/ABI directory.
451
Mauro Carvalho Chehab11ce90a2020-10-30 08:40:20 +0100452=item B<--rst-source> and B<--no-rst-source>
453
454The input file may be using ReST syntax or not. Those two options allow
455selecting between a rst-compliant source ABI (--rst-source), or a
456plain text that may be violating ReST spec, so it requres some escaping
457logic (--no-rst-source).
458
Mauro Carvalho Chehab61439c42020-10-30 08:40:22 +0100459=item B<--enable-lineno>
460
461Enable output of #define LINENO lines.
462
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300463=item B<--debug>
464
465Put the script in verbose mode, useful for debugging. Can be called multiple
466times, to increase verbosity.
467
468=item B<--help>
469
470Prints a brief help message and exits.
471
472=item B<--man>
473
474Prints the manual page and exits.
475
476=back
477
478=head1 DESCRIPTION
479
Mauro Carvalho Chehab33e3e992019-06-20 14:22:59 -0300480Parse the Linux ABI files from ABI DIR (usually located at Documentation/ABI),
481allowing to search for ABI symbols or to produce a ReST book containing
482the Linux ABI documentation.
483
484=head1 EXAMPLES
485
486Search for all stable symbols with the word "usb":
487
488=over 8
489
490$ scripts/get_abi.pl search usb --dir Documentation/ABI/stable
491
492=back
493
494Search for all symbols that match the regex expression "usb.*cap":
495
496=over 8
497
498$ scripts/get_abi.pl search usb.*cap
499
500=back
501
502Output all obsoleted symbols in ReST format
503
504=over 8
505
506$ scripts/get_abi.pl rest --dir Documentation/ABI/obsolete
507
508=back
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300509
510=head1 BUGS
511
Mauro Carvalho Chehab7ce7b892019-06-20 14:23:04 -0300512Report bugs to Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300513
514=head1 COPYRIGHT
515
Mauro Carvalho Chehab7ce7b892019-06-20 14:23:04 -0300516Copyright (c) 2016-2019 by Mauro Carvalho Chehab <mchehab+samsung@kernel.org>.
Mauro Carvalho Chehabbbc249f2019-06-20 14:22:55 -0300517
518License GPLv2: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>.
519
520This is free software: you are free to change and redistribute it.
521There is NO WARRANTY, to the extent permitted by law.
522
523=cut