pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/textproc/mdoclint Initial import of mdoclint-1.0:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5a7961c1a627
branches:  trunk
changeset: 555399:5a7961c1a627
user:      wiz <wiz%pkgsrc.org@localhost>
date:      Sun Mar 01 21:25:39 2009 +0000

description:
Initial import of mdoclint-1.0:

mdoclint is a tool to verify that man pages follow the conventions
for NetBSD (and most other BSDs) regarding structure and macro
usage.

diffstat:

 textproc/mdoclint/DESCR            |    3 +
 textproc/mdoclint/Makefile         |   35 ++
 textproc/mdoclint/PLIST            |    3 +
 textproc/mdoclint/files/TODO       |   24 +
 textproc/mdoclint/files/mdoclint   |  589 +++++++++++++++++++++++++++++++++++++
 textproc/mdoclint/files/mdoclint.1 |  157 +++++++++
 6 files changed, 811 insertions(+), 0 deletions(-)

diffs (truncated from 835 to 300 lines):

diff -r 44be9f81cdbd -r 5a7961c1a627 textproc/mdoclint/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/mdoclint/DESCR   Sun Mar 01 21:25:39 2009 +0000
@@ -0,0 +1,3 @@
+mdoclint is a tool to verify that man pages follow the conventions
+for NetBSD (and most other BSDs) regarding structure and macro
+usage.
diff -r 44be9f81cdbd -r 5a7961c1a627 textproc/mdoclint/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/mdoclint/Makefile        Sun Mar 01 21:25:39 2009 +0000
@@ -0,0 +1,35 @@
+# $NetBSD: Makefile,v 1.1.1.1 2009/03/01 21:25:39 wiz Exp $
+
+DISTNAME=      mdoclint-1.0
+CATEGORIES=    textproc
+MASTER_SITES=  # none
+DISTFILES=     # none
+
+MAINTAINER=    wiz%NetBSD.org@localhost
+#HOMEPAGE=     #
+COMMENT=       Tool for verifying man pages
+
+PKG_DESTDIR_SUPPORT=   user-destdir
+INSTALLATION_DIRS=     bin ${PKGMANDIR}/man1
+
+WRKSRC=                ${WRKDIR}
+NO_CHECKSUM=   yes
+NO_BUILD=      yes
+USE_LANGUAGES= # none
+USE_TOOLS+=    perl:run
+
+SUBST_CLASSES+=                perl
+SUBST_STAGE.perl=      do-configure
+SUBST_FILES.perl=      mdoclint
+SUBST_SED.perl+=       -e 's,@PERL5@,${PERL5},g'
+SUBST_MESSAGE.perl=    Fixing path to perl.
+
+do-extract:
+       cd ${FILESDIR} && cp mdoclint* ${WRKSRC}/
+
+do-install:
+       ${INSTALL_SCRIPT} ${WRKSRC}/mdoclint ${DESTDIR}${PREFIX}/bin
+       ${INSTALL_MAN} ${FILESDIR}/mdoclint.1 \
+               ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+
+.include "../../mk/bsd.pkg.mk"
diff -r 44be9f81cdbd -r 5a7961c1a627 textproc/mdoclint/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/mdoclint/PLIST   Sun Mar 01 21:25:39 2009 +0000
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2009/03/01 21:25:39 wiz Exp $
+bin/mdoclint
+man/man1/mdoclint.1
diff -r 44be9f81cdbd -r 5a7961c1a627 textproc/mdoclint/files/TODO
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/mdoclint/files/TODO      Sun Mar 01 21:25:39 2009 +0000
@@ -0,0 +1,24 @@
+# $NetBSD: TODO,v 1.1.1.1 2009/03/01 21:25:39 wiz Exp $
+. check for font changes in .Bd -literal (.Fd, .No, ...)
+. add checks for only allowed values after .Bl/.Bd/...
+. compare internal with external section name
+. complain if NULL is used without .Dv
+. complain if error values are used without .Er
+[. Nm doesn't need an argument, most of the time (?)]
+. .Nm "": remove if not needed
+. count correct matching of .Bd/.Ed, .Rs/.Re and similar
+. check AUTHORS sections for usage of .An name Aq email@host
+. recognize more section headers?
+. check .Rs/.Re contents?
+. empty lines in .Bd -literal ignored -- groff ignores them, too...
+. ignore .Bd -literal for most checks (.Nm/.Xr, new sentence, new line, ...)
+. ignore matching braces in macro arguments
+. fix bogus report if no .Xr, but .Rs in SEE ALSO section
+. recognize which sections should be in a particular type of manpage
+  (like RETURN VALUES in 2&3, EXIT STATUS in 1&8 et al.)
+. check paths pointed at by .Pa directives?
+. sort in WARNS and ERRS and add switches for those two
+. complain about `,', `;' and similar on beginning of line
+. complain about ',' after last .Nm entry
+. complain about NULL without .Dv
+. complain about -1 (not \-1)
diff -r 44be9f81cdbd -r 5a7961c1a627 textproc/mdoclint/files/mdoclint
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/mdoclint/files/mdoclint  Sun Mar 01 21:25:39 2009 +0000
@@ -0,0 +1,589 @@
+#!@PERL5@
+#
+# $OpenBSD: mdoclint,v 1.13 2008/12/31 10:55:11 espie Exp $
+# $NetBSD: mdoclint,v 1.1.1.1 2009/03/01 21:25:39 wiz Exp $
+#
+# Copyright (c) 2001-2009 Thomas Klausner
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR, THOMAS KLAUSNER,
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+use strict;
+use warnings;
+
+$| = 1;
+
+package Parser;
+use Getopt::Std;
+
+use constant {
+       OPENBSD => 0,
+       NETBSD => 1
+};
+
+use vars qw(
+       $opt_a $opt_D $opt_d $opt_e $opt_F $opt_f $opt_H $opt_h $opt_m
+       $opt_n $opt_o $opt_P $opt_p $opt_r $opt_S $opt_s $opt_v
+       $opt_X $opt_x
+);
+
+
+my $arch=`uname -m`;
+chomp($arch);
+my $options="aDdeFfHhmnoPprSsvXx";
+
+sub usage
+       {
+       my $default = OPENBSD ? "-aDdfHmnoPprSsXx" : "-aDdefHmnoPprSsXx";
+       
+       print STDERR <<"EOF";
+mdoclint: verify man page correctness
+usage: mdoclint [-$options] file ...
+       -a      warn about SEE ALSO section problems
+       -D      warn about bad casing and archs in .Dt
+       -d      warn about bad date strings (in .Dd only)
+       -e      warn about unsorted errors (for functions)
+       -F      fix whitespace problems (asks before overwriting)
+       -f      warn about possible incorrect .Fn syntax
+       -H      warn about characters that produce problems in HTML output
+       -h      display this help text
+       -m      warn about man pages that are not in mdoc(7) format
+       -n      warn about .Nd's ending in '.'
+       -o      warn about non-empty .Os strings
+       -P      warn about paragraph problems
+       -p      warn about punctuation problems
+       -r      warn about missing RCS Id
+       -S      warn about any .Sh weirdness
+       -s      warn about whitespace problems
+       -v      verbose output
+       -X      warn about explicit mentions of FreeBSD, NetBSD, or OpenBSD
+       -x      warn about cross-references with missing targets
+Default is $default if no flag is specified.
+EOF
+       exit(0);
+}
+
+
+my %short = (
+    "Free" => ".Fx",
+    "Net" => ".Nx",
+    "Open" => ".Ox"
+);
+
+# constants to build
+my %sections;
+my $arches_re;
+my $sections_re;
+my $esections_re;
+my $valid_date_re;
+# and the code that builds them
+{
+       my @sections = (
+               "NAME",
+               NETBSD ? "LIBRARY" : undef,
+               "SYNOPSIS",
+               "DESCRIPTION",
+               NETBSD ? "EXIT STATUS" : undef,
+               "RETURN VALUES",
+               "ENVIRONMENT",
+               "FILES",
+               "EXAMPLES",
+               "DIAGNOSTICS",
+               "ERRORS",
+               "SEE ALSO",
+               "STANDARDS",
+               "HISTORY",
+               "AUTHORS",
+               "CAVEATS",
+               "BUGS",
+               NETBSD ? "SECURITY CONSIDERATIONS" : undef
+       );
+
+       my $i = 1;
+       for my $sh (@sections) {
+               if (defined $sh) {
+                       $sections{$sh} = $i++;
+               }
+       }
+       my @arches;
+       if (OPENBSD) {
+               @arches =
+                   (qw(alpha amd64 arm armish aviion cats hp300 hppa
+                   hppa64 i386 landisk luna88k mac68k macppc mvme68k
+                   mvme88k sgi socppc sparc sparc64 vax zaurus));
+       }
+       if (NETBSD) {
+               @arches =
+                   (qw(acorn26 acorn32 algor alpha amiga arc atari
+                   bebox cats cesfic cobalt dreamcast evbarm evbmips
+                   evbsh3 evbsh5 hp300 hp700 hpcarm hpcmips hpcsh
+                   i386 ibmnws luna68k mac68k macppc mipsco mmeye
+                   mvme68k mvmeppc netwinder news68k newsmips next68k
+                   pc532 playstation2 pmax pmppc prep sandpoint sbmips
+                   sgimips shark sparc sparc64 sun2 sun3 vax walnut
+                   x68k x86_64));
+       }
+       my $a = join('|', @arches);
+       $arches_re = qr{(?:$a)}o;
+       if (OPENBSD) {
+               $sections_re = qr{(?:3p|[1-9])}o;
+               $esections_re = qr{(?:3p|[0-9])}o;
+       }
+       if (NETBSD) {
+               $sections_re = qr{[1-9]}o;
+               $esections_re = qr{[0-9]}o;
+       }
+       if (OPENBSD) {
+               $valid_date_re = qr{\$Mdocdate\b};
+       }
+       if (NETBSD) {
+               $valid_date_re = qr{(?:January|February|March|April|May|June|July|August|September|October|November|December)\s*[1-9][0-9]*,\s*(?:198[0-9]|199[0-9]|200[012345678])$}o;
+       }
+}
+
+sub debug
+{
+       my $self = shift;
+       print STDOUT "debug: $self->{fn}:$self->{ln}: @_\n" if $opt_v;
+}
+
+sub warning
+{
+       my $self = shift;
+       print STDOUT "$self->{fn}:$self->{current_section_header}:$self->{ln}: ", join('', @_), "\n";
+}
+
+sub handle_options
+{
+       getopts($options);
+       $opt_h and usage();
+
+       # default to all warnings if no flag is set
+       unless ($opt_a or $opt_D or $opt_d or $opt_e or $opt_f or $opt_H
+           or $opt_m or $opt_n or $opt_o or $opt_P or $opt_p or $opt_r
+           or $opt_S or $opt_s or $opt_X or $opt_x) {
+               $opt_a = $opt_D = $opt_d = $opt_f = $opt_H = $opt_m =
+                   $opt_n = $opt_o = $opt_P = $opt_p = $opt_r = $opt_S =
+                   $opt_s = $opt_X = $opt_x = 1;
+                   $opt_e = 1 if NETBSD;
+       }
+}
+
+
+sub verify_xref
+{
+       my ($self, $page, $section, $pre, $post) = @_;
+       if ("$page.$section" eq $self->{fn}) {
+               $self->warning("Xref to itself (use .Nm instead)");
+       }
+       # try to find corresponding man page
+       for my $dir ("/usr/share/man",
+           OPENBSD ? "/usr/X11R6/man" : "/usr/X11R7/man") {
+               for my $a ("", $arch) {
+                       for my $page ("cat$section/$a/$page.0",
+                           "man$section/$a/$page.$section") {
+                               return 1 if -f "$dir/$page";
+                       }
+               }
+       }
+       return 1 if -f "./$page.$section";
+
+       $self->warning($pre."trailing Xref to $page($section)$post");
+       return 0;
+}
+
+sub new



Home | Main Index | Thread Index | Old Index