#!/usr/bin/perl # man page validate: last minute check for errors # Warren Block use strict; use warnings; use feature qw/switch/; sub usage { print "$0 -- validate man pages\n"; print "Check an mdoc(7) file from stdin or by filename\n"; print "usage: $0 filename\n"; print " cat file | $0\n"; # -a all checks # -ad all but date checks # -adn all but date and new line per sentence (default) # -c cvsup check # -d dir to check a whole directory (implies -f) # -D date checks # -f include basename(filename) in output # -m see if it renders as a man page without errors # -n new line per sentence check # -r repeated word checks # -s spelling checks # add routine to print output # use getopt # other tests: line too long exit 0; } usage() if (@ARGV > 1) || (@ARGV > 0 && $ARGV[0] =~ /-h/); chomp(my $today = `date "+%B %d, %G"`); my $docdate; my @repeatedwords = qw( and are as is it last the that ); my @spellingerrs = qw( accesing addresss alot annonymous anonymus anormalous aritmetic asynchroneous authorty choise cince colision commiter comiters commited credentail deamon dependancy dependancys dependiency dependendencies developement diretories diretory directorys directorys exibits extemely extremly formated freind fuction idosyncracies indentical independant indepth inputed issueing kernal lable lables albel albels libraru linerly manaul negociated ommit optiion partion partions partiton partitons protcol protcols reloation reloations sepcify sepcifies specifiy seperate seperates settable settt sofware spearator stantdard teh translater translaters upto wanna wierd ); while (<>) { chomp; # skip comments and blank lines next if /^\.\\\"/; next if /^\s*$/; given ( $_ ) { # document date (.Dd) when ( /^.Dd (.*)$/ ) { $docdate = $1; print "$.:$_\n date is not today ($today)\n" unless $today eq $1; } # sentences should begin on a new line when ( /^.+\w\.\s+\w/ ) { print "$.:$_\n sentences should begin on a new line\n"; } # repeated words for my $word (@repeatedwords) { when ( /\b$word\b\s*\b$word\b/i ) { print "$.:$_\n repeated word ($word)\n"; } } # spelling errors for my $word (@spellingerrs) { when ( /\b$word\b/i ) { print "$.:$_\n spelling error ($word)\n"; } } # cvsup when ( /cvsup/ ) { print "$.:$_\n replace cvsup with csup\n"; } } } print ".Dd not found\n" unless $docdate;