Merge branch 'maint-0.4.8'
[tor.git] / scripts / maint / checkOptionDocs.pl.in
blobd2c2a838d6ec54a9d6fd1c7b764eb26a0a83056a
1 #!/usr/bin/perl -w
2 use strict;
4 my %options = ();
5 my %descOptions = ();
6 my %torrcSampleOptions = ();
7 my %manPageOptions = ();
9 # Load the canonical list as actually accepted by Tor.
10 open(F, "@abs_top_builddir@/src/app/tor --list-torrc-options |") or die;
11 while (<F>) {
12 next if m!\[notice\] Tor v0\.!;
13 if (m!^([A-Za-z0-9_]+)!) {
14 $options{$1} = 1;
15 } else {
16 print "Unrecognized output> ";
17 print;
20 close F;
22 # Load the contents of torrc.sample
23 sub loadTorrc {
24 my ($fname, $options) = @_;
25 local *F;
26 open(F, "$fname") or die;
27 while (<F>) {
28 next if (m!##+!);
29 if (m!#([A-Za-z0-9_]+)!) {
30 $options->{$1} = 1;
33 close F;
37 loadTorrc("@abs_top_srcdir@/src/config/torrc.sample.in", \%torrcSampleOptions);
39 # Try to figure out what's in the man page.
41 my $considerNextLine = 0;
42 open(F, "@abs_top_srcdir@/doc/man/tor.1.txt") or die;
43 while (<F>) {
44 if (m!^(?:\[\[([A-za-z0-9_]+)\]\] *)?\*\*([A-Za-z0-9_]+)\*\*! && $considerNextLine) {
45 $manPageOptions{$2} = 1;
46 print "Missing an anchor: $2\n" unless (defined $1 or $2 eq 'tor');
47 $considerNextLine = 1;
48 } elsif (m!^\s*$! or
49 m!^\s*\+\s*$! or
50 m!^\s*//!) {
51 $considerNextLine = 1;
52 } else {
53 $considerNextLine = 0;
56 close F;
58 # Now, display differences:
60 sub subtractHashes {
61 my ($s, $a, $b) = @_;
62 my @lst = ();
63 for my $k (keys %$a) {
64 push @lst, $k unless (exists $b->{$k});
66 print "$s: ", join(' ', sort @lst), "\n\n";
70 # subtractHashes("No online docs", \%options, \%descOptions);
71 # subtractHashes("Orphaned online docs", \%descOptions, \%options);
73 subtractHashes("Orphaned in torrc.sample.in", \%torrcSampleOptions, \%options);
75 subtractHashes("Not in man page", \%options, \%manPageOptions);
76 subtractHashes("Orphaned in man page", \%manPageOptions, \%options);