Print this page
manpage lint.

@@ -14,10 +14,11 @@
 #
 
 #
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright 2008, 2011 Richard Lowe
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
 #
 
 '''OpenSolaris extensions to Mercurial
 
     This extension contains a number of commands to help you work with

@@ -102,11 +103,11 @@
 from mercurial import cmdutil, ignore, node, patch
 
 from onbld.Scm.WorkSpace import WorkSpace, WorkList
 from onbld.Scm.Backup import CdmBackup
 from onbld.Checks import Cddl, Comments, Copyright, CStyle, HdrChk
-from onbld.Checks import JStyle, Keywords, Mapfile
+from onbld.Checks import JStyle, Keywords, ManLint, Mapfile
 
 
 def yes_no(ui, msg, default):
     if default:
         prompt = ' [Y/n]:'

@@ -388,10 +389,44 @@
         ret |= Cddl.cddlchk(fh, lenient=lenient, output=ui)
         fh.close()
     return ret
 
 
+def cdm_manlintchk(ui, repo, *args, **opts):
+    '''check for mandoc lint
+
+    Check for man page formatting errors.
+
+    Files can be excluded from this check using the manlint.NOT
+    file.  See NOT Files in the extension documentation ('hg help
+    cdm').
+    '''
+
+    filelist = buildfilelist(wslist[repo], opts.get('parent'), args)
+    exclude = not_check(repo, 'manlint')
+    ret = 0
+
+    # Man pages are identified as having a suffix starting with a digit.
+    ManfileRE = re.compile(r'.*\.[0-9][a-z]*$', re.IGNORECASE)
+
+    ui.write('Man format check:\n')
+
+    for f, e in filelist:
+        if e and e.is_removed():
+            continue
+        elif (not ManfileRE.match(f)):
+            continue
+        elif (e or opts.get('honour_nots')) and exclude(f):
+            ui.status('Skipping %s...\n' % f)
+            continue
+
+        fh = open(f, 'r')
+        ret |= ManLint.manlint(fh, output=ui, picky=True)
+        fh.close()
+    return ret
+
+
 def cdm_mapfilechk(ui, repo, *args, **opts):
     '''check for a valid mapfile header block in active files
 
     Check that all link-editor mapfiles contain the standard mapfile
     header comment directing the reader to the document containing

@@ -792,10 +827,11 @@
 
       - copyright  (copyright statements)
       - cstyle     (C source style)
       - hdrchk     (C header style)
       - jstyle     (java source style)
+      - manlint    (man page formatting)
       - mapfilechk (link-editor mapfiles)
       - permchk    (file permissions)
       - keywords   (SCCS keywords)
 
     With the global -q/--quiet option, only provide output for those

@@ -804,10 +840,11 @@
 
     cmds = [cdm_copyright,
         cdm_cstyle,
         cdm_hdrchk,
         cdm_jstyle,
+        cmd_manlintchk,
         cdm_mapfilechk,
         cdm_permchk,
         cdm_keywords]
 
     return run_checks(wslist[repo], cmds, *args, **opts)

@@ -826,10 +863,11 @@
       - copyright  (copyright statements)
       - cstyle     (C source style)
       - hdrchk     (C header style)
       - jstyle     (java source style)
       - keywords   (SCCS keywords)
+      - manlint    (man page formatting)
       - mapfilechk (link-editor mapfiles)
       - permchk    (file permissions)
       - tagchk     (addition/modification of tags)
 
     Additionally, the workspace is checked for outgoing merges (which

@@ -846,10 +884,11 @@
     #
     cmds = [cdm_copyright,
         cdm_cstyle,
         cdm_hdrchk,
         cdm_jstyle,
+        cdm_manlintchk,
         cdm_mapfilechk,
         cdm_permchk,
         cdm_keywords,
         cdm_comchk,
         cdm_tagchk,

@@ -1429,10 +1468,12 @@
     '^list|active': (cdm_list, [('p', 'parent', '', 'parent workspace'),
                                 ('a', 'added', None, 'show added files'),
                                 ('m', 'modified', None, 'show modified files'),
                                 ('r', 'removed', None, 'show removed files')],
                     'hg list [-amrRu] [-p PARENT]'),
+    'manlint': (cdm_manlintchk, [('p', 'parent', '', 'parent workspace')],
+                'hg manlint [-p PARENT]'),
     'mapfilechk': (cdm_mapfilechk, [('p', 'parent', '', 'parent workspace')],
                 'hg mapfilechk [-p PARENT]'),
     '^nits': (cdm_nits, [('p', 'parent', '', 'parent workspace')],
              'hg nits [-p PARENT]'),
     '^pbchk': (cdm_pbchk, [('p', 'parent', '', 'parent workspace'),