Merge pull request #135 from libtom/pr/helper-pl-doc-check Add doc checking to helper.pl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/helper.pl b/helper.pl
index 5afeb82..923bc2b 100755
--- a/helper.pl
+++ b/helper.pl
@@ -115,6 +115,30 @@ MARKER
return $fails;
}
+sub check_doc {
+ my $fails = 0;
+ my $tex = read_file('doc/bn.tex');
+ my $tmh = read_file('tommath.h');
+ my @functions = $tmh =~ /\n\s*[a-zA-Z0-9_* ]+?(mp_[a-z0-9_]+)\s*\([^\)]+\)\s*;/sg;
+ my @macros = $tmh =~ /\n\s*#define\s+([a-z0-9_]+)\s*\([^\)]+\)/sg;
+ for my $n (sort @functions) {
+ (my $nn = $n) =~ s/_/\\_/g; # mp_sub_d >> mp\_sub\_d
+ if ($tex !~ /index\Q{$nn}\E/) {
+ warn "[missing_doc_for_function] $n\n";
+ $fails++
+ }
+ }
+ for my $n (sort @macros) {
+ (my $nn = $n) =~ s/_/\\_/g; # mp_iszero >> mp\_iszero
+ if ($tex !~ /index\Q{$nn}\E/) {
+ warn "[missing_doc_for_macro] $n\n";
+ $fails++
+ }
+ }
+ warn( $fails > 0 ? "check_doc: FAIL $fails\n" : "check-doc: PASS\n" );
+ return $fails;
+}
+
sub prepare_variable {
my ($varname, @list) = @_;
my $output = "$varname=";
@@ -275,6 +299,7 @@ MARKER
GetOptions( "s|check-source" => \my $check_source,
"o|check-comments" => \my $check_comments,
"m|check-makefiles" => \my $check_makefiles,
+ "d|check-doc" => \my $check_doc,
"a|check-all" => \my $check_all,
"u|update-makefiles" => \my $update_makefiles,
"h|help" => \my $help
@@ -283,6 +308,7 @@ GetOptions( "s|check-source" => \my $check_source,
my $failure;
$failure ||= check_source() if $check_all || $check_source;
$failure ||= check_comments() if $check_all || $check_comments;
+$failure ||= check_doc() if $check_doc; # temporarily excluded from --check-all
$failure ||= process_makefiles(0) if $check_all || $check_makefiles;
$failure ||= process_makefiles(1) if $update_makefiles;